/* ===== Holiday Code Club ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #10233f; --panel: #1b3355; --panel2: #24436e; --ink: #f2f8ff;
  --acc: #ffd166; --green: #43c59e; --blue: #4d9de0; --red: #ef476f;
  --purple: #9b6dff; --orange: #ff9f43; --cell: 52px;
}
html, body { height: 100%; }
body {
  font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 50% -100px, #23477a, var(--bg));
  color: var(--ink); overflow-x: hidden;
}
.screen { min-height: 100vh; padding: 14px; max-width: 1280px; margin: 0 auto; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ===== top bars ===== */
.top-bar { display: flex; align-items: center; gap: 10px; padding: 6px 2px 14px; }
.top-bar h2 { font-size: 22px; flex: 1; text-align: center; }
.spacer { width: 42px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 2px solid #3d6194;
  background: var(--panel); color: var(--ink); font-size: 20px;
}
.icon-btn:hover { background: var(--panel2); }
.map-stars { min-width: 70px; text-align: right; font-size: 18px; }

/* ===== home ===== */
.home-head { text-align: center; padding: 34px 0 8px; position: relative; z-index: 2; }
.home-head h1 { font-size: clamp(30px, 6vw, 52px); text-shadow: 0 4px 0 #0a1730; }
.tagline { opacity: .8; margin-top: 6px; font-size: 17px; }
.profile-row {
  display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  margin: 34px 0 26px; position: relative; z-index: 2;
}
.profile-card {
  background: var(--panel); border: 3px solid #3d6194; border-radius: 20px;
  padding: 20px 26px; width: 250px; text-align: center; transition: .15s;
}
.profile-card:hover { transform: translateY(-4px); border-color: var(--acc); }
.profile-card .avatar { font-size: 54px; }
.profile-card .pname { font-size: 21px; font-weight: bold; margin: 6px 0 2px; }
.profile-card .pstats { font-size: 14px; opacity: .8; }
.profile-card .pedit { margin-top: 10px; font-size: 13px; background: none; border: 1px dashed #6d8cbb; color: #9db8dc; border-radius: 8px; padding: 4px 10px; }
.big-btn {
  border: none; border-radius: 14px; padding: 13px 22px; font-size: 17px;
  background: linear-gradient(180deg, #ffd166, #f4b740); color: #4a3200;
  font-weight: bold; box-shadow: 0 4px 0 #b9831f;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b9831f; }
.big-btn.ghost { background: var(--panel); color: var(--ink); box-shadow: 0 4px 0 #0d1c36; border: 2px solid #3d6194; }
.big-btn.small { padding: 8px 14px; font-size: 14px; }
.big-btn.run { background: linear-gradient(180deg, #43c59e, #2ea382); color: #053b2c; box-shadow: 0 4px 0 #1c7a5f; }
.big-btn.stop { background: linear-gradient(180deg, #ef476f, #d6365c); color: #fff; box-shadow: 0 4px 0 #9c2543; }
#btn-parent { display: block; margin: 0 auto 30px; position: relative; z-index: 2; }

/* snow */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.snow i {
  position: absolute; top: -12px; color: #fff; opacity: .8; font-style: normal;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(360deg); }
}

/* ===== tracks ===== */
.track-row { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; padding-top: 10px; }
.track-card {
  background: var(--panel); border: 3px solid #3d6194; border-radius: 22px;
  width: 320px; padding: 24px; text-align: center; transition: .15s;
}
.track-card:hover { transform: translateY(-5px); border-color: var(--acc); }
.track-card .ticon { font-size: 62px; }
.track-card h3 { font-size: 24px; margin: 8px 0 2px; }
.track-card .tage { color: var(--acc); font-size: 14px; font-weight: bold; }
.track-card p { font-size: 14px; opacity: .85; margin: 10px 0 14px; min-height: 58px; }
.track-card .tstars { font-size: 16px; }

/* ===== level map ===== */
.level-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px; padding: 8px 0 20px;
}
.level-card {
  background: var(--panel); border: 3px solid #3d6194; border-radius: 18px;
  padding: 16px 12px; text-align: center; position: relative; transition: .15s;
}
.level-card:hover:not(.locked) { transform: translateY(-4px); border-color: var(--acc); }
.level-card .lnum {
  width: 34px; height: 34px; margin: 0 auto 6px; border-radius: 50%;
  background: var(--blue); color: #06203c; font-weight: bold; line-height: 34px;
}
.level-card .lname { font-size: 14px; font-weight: bold; }
.level-card .lstars { font-size: 16px; margin-top: 6px; letter-spacing: 2px; }
.level-card.locked { opacity: .45; filter: grayscale(.7); }
.level-card.locked .lnum { background: #4a5f80; }
.map-actions { text-align: center; padding-bottom: 30px; }

/* ===== play layout ===== */
.play-layout { display: grid; grid-template-columns: 250px 1fr minmax(300px, 460px); gap: 14px; align-items: start; }
.side, .work-col, .stage-col { min-width: 0; }
.goal-card {
  background: var(--panel); border: 2px solid #3d6194; border-radius: 16px;
  padding: 14px; font-size: 14.5px; line-height: 1.45;
}
.goal-par { color: var(--acc); font-size: 13px; margin-top: 8px; font-weight: bold; }
.hint-btn { margin-top: 10px; background: none; border: 1px dashed #6d8cbb; color: #9db8dc; border-radius: 8px; padding: 5px 10px; font-size: 13px; }
.goal-hint { margin-top: 8px; background: #0e1f3a; padding: 9px; border-radius: 9px; font-size: 13px; border: 1px solid #3d6194; }
.palette-title { margin: 14px 0 6px; font-weight: bold; font-size: 15px; }
.palette-sub { font-size: 12px; opacity: .6; font-weight: normal; }
.palette {
  background: rgba(10, 23, 48, .55); border: 2px dashed #3d6194; border-radius: 16px;
  padding: 12px 10px; display: flex; flex-direction: column; gap: 9px; min-height: 180px;
  transition: .15s;
}
.palette.trash { border-color: var(--red); background: rgba(239, 71, 111, .15); }
.palette.trash::after { content: "🗑️ Drop here to delete"; color: var(--red); text-align: center; font-size: 13px; font-weight: bold; }

.workspace-head { font-weight: bold; font-size: 15px; margin-bottom: 6px; }
.workspace {
  background: rgba(10, 23, 48, .55); border: 2px solid #3d6194; border-radius: 16px;
  padding: 12px; min-height: 300px; max-height: 55vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.ws-empty { opacity: .5; font-size: 15px; padding: 12px 4px; }
.run-bar { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.message {
  margin-top: 10px; min-height: 46px; border-radius: 12px; padding: 11px 14px;
  font-size: 15px; background: var(--panel); border: 2px solid #3d6194; line-height: 1.4;
}
.message.good { border-color: var(--green); background: rgba(67, 197, 158, .15); }
.message.bad { border-color: var(--red); background: rgba(239, 71, 111, .15); }

/* ===== blocks ===== */
.block {
  background: var(--blue); color: #06203c; border-radius: 10px; padding: 9px 12px;
  font-size: 15px; font-weight: bold; user-select: none; touch-action: none;
  position: relative; box-shadow: 0 3px 0 rgba(0, 0, 0, .3); cursor: grab;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.block .ico { font-size: 17px; }
.block.type-move { background: linear-gradient(180deg, #59d6b3, #37b593); }
.block.type-left, .block.type-right { background: linear-gradient(180deg, #6db6f2, #4493d4); }
.block.type-repeat { background: linear-gradient(180deg, #ffd166, #f0b43c); color: #4a3200; flex-direction: column; align-items: stretch; gap: 6px; }
.block.type-jump { background: linear-gradient(180deg, #ff9f43, #ef8722); color: #4a2500; }
.block.type-ifelse { background: linear-gradient(180deg, #b493ff, #9066f2); color: #24104d; flex-direction: column; align-items: stretch; gap: 6px; }
.block select {
  font-family: inherit; font-weight: bold; font-size: 14px; border: 2px solid rgba(0, 0, 0, .25);
  border-radius: 8px; padding: 3px 6px; background: #fff; color: #222;
}
.block .head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.body {
  min-height: 34px; border-radius: 8px; padding: 6px; display: flex; flex-direction: column;
  gap: 6px; background: rgba(0, 0, 0, .16); border: 2px dashed rgba(0, 0, 0, .3);
}
.body:empty::before { content: "put blocks here"; font-size: 11.5px; opacity: .55; font-weight: normal; }
.branch { flex: 1; min-width: 120px; }
.branch-label { font-size: 12px; font-weight: bold; margin-bottom: 3px; opacity: .85; }
.slot-row { display: flex; gap: 8px; align-items: stretch; }
.insert-line { height: 4px; background: #fff; border-radius: 3px; margin: -4px 0; box-shadow: 0 0 8px #fff; pointer-events: none; }
.block.err { outline: 3px solid var(--red); animation: shake .3s 2; }
.block.running { outline: 3px solid #fff; box-shadow: 0 0 14px rgba(255, 255, 255, .8); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.drag-ghost {
  position: fixed; z-index: 999; pointer-events: none; opacity: .92;
  transform: translate(-50%, -50%) rotate(-3deg); filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .5));
}

/* ===== stage ===== */
.stage-col { position: sticky; top: 10px; }
.stage-wrap { overflow: auto; border-radius: 18px; }
.stage {
  position: relative; background: linear-gradient(160deg, #dfefff, #b9d9f7);
  border: 5px solid #3d6194; border-radius: 18px; overflow: hidden;
  width: max-content; margin: 0 auto;
}
.tile { position: absolute; width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center; font-size: calc(var(--cell) * .55); }
.tile.wall { background: rgba(46, 92, 60, .18); }
.tile.ice { background: rgba(140, 220, 255, .55); }
.tile.goal { background: rgba(255, 209, 102, .45); }
.tile.gift { background: rgba(255, 150, 190, .3); }
.tile.start { outline: 2px dashed rgba(0, 0, 0, .25); outline-offset: -5px; }
.stage.crack { animation: shake .35s; }
.sprite {
  position: absolute; width: var(--cell); height: var(--cell); left: 0; top: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * .72); z-index: 5; transition: transform .22s ease; will-change: transform;
}
.stage-legend { text-align: center; font-size: 12.5px; opacity: .75; margin-top: 8px; }

/* ===== overlay / win ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(5, 12, 26, .82); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
}
.win-card, .parent-card {
  background: var(--panel); border: 3px solid var(--acc); border-radius: 24px;
  padding: 28px; max-width: 520px; width: 100%; text-align: center; position: relative; z-index: 2;
}
.win-emoji { font-size: 64px; animation: bounce .7s infinite alternate; }
@keyframes bounce { to { transform: translateY(-12px); } }
.win-stars { font-size: 44px; letter-spacing: 6px; margin: 10px 0; }
.win-stars .off { opacity: .22; }
.win-stats { font-size: 15px; opacity: .9; margin-bottom: 16px; }
.win-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; animation: drop linear forwards; }
@keyframes drop { to { transform: translateY(110vh) rotate(720deg); } }

/* parent modal */
.parent-card { max-width: 640px; text-align: left; border-color: var(--blue); }
.parent-card h2 { text-align: center; margin-bottom: 12px; }
.parent-card h3 { color: var(--acc); margin: 14px 0 6px; font-size: 16px; }
.parent-body { font-size: 14.5px; line-height: 1.55; max-height: 55vh; overflow-y: auto; padding-right: 6px; }
.parent-body li { margin: 5px 0 5px 20px; }
.parent-card > .big-btn { display: block; margin: 16px auto 0; }
.parent-tools { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ===== responsive ===== */
@media (max-width: 1000px) {
  .play-layout { grid-template-columns: 1fr 1fr; }
  .stage-col { grid-column: 1 / -1; order: -1; position: static; }
}
@media (max-width: 640px) {
  .play-layout { grid-template-columns: 1fr; }
  .workspace { max-height: 40vh; }
  .top-bar h2 { font-size: 18px; }
}
