/* The web game. Tokens come from /assets/style.css; this file only lays out the game screens. */
:root {
  --light-square: #fff3d6;
  --dark-square: #7cc9a7;
  --red: #ff4d5e;
}

body.play {
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--sky), var(--lavender)) fixed;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
[hidden] { display: none !important; }
svg { display: block; }

/* Chunky buttons that sink when pressed, like the app's BouncyButtonStyle. */
.btn {
  --c: var(--blue);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 22px; padding: 0 18px; min-height: 52px;
  background: var(--c); color: #fff; font: 800 17px/1.1 var(--round); text-decoration: none; cursor: pointer;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c), black 35%);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
}
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c), black 35%); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; }
.btn > svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.btn > svg .fill { fill: currentColor; stroke: none; }
.btn.orange { --c: var(--orange); }
.btn.green { --c: var(--green); }
.btn.pink { --c: var(--pink); }
.btn.yellow { --c: var(--yellow); color: var(--ink); }
.btn.purple { --c: var(--purple); }
.btn.blue { --c: var(--blue); }
.btn.ink { --c: var(--ink); }
#sound[aria-pressed="true"] .off, #sound[aria-pressed="false"] .on { display: none; }
.btn.icon { width: 56px; min-height: 50px; padding: 0; border-radius: 18px; }

