@import url("design-tokens.css");

:root {
  color-scheme: light;
  font-family: ui-rounded, "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: #443b2c;
  background: #eaf0d9;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body {
  --home-sky: var(--sky-top);
  --home-upper: var(--sky-upper);
  --home-lower: var(--sky-bottom);
  --home-ground: var(--ground-a);
  --hero-ink: #443b2c;
  --hero-muted: #6d735e;
  margin: 0;
  min-height: 100vh;
  background:
    url("textures/noise.svg") repeat,
    radial-gradient(circle at 90% 5%, #ffe8a899, transparent 28%),
    linear-gradient(180deg, var(--home-sky) 0%, var(--home-upper) 38%, var(--home-lower) 83%, var(--home-ground) 100%);
  background-size: 160px 160px, auto, auto;
  background-attachment: fixed;
}
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.cloud { position: absolute; left: 0; width: 260px; aspect-ratio: 240 / 150; background: var(--cloud-image) no-repeat center / contain; opacity: 0.65; animation: cloud-drift 80s linear infinite; animation-play-state: var(--decoration-play-state, running); }
.cloud-one { top: 1%; animation-delay: -12s; }
.cloud-two { top: 2%; width: 310px; animation-duration: 110s; animation-delay: -67s; }
.cloud-three { bottom: 7%; width: 180px; opacity: 0.3; animation-duration: 95s; animation-delay: -35s; }
body:is([data-theme="space"], [data-theme="ocean"]) .cloud { aspect-ratio: 1; }
main { position: relative; width: min(1120px, 100%); margin: 0 auto; padding: 40px 28px 24px; }
.welcome { text-align: center; margin-bottom: 32px; color: var(--hero-ink); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; color: var(--hero-muted); }
.brand img { width: 30px; height: 36px; }
h1 { margin: 13px 0 10px; font-size: clamp(2rem, 4.5vw, 3.25rem); letter-spacing: -0.045em; line-height: 1.12; }
.welcome p { margin: 0; color: var(--hero-muted); font-size: 1.05rem; }
.games { display: grid; grid-template-columns: 1.12fr 1fr 1fr; gap: 18px; }
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px;
  min-width: 0;
  border: 1px solid #fff8e5;
  border-radius: 24px;
  background: #fffaf0eF;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 7px 18px #66532b10, inset 0 1px 0 #ffffff;
  transition: transform 180ms ease, box-shadow 180ms ease;
  overflow: hidden;
}
.game-card:hover { transform: translateY(-5px); box-shadow: 0 13px 25px #66532b23; }
.game-card:focus-visible { outline: 3px solid #a45b20; outline-offset: 5px; }
.category { font-size: 0.68rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; color: #7e785f; }
h2 { margin: 0 0 7px; font-size: 1.23rem; line-height: 1.25; letter-spacing: -0.025em; }
.card-copy p { margin: 0; color: #7c765f; font-size: 0.87rem; line-height: 1.6; }
.card-arrow { position: absolute; right: 18px; bottom: 20px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #e8ddba80; color: #827244; font-size: 1.1rem; }
.card-copy { padding-right: 16px; }
.piece-scene { position: relative; height: 126px; margin: 12px 0 15px; }
.piece-scene::before { content: ""; position: absolute; left: 8%; right: 8%; bottom: 0; height: 55px; border-radius: 50%; background: radial-gradient(ellipse, var(--scene-color, #cbd8ac) 0%, transparent 70%); opacity: 0.55; }
.piece-main { position: absolute; left: 12%; bottom: 0; width: 100px; height: 122px; object-fit: contain; transform: rotate(-7deg); }
.piece-opponent { position: absolute; right: 10%; bottom: 3px; width: 68px; height: 86px; object-fit: contain; transform: rotate(8deg); }
.piece-partner { position: absolute; left: 36%; bottom: 5px; width: 78px; height: 100px; object-fit: contain; transform: rotate(4deg); }
.piece-scene--pair .piece-main { left: 2%; width: 88px; }
.piece-scene--pair .piece-opponent { right: 0; width: 60px; }
.game-card--queen { --scene-color: #ecd28d; background: #fff6e4ef; }
.game-card--two-rooks { --scene-color: #a9ced5; background: #f3f9f0ef; }
.game-card--puzzle { --scene-color: #c4b6df; background: #f7f0ffef; }
.game-card--puzzle .piece-main { width: 120px; left: 4%; }
.game-card--puzzle .piece-opponent { width: 85px; }
.mate-scene { --t: 54px; }
.mate-board { position: absolute; left: 50%; bottom: 6px; width: calc(var(--t) * 4); height: calc(var(--t) * 2); transform: translateX(-50%); border-radius: 12px; box-shadow: 0 6px 12px #4f3f7a26, 0 0 0 3px #fffaf0; background: conic-gradient(#e6dcf5 25%, #bba9dd 0 50%, #e6dcf5 0 75%, #bba9dd 0) 0 0 / calc(var(--t) * 2) calc(var(--t) * 2); }
.mate-board::after { content: ""; position: absolute; right: 0; top: 0; width: var(--t); height: var(--t); border-radius: 0 12px 0 0; background: #e9908a99; }
.mate-jump { position: absolute; left: 50%; bottom: 6px; width: calc(var(--t) * 4); height: calc(var(--t) * 2); transform: translateX(-50%); overflow: visible; }
.mate-jump path { fill: none; stroke: #8a6fc4; stroke-width: 0.07; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 0.01 0.16; }
.mate-knight, .mate-king { position: absolute; left: 50%; width: calc(var(--t) * 1.25); height: calc(var(--t) * 1.25); object-fit: contain; }
.mate-knight { bottom: calc(6px + var(--t) * 0.08); margin-left: calc(var(--t) * -1.625); }
.mate-king { bottom: calc(6px + var(--t) * 1.08); margin-left: calc(var(--t) * 0.875); }
.mate-badge { position: absolute; left: 50%; bottom: calc(6px + var(--t) * 1.95); margin-left: calc(var(--t) * 1.5); display: grid; place-items: center; width: calc(var(--t) * 0.7); height: calc(var(--t) * 0.7); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe08a, #e2a73b); box-shadow: 0 2px 5px #66532b30; color: #6b4a14; font-size: calc(var(--t) * 0.48); font-weight: 800; line-height: 1; }
.game-card--sweets { grid-row: span 2; padding: 26px; background: linear-gradient(155deg, #fff3cc, #f5e6b6 65%, #e1dfa6); }
.game-card--sweets .category { color: #947130; }
.game-card--sweets .card-copy { margin-top: auto; padding: 0; }
.game-card--sweets h2 { font-size: 2rem; }
.game-card--sweets .card-copy p { font-size: 0.98rem; color: #7c6945; }
.sweet-scene { position: relative; height: 260px; margin: 20px -12px 15px; }
.mini-board { position: absolute; width: 220px; height: 190px; left: 50%; top: 55px; transform: translateX(-50%) rotate(-12deg); border: 7px solid #a0ad73; border-radius: 20px; background: repeating-conic-gradient(#f5eccb 0% 25%, #afc587 0% 50%) 50% / 80px 80px; box-shadow: 0 12px 0 #879759, 0 22px 25px #7c6e3a30; }
.sweet-rook { position: absolute; width: 112px; height: 145px; top: 20px; left: 12%; transform: rotate(-10deg); filter: drop-shadow(0 7px 3px #443b2c25); }
.sweet-candy { position: absolute; width: 65px; height: 65px; right: 3%; top: 3px; transform: rotate(20deg); }
.sweet-donut { position: absolute; width: 52px; height: 52px; left: 4%; bottom: 9px; transform: rotate(-16deg); }
.sweet-monster { position: absolute; width: 86px; height: 95px; right: 5%; bottom: 19px; transform: rotate(10deg); }
.sparkle { position: absolute; color: #b98426; }
.sparkle-one { font-size: 28px; left: 42%; top: 0; }
.sparkle-two { font-size: 22px; right: -2%; top: 94px; }
.play-link { margin-top: 22px; display: inline-flex; align-items: center; gap: 22px; padding: 12px 18px; border-radius: 999px; border: 1px solid #ac6627; background: linear-gradient(#dc9a4c, #c9762f); color: #fffaf0; font-weight: 700; font-size: 0.9rem; box-shadow: 0 4px 8px #a4662420; }
.play-link span { font-size: 1.2rem; }
footer a { color: inherit; text-decoration: underline; }
footer { margin-top: 25px; text-align: center; font-size: 0.8rem; color: var(--hero-muted); }
body[data-theme="space"] {
  --hero-ink: #fffaf0; --hero-muted: #e3e8f5;
}


@keyframes cloud-drift {
  from { transform: translateX(-320px); }
  to { transform: translateX(100vw); }
}
@media (max-width: 1024px) {
  main { padding: 28px 20px 24px; }
  .games { grid-template-columns: 1fr 1fr; }
  .game-card--sweets { grid-column: span 2; grid-row: auto; min-height: 230px; }
  .sweet-scene { position: absolute; width: 260px; right: 20px; top: 0; margin: 0; height: 210px; }
  .mini-board { top: 20px; height: 155px; width: 185px; }
  .sweet-rook { width: 94px; height: 114px; top: 5px; }
  .sweet-candy { width: 48px; height: 48px; }
  .sweet-monster { width: 70px; height: 80px; }
  .sweet-donut { bottom: 0; }
  .game-card--sweets .card-copy { max-width: 50%; margin-top: 24px; }
}
@media (max-width: 600px) {
  main { padding: 24px 16px; }
  .welcome { margin-bottom: 24px; }
  .welcome p { font-size: 0.92rem; }
  .games { gap: 12px; }
  .game-card { padding: 16px; border-radius: 20px; }
  .game-card--sweets { padding: 20px; min-height: 230px; }
  .sweet-scene { width: 175px; right: 0; top: 20px; }
  .mini-board { width: 140px; height: 135px; }
  .sweet-rook { left: 7%; width: 80px; }
  .sweet-monster { right: 4%; width: 60px; }
  .sweet-candy { right: 0; width: 40px; }
  .sweet-donut { left: 0; width: 38px; }
  .game-card--sweets h2 { font-size: 1.6rem; }
  .game-card--sweets .card-copy p { font-size: 0.85rem; }
  .game-card--sweets .category { max-width: 50%; }
  .piece-scene { height: 100px; margin: 8px -8px 12px; }
  .piece-main { width: 76px; height: 100px; left: 0; }
  .piece-opponent { right: 0; width: 50px; height: 70px; }
  .piece-partner { left: 27%; width: 64px; height: 84px; }
  .piece-scene--pair .piece-main { width: 66px; left: -4%; }
  .piece-scene--pair .piece-opponent { width: 43px; right: -4%; }
  .game-card--puzzle .piece-main { width: 88px; left: -7%; }
  .game-card--puzzle .piece-opponent { width: 62px; right: -5%; }
        .mate-scene { --t: 30px; }
  .category { font-size: 0.59rem; letter-spacing: 0.04em; }
  h2 { font-size: 1rem; }
  .card-copy p { font-size: 0.76rem; line-height: 1.45; }
  .card-copy { padding: 0 0 28px; }
  .card-arrow { width: 23px; height: 23px; right: 13px; bottom: 13px; font-size: 0.95rem; }
  .play-link { gap: 12px; padding: 10px 14px; font-size: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .cloud { animation: none; will-change: auto; }
  .cloud-one { left: -60px; }
  .cloud-two { left: auto; right: -25px; }
  .cloud-three { left: 3%; }
  .game-card { transition: none; }
  .game-card:hover { transform: none; }
}

.install-app { margin-top: 1rem; min-height: 44px; padding: .65rem 1.1rem; border: 1px solid #d5b987; border-radius: 999px; background: #fffaf0; color: #8a5424; font: inherit; cursor: pointer; }

.game-card--pawn { --scene-color: #e8c477; background: #fff6dfef; }
.game-card--creator { background: linear-gradient(145deg, #eef5ee, #fcf7e9); }
.lesson-scene { position: relative; height: 126px; margin: 12px 0 15px; }
.lesson-board { position: absolute; left: 3%; top: 12px; width: 65%; height: 100px; border: 5px solid #789184; border-radius: 10px; transform: rotate(-8deg); background: repeating-conic-gradient(#f9f0d7 0% 25%, #b7cdb6 0% 50%) 0 0 / 50% 50%; box-shadow: 0 5px 0 #5d756b, 0 10px 16px #49615320; }
.lesson-piece { position: absolute; width: 46px; height: 56px; left: 8%; bottom: 4px; z-index: 2; filter: drop-shadow(0 3px 2px #394f4033); }
.lesson-target, .lesson-sweet { position: absolute; width: 28px; height: 28px; object-fit: contain; z-index: 2; }
.lesson-target { top: 8px; right: 10%; }
.lesson-sweet { top: 8px; left: 12%; }
.lesson-route { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: #bc7628; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 5 5; }
.lesson-note { position: absolute; right: 0; top: 19px; width: 42%; box-sizing: border-box; padding: 10px 8px 8px; border: 1px solid #e1d6b8; border-radius: 7px; background: #fffdf4; box-shadow: 0 5px 12px #66532b18; transform: rotate(8deg); font-size: 10px; line-height: 1.6; color: #5b614f; }
.lesson-note-title { display: block; font-weight: 700; padding-bottom: 4px; margin-bottom: 4px; border-bottom: 1px solid #e7deca; }
.lesson-note-row { display: block; white-space: nowrap; }
.lesson-note-row > img { width: 1.3em; height: 1.3em; margin-right: 3px; vertical-align: -0.3em; }
.lesson-note-check { position: absolute; right: 8px; top: -13px; width: 24px; height: 24px; border-radius: 50%; background: #789184; color: white; font: 700 16px/24px system-ui; text-align: center; }
.lesson-pencil { position: absolute; right: 8%; bottom: -4px; width: 34px; height: 34px; transform: rotate(-18deg); }
@media (max-width: 600px) {
  .lesson-scene { height: 106px; margin: 8px -5px 12px; }
  .lesson-board { height: 82px; border-width: 4px; }
  .lesson-piece { width: 37px; height: 45px; }
  .lesson-target, .lesson-sweet { width: 23px; height: 23px; }
  .lesson-note { top: 15px; padding: 7px 5px; font-size: 8px; }
  .lesson-pencil { font-size: 25px; }
}
.game-card--king-journey { --scene-color: #a9c7a5; background: #edf6e5ef; }

/* Journey cards use the same target artwork as their games. */
.journey-goal { position: absolute; right: 4%; bottom: 0; width: 116px; height: 126px; }
.journey-goal > img { display: block; width: 100%; height: 100%; object-fit: contain; }
.journey-goal--home { width: 128px; }
.journey-magic { position: absolute; inset: 0; pointer-events: none; }
.journey-sparkle { --sparkle-color: #ffda4b; --sparkle-drift: -8px; position: absolute; left: 26%; top: 18%; width: 9px; height: 9px; background: var(--sparkle-color); clip-path: polygon(50% 0, 62% 34%, 98% 38%, 71% 61%, 80% 97%, 50% 78%, 20% 97%, 29% 61%, 2% 38%, 38% 34%); opacity: 0; animation: journey-fairy-rise 3s ease-in-out infinite; animation-play-state: var(--decoration-play-state, running); }
.journey-sparkle:nth-child(2) { left: 58%; top: 22%; --sparkle-color: #ff8cce; --sparkle-drift: 9px; animation-delay: -.5s; }
.journey-sparkle:nth-child(3) { left: 42%; top: 8%; --sparkle-color: #84e9ff; --sparkle-drift: -4px; animation-delay: -1s; }
.journey-sparkle:nth-child(4) { left: 72%; top: 28%; --sparkle-color: #c2a0ff; --sparkle-drift: 6px; animation-delay: -1.5s; }
.journey-sparkle:nth-child(5) { left: 16%; top: 30%; --sparkle-color: #a4ef8a; --sparkle-drift: -6px; animation-delay: -2s; }
.journey-sparkle:nth-child(6) { left: 50%; top: 19%; --sparkle-color: #fff1a0; --sparkle-drift: 5px; animation-delay: -2.5s; }
@keyframes journey-fairy-rise {
  0% { opacity: 0; transform: translate(0, 5px) scale(.35) rotate(-15deg); }
  20% { opacity: 1; }
  45% { opacity: .55; }
  60% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--sparkle-drift), -24px) scale(.85) rotate(65deg); }
}
@media (max-width: 600px) {
  .journey-goal { width: 88px; height: 100px; right: 0; }
  .journey-goal--home { width: 96px; }
  .journey-sparkle { width: 7px; height: 7px; }
}
@media (prefers-reduced-motion: reduce) { .journey-sparkle { animation: none; opacity: .8; } }
.game-card--capture { --scene-color: #e9b9a7; background: #fff0ebef; }

.study-notebook { position: absolute; left: 12%; bottom: 0; width: 156px; max-width: 75%; height: 126px; object-fit: contain; transform: rotate(-8deg); filter: drop-shadow(0 5px 4px #66532b18); }
.study-rook { position: absolute; right: 3%; bottom: -2px; width: 78px; height: 96px; object-fit: contain; transform: rotate(8deg); }
@media (max-width: 600px) {
  .study-notebook { left: 3%; width: 124px; height: 100px; }
  .study-rook { right: -3%; width: 58px; height: 74px; }
}

.game-card--blog { --scene-color: #e3b9a0; background: linear-gradient(145deg, #fff1e6ef, #fdf6e6ef); }
.blog-page { position: absolute; left: 24%; top: 4px; width: 52%; height: 112px; box-sizing: border-box; padding: 14px 12px; display: grid; align-content: start; gap: 8px; border: 1px solid #e6d5bd; border-radius: 7px; background: #fffdf6; box-shadow: 0 5px 12px #66532b1f; transform: rotate(5deg); }
.blog-page span { height: 6px; border-radius: 3px; background: #e6dcc6; }
.blog-page .blog-title { height: 9px; width: 60%; background: #c98f66; }
.blog-page .blog-short { width: 45%; }
.blog-bishop { position: absolute; left: 6%; bottom: 0; width: 74px; height: 96px; object-fit: contain; transform: rotate(-7deg); }
.blog-pencil { position: absolute; right: 8%; bottom: -4px; width: 34px; height: 34px; transform: rotate(-18deg); }
@media (max-width: 600px) {
  .blog-page { height: 92px; padding: 11px 9px; }
  .blog-bishop { width: 58px; height: 76px; }
}

/* Corner button shown while the tab's fullscreen mode is on; fullscreen-mode.js handles the press. */
.fullscreen-exit {
  position: fixed; z-index: 10;
  top: calc(env(safe-area-inset-top, 0px) + .75rem); right: calc(env(safe-area-inset-right, 0px) + .75rem);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: 0 1rem; border: 1px solid var(--panel-border, #0003); border-radius: 999px;
  background: var(--panel-bg, #fff); color: inherit; font-family: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.fullscreen-exit[hidden] { display: none; }
.fullscreen-exit svg { width: 22px; height: 22px; flex: none; }
.fullscreen-exit:focus-visible { outline: 3px solid var(--accent-dark, #4b6b2c); outline-offset: 3px; }
@media (max-width: 600px) { .fullscreen-exit span { display: none; } .fullscreen-exit { width: 46px; padding: 0; } }
