/* Shritha's Chess Adventure — playful, premium, kid-first design. */
:root {
  --ink: #33304e;
  --paper: #fff9f0;
  --sky1: #aee3ff;
  --sky2: #e8f9ff;
  --accent: #ff8fab;
  --gold: #ffb340;
  --btn: #6c5ce7;
  --btn-ink: #fff;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(60, 50, 120, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Baloo 2", "Comic Sans MS", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--sky1), var(--sky2) 340px, #fdf6ec);
  color: var(--ink);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(60,50,120,.12);
}
.app-title { font-weight: 800; font-size: clamp(16px, 2.6vw, 22px); letter-spacing: .3px; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.star-pill { background: #fff3d6; border: 2px solid var(--gold); border-radius: 999px; padding: 4px 12px; font-weight: 800; }
.app-footer { text-align: center; padding: 18px; color: #8a86a3; font-size: 13px; }
.view { max-width: 1080px; margin: 0 auto; padding: 14px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border: none; border-radius: 999px; padding: 10px 18px;
  background: var(--btn); color: var(--btn-ink);
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.btn-small { padding: 7px 13px; font-size: 14px; }
.btn-big { padding: 14px 26px; font-size: 18px; background: #00b894; }
.btn-ghost { background: #fff; color: var(--ink); border: 2px solid #d9d4f5; box-shadow: none; }
.btn-help { background: var(--gold); color: #5b4300; }
.btn-danger { background: #e74c3c; }
.btn-next { background: #00b894; }
.btn-choice { background: #fff; color: var(--ink); border: 2.5px solid var(--btn); box-shadow: 0 4px 0 rgba(108,92,231,.25); }
.hidden { display: none !important; }

/* ---------- home / castle ---------- */
.castle-scene {
  position: relative; overflow: hidden;
  border-radius: 24px; box-shadow: var(--shadow);
  background: linear-gradient(180deg, #8fd8ff, #d9f4ff);
  min-height: 200px;
}
.castle-svg { display: block; width: 100%; height: auto; }
.cloud { position: absolute; width: 110px; height: 34px; background: #fff; border-radius: 999px; opacity: .95; animation: drift 26s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 44px; height: 44px; top: -20px; left: 16px; }
.cloud::after { width: 30px; height: 30px; top: -12px; left: 56px; }
.cloud.c1 { top: 26px; left: -120px; }
.cloud.c2 { top: 64px; left: -120px; animation-duration: 38s; animation-delay: -14s; transform: scale(.7); }
.cloud.c3 { top: 12px; left: -120px; animation-duration: 48s; animation-delay: -30s; transform: scale(1.25); }
@keyframes drift { to { transform: translateX(calc(100vw + 320px)); } }
.flag { transform-origin: left center; animation: wave 2.2s ease-in-out infinite; }
.flag.f2 { animation-delay: .4s; } .flag.f3 { animation-delay: .8s; }
@keyframes wave { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(4deg); } }

.castle-paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; margin-top: 14px; }
.path-card {
  font: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  background: #fff; border: 3px solid #efeaff; border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s;
}
.path-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.path-card.continue { background: linear-gradient(135deg, #ffe9a8, #ffd3e0); border-color: var(--gold); }
.path-card.quest { background: linear-gradient(135deg, #d8f7e8, #cfe9ff); border-color: #4ecdc4; }
.path-card.daily { background: linear-gradient(135deg, #fff3d6, #ffe0ec); border-color: #ffb340; }
.daily-streak { align-self: flex-start; margin-top: 6px; background: #ff8c42; color: #fff; font-weight: 800; font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.path-emoji { font-size: 30px; }
.path-name { font-weight: 800; font-size: 17px; }
.path-sub { color: #77728f; font-size: 13px; font-weight: 600; }
.quest-tip { text-align: center; font-weight: 700; color: #5b5486; margin: 16px 6px 4px; }

/* ---------- hubs (learn/academy/puzzles/bots/trophy/parent) ---------- */
.hub { background: rgba(255,255,255,.75); border-radius: 24px; padding: 16px; box-shadow: var(--shadow); }
.hub-sub { font-weight: 600; color: #6b6690; }
.world-title { margin: 20px 0 10px; font-size: 19px; }
.lesson-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lesson-title { font-weight: 800; font-size: clamp(17px, 3vw, 22px); text-align: center; flex: 1; }
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-card {
  font: inherit; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 2.5px solid #efeaff; border-radius: 16px;
  padding: 13px 16px; box-shadow: 0 4px 14px rgba(60,50,120,.08);
  transition: transform .1s, border-color .1s;
}
.lesson-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.lesson-card.done { border-color: #8fe3b0; background: #f2fff6; }
.lesson-check { font-size: 22px; }
.lesson-name { font-weight: 800; flex: 1; }
.lesson-state { color: #8a86a3; font-weight: 700; font-size: 13px; }
.locked-worlds { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.locked-world {
  background: #f4f1ff; border: 2.5px dashed #cfc8ee; border-radius: 16px; padding: 14px;
  display: flex; flex-direction: column; gap: 4px; color: #7a76a0;
}
.piece-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.piece-card { background: #fff; border: 3px solid var(--pc, #ddd); border-radius: 20px; padding: 14px; text-align: center; box-shadow: var(--shadow); }
.piece-art { width: 110px; height: 110px; margin: 0 auto; }
.piece-name { font-weight: 800; font-size: 18px; margin: 6px 0 10px; }
.level-row { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.level-chip {
  font: inherit; font-weight: 700; font-size: 13.5px; cursor: pointer;
  border: 2px solid #e6e1ff; background: #faf8ff; border-radius: 999px; padding: 7px 12px;
}
.level-chip.done { background: #e8fff0; border-color: #8fe3b0; }
.level-chip:hover { border-color: var(--gold); }
.bot-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.bot-card {
  font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #fff; border: 3px solid #efeaff; border-radius: 20px; padding: 18px; box-shadow: var(--shadow);
}
.bot-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.bot-emoji { font-size: 52px; }
.bot-name { font-weight: 800; font-size: 18px; }
.bot-sub { color: #77728f; font-weight: 600; font-size: 13px; text-align: center; }

/* Academy graduation banner: appears once every Piece Academy lesson is done. */
.graduate-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(135deg, #fff6d9, #ffe9a8);
  border: 3px solid var(--gold); border-radius: 20px;
  padding: 14px 18px; margin: 12px 0 4px; box-shadow: var(--shadow);
}
.graduate-emoji { font-size: 40px; }
.graduate-text { flex: 1 1 220px; display: flex; flex-direction: column; gap: 2px; }
.graduate-text b { font-size: 18px; }
.graduate-text span { color: #6b6690; font-weight: 600; font-size: 14px; }

/* ---------- characters ---------- */
.char-svg { width: 100%; height: 100%; display: block; }
.char-anim { animation: bob 3s ease-in-out infinite; transform-origin: 50% 90%; }
.char-anim.mood-celebrate { animation: celebrate .7s ease-in-out 3; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-6px) rotate(1.2deg); } }
@keyframes celebrate { 0% { transform: translateY(0) scale(1); } 35% { transform: translateY(-16px) scale(1.06) rotate(-3deg); } 70% { transform: translateY(0) scale(1.02) rotate(3deg); } 100% { transform: translateY(0); } }

/* ---------- lesson / game layout ---------- */
.lesson { max-width: 880px; margin: 0 auto; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 6px; }
.char-stage { display: flex; align-items: flex-end; gap: 10px; width: 100%; max-width: 640px; }
.char-stage .char-anim { width: 92px; height: 92px; flex: 0 0 auto; }
.bubble {
  position: relative; flex: 1;
  background: #fff; border: 3px solid #ffe1ec; border-radius: 18px;
  padding: 12px 14px; font-weight: 700; font-size: clamp(15px, 2.4vw, 18px);
  box-shadow: var(--shadow); min-height: 58px;
}
.bubble::before {
  content: ""; position: absolute; left: -12px; bottom: 18px;
  border: 7px solid transparent; border-right-color: #ffe1ec; border-left: 0;
}
.bubble p { margin: 0; }
.caption-bar {
  max-width: 640px; margin: 2px auto 0; text-align: center;
  font-weight: 700; color: #5b5486; min-height: 22px; font-size: 15px;
  opacity: 0; transition: opacity .3s;
}
.caption-bar.show { opacity: 1; }
.lesson-controls, .game-controls { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.btn-video { background: #e84393; color: #fff; }
.video-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(30, 25, 70, .82); display: flex; align-items: center; justify-content: center; padding: 16px; }
.video-box { background: var(--paper); border: 3px solid var(--gold); border-radius: 22px; padding: 14px; box-shadow: var(--shadow); max-width: 860px; width: 100%; text-align: center; }
.video-box video { width: 100%; max-height: 70vh; border-radius: 14px; background: #000; }
.video-box .btn { margin-top: 12px; }
.step-dots { display: flex; gap: 5px; }
.sdot { width: 11px; height: 11px; border-radius: 50%; background: #ddd8f5; display: inline-block; }
.sdot.done { background: #00b894; }
.sdot.now { background: var(--gold); transform: scale(1.3); }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.moves-label { font-weight: 800; color: #5b5486; }

.celebrate { text-align: center; background: #fff; border: 3px solid var(--gold); border-radius: 22px; padding: 22px; margin-top: 14px; box-shadow: var(--shadow); }
.celebrate-stars { font-size: 44px; animation: celebrate .8s ease-in-out 2; }
.celebrate p { font-weight: 800; font-size: 19px; }

.warning {
  display: flex; gap: 12px; align-items: center;
  background: #fff8e6; border: 3px solid var(--gold); border-radius: 18px;
  padding: 12px 14px; margin-top: 12px; box-shadow: var(--shadow);
}
.warning-char { width: 64px; height: 64px; flex: 0 0 auto; }
.warning p { font-weight: 800; margin: 0; flex: 1; }
.warning-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.promote {
  background: #fff; border: 3px solid var(--accent); border-radius: 18px;
  padding: 14px; margin-top: 12px; text-align: center; box-shadow: var(--shadow);
}
.promote p { font-weight: 800; margin: 0 0 10px; }
.promote-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn-piece { display: flex; flex-direction: column; align-items: center; font-size: 30px; padding: 10px 16px; background: #fff; color: var(--ink); border: 2.5px solid var(--accent); box-shadow: none; }
.btn-piece span { font-size: 12.5px; font-weight: 800; }

/* ---------- game review (CHS-REQ-000066) ---------- */
.review {
  background: #fff; border: 3px solid #4ecdc4; border-radius: 18px;
  padding: 14px; margin-top: 12px; box-shadow: var(--shadow);
}
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 800; font-size: 17px; }
.review-intro { font-weight: 700; color: #5b5486; margin: 8px 0 12px; }
.review-moments { display: flex; flex-direction: column; gap: 12px; }
.review-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: #faf8ff; border: 2.5px solid #efeaff; border-radius: 16px; padding: 10px;
}
.review-card .board-wrap { width: min(38vw, 180px); margin: 0; flex: 0 0 auto; }
.review-text { flex: 1; }
.review-text h4 { margin: 2px 0 4px; font-size: 16.5px; }
.review-text p { margin: 0 0 6px; font-weight: 600; }
.review-text .review-move { font-weight: 800; color: #8a86a3; font-size: 12.5px; margin-bottom: 2px; }
@media (max-width: 560px) {
  .review-card { flex-direction: column; align-items: center; }
  .review-card .board-wrap { width: min(70vw, 220px); }
  .review-text { text-align: center; }
}

/* ---------- board ---------- */
.board-wrap { width: min(92vw, 62vh, 560px); margin: 6px auto; }
.board {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 16px; overflow: hidden;
  border: 6px solid #8a5a2b;
  box-shadow: var(--shadow), inset 0 0 0 3px #ffd9a0;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  background: #f6ead2;
  touch-action: manipulation; user-select: none;
}
.sq { position: relative; display: flex; align-items: flex-start; justify-content: flex-start; }
.sq.light { background: #f7ecd4; }
.sq.dark { background: #86bb8a; }
.sq.selected { box-shadow: inset 0 0 0 4px var(--gold); }
.coord { font-size: clamp(8px, 1.6vw, 11px); font-weight: 800; opacity: .65; padding: 2px; pointer-events: none; }
.coord.file { position: absolute; bottom: 1px; right: 3px; top: auto; }
.coord.rank { position: absolute; top: 1px; left: 3px; }
.dot {
  position: absolute; inset: 0; margin: auto; width: 30%; height: 30%;
  background: rgba(20, 140, 60, .55); border-radius: 50%; pointer-events: none;
  animation: pulse-dot 1.1s ease-in-out infinite;
}
.capture-ring {
  position: absolute; inset: 4%; border: 5px solid rgba(255, 122, 26, .9); border-radius: 50%;
  pointer-events: none; animation: pulse-dot 1.1s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.12); opacity: 1; } }
.hl-pulse { box-shadow: inset 0 0 0 4px var(--gold); animation: sq-pulse 1s ease-in-out infinite; }
.hl-glow { box-shadow: inset 0 0 0 3px rgba(255, 179, 64, .8), inset 0 0 18px rgba(255, 179, 64, .65); }
.hl-danger { box-shadow: inset 0 0 0 4px #e74c3c, inset 0 0 18px rgba(231, 76, 60, .55); animation: sq-pulse .8s ease-in-out infinite; }
.hl-celebrate { animation: sq-celebrate .9s ease; }
@keyframes sq-pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
@keyframes sq-celebrate { 0% { box-shadow: inset 0 0 0 3px #ffd700; } 50% { box-shadow: inset 0 0 26px 8px rgba(255, 215, 0, .8); } 100% { box-shadow: none; } }
.arrow-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.guide-arrow { opacity: .95; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); animation: arrow-in .3s ease; }
@keyframes arrow-in { from { opacity: 0; } to { opacity: .95; } }
.marker-layer, .piece-layer { position: absolute; inset: 0; pointer-events: none; }
.marker-layer { z-index: 2; }
.piece-layer { z-index: 4; }
.marker {
  position: absolute; width: 12.5%; height: 12.5%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(18px, 4.6vw, 32px);
  animation: bob 2.4s ease-in-out infinite;
}
.piece {
  position: absolute; width: 12.5%; height: 12.5%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(26px, 6.4vw, 46px); line-height: 1;
  cursor: pointer; pointer-events: auto;
  transition: left .35s ease, top .35s ease;
  text-shadow: 0 2px 3px rgba(0,0,0,.25);
  border-radius: 50%;
}
.piece.white { color: #fffdf5; background: radial-gradient(circle at 35% 30%, #fffef8, #ffe9bd); border: 2.5px solid var(--accent, #c9a86a); color: #4a3b1e; }
.piece.black { background: radial-gradient(circle at 35% 30%, #5a6070, #2e323d); border: 2.5px solid #16181f; color: #f2ead8; }
.piece.sliding { transition: left .35s ease, top .35s ease; }
.piece.hopping { animation: hop .5s ease; }
@keyframes hop { 0% { transform: scale(1) translateY(0); } 45% { transform: scale(1.22) translateY(-14%); } 100% { transform: scale(1) translateY(0); } }
.piece.ghost { opacity: .55; pointer-events: none; filter: saturate(1.4); }
.piece.ghost-out { opacity: 0; transition: opacity .3s; }
.piece.captured-pop { animation: pop-out .3s forwards; }
@keyframes pop-out { to { transform: scale(1.5) rotate(18deg); opacity: 0; } }

/* ---------- trophy / parent ---------- */
.trophy-stars { font-size: 30px; font-weight: 800; text-align: center; margin: 8px 0; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.badge { background: #fff; border: 2.5px solid #efeaff; border-radius: 16px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.badge.earned { border-color: var(--gold); background: #fffaf0; }
.badge-emoji { font-size: 30px; }
.badge-name { font-weight: 800; font-size: 14.5px; }
.badge-hint { color: #8a86a3; font-size: 12px; font-weight: 600; }
.room-list { display: flex; flex-direction: column; gap: 9px; }
.room { display: flex; gap: 12px; align-items: center; background: #fff; border: 2.5px solid #efeaff; border-radius: 16px; padding: 12px 16px; }
.room.open { border-color: #8fe3b0; background: #f2fff6; }
.room span { font-size: 26px; }
.room small { display: block; color: #8a86a3; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
/* Parent Progress Report per-world bars (CHS-REQ-000065) — existing palette. */
.report-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.report-bar-row { display: flex; align-items: center; gap: 10px; }
.report-bar-name { font-weight: 800; font-size: 13.5px; min-width: 180px; }
.report-bar-track { flex: 1; height: 14px; background: #efeaff; border-radius: 999px; overflow: hidden; }
.report-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #4ecdc4, var(--btn)); border-radius: 999px; }
.report-bar-count { font-weight: 700; color: #8a86a3; font-size: 13px; min-width: 52px; text-align: right; }
@media (max-width: 560px) { .report-bar-name { min-width: 118px; font-size: 12.5px; } }
.stat { background: #fff; border: 2.5px solid #efeaff; border-radius: 16px; padding: 12px; text-align: center; }
.stat b { font-size: 22px; display: block; }
.stat span { color: #8a86a3; font-weight: 700; font-size: 12.5px; }
.control-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.control-row label { font-weight: 800; min-width: 170px; }
.gate-row { display: flex; gap: 10px; align-items: center; }
.gate-input { font: inherit; font-weight: 700; padding: 10px 14px; border: 2.5px solid #d9d4f5; border-radius: 12px; width: 140px; }
.gate-msg { font-weight: 800; color: #b3541e; min-height: 20px; }
.file-label { display: inline-flex; cursor: pointer; }

/* ---------- responsive + motion ---------- */
@media (max-width: 560px) {
  .char-stage .char-anim { width: 68px; height: 68px; }
  .board-wrap { width: min(94vw, 94vw); }
  .header-home { display: none; }
  .app-title { font-size: 15px; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