/* Menu */
.menu { display: flex; flex-direction: column; min-height: 100dvh; max-width: 560px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.menu-top { display: flex; height: 60px; align-items: center; }
.menu-body { flex: 1; min-height: calc(100dvh - 120px); display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 12px 0 28px; }
.menu h1 { font-size: clamp(34px, 9vw, 48px); }
.menu-lead { font-size: 18px; color: var(--ink-soft); }
.menu-choices { display: grid; gap: 16px; margin-top: 8px; }
.btn.big { justify-content: flex-start; gap: 16px; min-height: 104px; padding: 14px 20px; border-radius: 28px; text-align: left; }
.btn.big strong { display: block; font-size: 26px; font-weight: 900; }
.btn.big small { display: block; margin-top: 4px; font-size: 16px; font-weight: 700; opacity: 0.92; }
.big-art, .robot-art, .avatar { display: block; }
.big-art { flex: none; width: 76px; height: 76px; }
.big-art.pawns { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgb(255 255 255 / 0.35); }
.big-art.pawns img { width: 38px; }
.install { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center; margin-top: 10px; padding: 16px; border-radius: 24px; background: rgb(255 255 255 / 0.85); }
.install img { width: 56px; height: 56px; border-radius: 14px; }
.install strong { font-size: 18px; font-weight: 900; }
.install p { font-size: 15px; color: var(--ink-soft); line-height: 1.4; }
.install .btn { grid-column: 1 / -1; min-height: 46px; }
/* Below the first screen: what search engines and AI answers read, and what a parent
   scrolls to before handing over the phone. */
.about { display: grid; gap: 12px; margin-bottom: 28px; padding: 24px 20px; border-radius: 28px; background: rgb(255 255 255 / 0.85); user-select: text; -webkit-user-select: text; }
.about h2 { font-size: 26px; }
.about h3 { margin-top: 10px; font-size: 19px; font-weight: 900; }
.about p { font-size: 16px; line-height: 1.5; color: var(--ink-soft); }
.about .faq { gap: 8px; }
.about .faq details { padding: 14px 16px; background: rgb(255 255 255 / 0.9); }
.about .faq summary { font-size: 16px; }
.about .faq summary::after { margin-left: 10px; }
.menu-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.menu-foot a { text-decoration: none; }

/* Bars shared by the picker and the game */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bar h2 { font-size: 24px; text-align: center; }
.bar-spacer { width: 56px; }

/* Robot picker */
.picker { max-width: 560px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.picker-body { display: grid; gap: 18px; padding-top: 20px; }
.colors { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; border-radius: 24px; background: rgb(255 255 255 / 0.85); }
.colors p { grid-column: 1 / -1; font-weight: 800; font-size: 18px; }
.color-choice {
  display: flex; align-items: center; gap: 8px; padding: 10px; border: 4px solid transparent; border-radius: 18px;
  background: var(--light-square); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.color-choice[aria-checked="true"] { border-color: var(--yellow); background: #fff; box-shadow: 0 4px 12px rgb(43 45 91 / 0.15); }
.color-choice img { width: 40px; height: 40px; }
.color-choice strong { display: block; font-size: 16px; font-weight: 900; }
.color-choice small { display: block; font-size: 13px; font-weight: 700; opacity: 0.75; }
.robot-list { display: grid; gap: 16px; }
.robot-card { justify-content: flex-start; gap: 16px; min-height: 116px; padding: 14px 18px; border-radius: 28px; text-align: left; }
.robot-art { flex: none; width: 84px; height: 84px; }
.robot-text strong { display: block; font-size: 28px; font-weight: 900; }
.robot-text small { display: block; margin-top: 2px; font-size: 16px; font-weight: 700; opacity: 0.92; }
.robot-text .level { display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 999px; background: rgb(255 255 255 / 0.28); font-size: 14px; }
.robot-text .dim { opacity: 0.4; }

/* Robot avatar */
.robot { width: 100%; height: 100%; overflow: visible; }
.robot .ball { fill: var(--pink); transform-origin: 50px 0; transform-box: view-box; }
.robot.thinking .ball { fill: var(--yellow); animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.3); } }

/* Game: one column on a phone, board plus a side panel when the screen is wide */
.game {
  display: flex; flex-direction: column; gap: 10px;
  height: 100dvh; max-width: 640px; margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
}
.turn { padding: 10px 18px; border-radius: 999px; background: rgb(255 255 255 / 0.85); font-size: 19px; font-weight: 900; text-align: center; }
.board-wrap { flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }

.strip {
  display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 9px 12px; border-radius: 22px;
  background: #fff; box-shadow: 0 6px 12px rgb(43 45 91 / 0.15); outline: 5px solid transparent;
  transform: scale(0.97); transition: transform 0.3s cubic-bezier(.3, 1.6, .6, 1), outline-color 0.2s;
}
.strip.active { outline-color: var(--yellow); transform: none; }
.avatar { flex: none; width: 56px; height: 56px; }
.pawn-avatar { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; }
.pawn-avatar.white { background: var(--yellow); }
.pawn-avatar.black { background: var(--pink); }
.pawn-avatar img { width: 66%; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.name { display: flex; align-items: center; gap: 6px; font-size: 19px; font-weight: 900; }
.name img { width: 22px; height: 22px; }
.line { font-size: 15px; font-weight: 700; color: var(--ink-soft); line-height: 1.25; }
.captured { display: flex; align-items: center; min-height: 22px; }
.captured img { width: 22px; height: 22px; margin-right: -6px; }
.captured b { margin-left: 12px; font-size: 14px; font-weight: 900; color: var(--green); }

.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.controls .btn { flex-direction: column; gap: 2px; min-height: 64px; padding: 0 6px; border-radius: 20px; font-size: 15px; }

@media (min-aspect-ratio: 6/5) and (min-width: 720px) {
  .game {
    display: grid; max-width: 1200px; padding: 24px; gap: 16px 24px;
    grid-template-columns: 1fr minmax(300px, 380px);
    grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas: "board top" "board stripTop" "board ." "board stripBottom" "board controls";
  }
  .g-top { grid-area: top; }
  .g-strip-top { grid-area: stripTop; }
  .g-strip-bottom { grid-area: stripBottom; }
  .controls { grid-area: controls; }
  .board-wrap { grid-area: board; }
}

/* Board */
.board {
  --frame: min(3.5cqmin, 18px);
  position: relative; width: min(100cqw, 100cqh); aspect-ratio: 1; padding: var(--frame);
  border-radius: calc(var(--frame) * 1.6); background: var(--frame-color, #5b4bb7);
  box-shadow: 0 8px 14px rgb(43 45 91 / 0.3); cursor: pointer;
}
.layer { position: absolute; inset: var(--frame); }
.squares {
  overflow: hidden; border-radius: 2.2%;
  /* One gradient instead of 64 colored tiles: tiles leave hairline seams at most zoom levels.
     The top-left square is light whichever side is at the bottom (a8 or h1). */
  background: repeating-conic-gradient(var(--dark-square) 0 25%, var(--light-square) 0 50%) 0 0 / 25% 25%;
}
.layer > * {
  position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%;
  /* --x and --y are the column and row on screen; a percentage translate is one square per 100%. */
  transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%));
}
.layer.marks, .layer.targets, .layer.pieces { pointer-events: none; }
.sq span { position: absolute; font-size: min(2.4cqmin, 14px); font-weight: 800; line-height: 1; }
.sq.light span { color: var(--dark-square); }
.sq.dark span { color: var(--light-square); }
.sq .rank { top: 6%; left: 6%; }
.sq .file { bottom: 6%; right: 6%; }

.mark.last { background: rgb(255 201 60 / 0.45); }
.mark.selected { background: rgb(255 201 60 / 0.85); }
.mark.check { background: radial-gradient(circle, var(--red) 0%, rgb(255 77 94 / 0.8) 40%, rgb(255 77 94 / 0) 72%); }
.mark.hint { border: max(3px, 1cqmin) solid var(--blue); border-radius: 14%; animation: blink 0.6s ease-in-out infinite alternate; }
@keyframes blink { from { opacity: 0.35; } }

/* Padding in % reads the board's width, not the square's: 0.75% of the board is 6% of a square. */
.piece {
  padding: 0.75%; object-fit: contain;
  filter: drop-shadow(0 1px 1px rgb(43 45 91 / 0.2));
  transition: transform 0.35s cubic-bezier(.3, 1.3, .5, 1), opacity 0.25s;
}
.piece.lifted { z-index: 2; transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100% - 6%)) scale(1.15); filter: drop-shadow(0 6px 6px rgb(43 45 91 / 0.35)); }
.piece.gone { transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%)) scale(0.2); opacity: 0; }

.target { display: grid; place-items: center; animation: burst 0.35s cubic-bezier(.3, 1.4, .6, 1) backwards; }
.target::after { content: ""; width: 32%; height: 32%; border-radius: 50%; background: rgb(140 108 242 / 0.55); }
.target.capture::after { width: 86%; height: 86%; box-sizing: border-box; background: none; border: max(3px, 1.1cqmin) solid rgb(140 108 242 / 0.75); }
@keyframes burst { from { transform: translate(calc((var(--x) + var(--dx)) * 100%), calc((var(--y) + var(--dy)) * 100%)) scale(0.2); opacity: 0; } }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgb(0 0 0 / 0.35); animation: fade 0.25s; }
@keyframes fade { from { opacity: 0; } }
.overlay .sheet { position: relative; width: 100%; max-width: 460px; padding: 26px 24px; border-radius: 32px; background: #fff; text-align: center; box-shadow: 0 12px 24px rgb(43 45 91 / 0.2); animation: pop 0.5s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.overlay h2 { font-size: 30px; }
.promo-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 18px; }
.btn.promo { --c: var(--light-square); flex-direction: column; gap: 4px; padding: 10px 4px; color: var(--ink); font-size: 14px; text-transform: capitalize; }
.btn.promo img { width: 100%; max-width: 64px; }
.result-art { display: grid; place-items: center; height: 110px; margin-bottom: 8px; }
.result-art .robot { width: 110px; height: 110px; }
.trophy { width: 84px; fill: var(--yellow); filter: drop-shadow(0 5px 0 rgb(255 138 61 / 0.6)); }
.result-message { margin-top: 10px; font-size: 18px; font-weight: 700; color: var(--ink-soft); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.result-actions .btn { min-height: 58px; font-size: 19px; }
.result-app { margin-top: 18px; font-size: 15px; color: var(--ink-soft); }
.result-app a { font-weight: 800; color: var(--purple); }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .piece, .strip, .btn { transition: none; }
  .target, .overlay .sheet, .mark.hint, .robot.thinking .ball { animation: none; }
}
