/* Satranç Dostları (Bebek App) — the UI on top of the paper scene. Everything looks drawn on paper: ink outlines
   with slightly uneven corners, crayon-hatched colour bands, a hard pencil shadow. Landscape phones and tablets
   (Android) and also portrait phones (the web version).
   Headings: Baloo 2 (covers Turkish and Polish letters); body: Nunito (also Cyrillic); CJK: system fonts. */
@font-face { font-family: 'Baloo 2'; font-weight: 600; font-display: block; src: url(fonts/baloo-2-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Baloo 2'; font-weight: 600; font-display: block; src: url(fonts/baloo-2-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Baloo 2'; font-weight: 700; font-display: block; src: url(fonts/baloo-2-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Baloo 2'; font-weight: 700; font-display: block; src: url(fonts/baloo-2-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: block; src: url(fonts/fredoka-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF; }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: block; src: url(fonts/nunito-latin-800-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: block; src: url(fonts/nunito-latin-ext-800-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: block; src: url(fonts/nunito-cyrillic-800-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }

:root {
  --ink: #3a3150;
  --ink-2: #5a5274;
  --paper: #f7f0e1;
  --card: #fffdf6;
  --orange: #ff9a3d;
  --orange-d: #c25a10;
  --purple: #8f7ff0;
  --purple-d: #4a3cb8;
  --pink: #ff6b8f;
  --green: #45b864;
  --blue: #3ea7e8;
  --sun: #ffc83a;
  --head: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', 'Baloo 2', system-ui, sans-serif;
  --brand: 'Fredoka', 'Baloo 2', system-ui, sans-serif;
  --safe-l: max(12px, env(safe-area-inset-left));
  --safe-r: max(12px, env(safe-area-inset-right));
  --safe-t: max(10px, env(safe-area-inset-top));
  --safe-b: max(10px, env(safe-area-inset-bottom));
  --u: min(1vh, 0.62vw, 8.4px); /* stops growing past tablet scale: big desktop browsers keep tablet proportions */
  --r: 22px 26px 24px 20px / 20px 24px 26px 22px; /* hand-drawn corners */
  --shadow: 3px 4px 0 rgba(58, 49, 80, .2);
  --ml: 200px; /* paper left of the board (set by the scene) */
  --mr: 200px;
}
@media (orientation: portrait) { :root { --u: min(0.55vh, 1vw, 8.4px); } }
:lang(ja), :lang(ko) { --head: system-ui, 'Hiragino Maru Gothic ProN', 'Noto Sans JP', 'Noto Sans KR', sans-serif; --body: var(--head); }
/* Korean keeps words whole (it has spaces); Japanese has none, so it breaks between characters with the strict rules */
:lang(ko) { word-break: keep-all; }
:lang(ja) { line-break: strict; }
/* menu labels are written with spaces between phrases (like Japanese picture books) and break only there */
:lang(ja) .card .name, :lang(ja) .tile b { word-break: keep-all; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--body); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
img { -webkit-user-drag: none; user-select: none; }
svg { display: block; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; visibility: hidden; }
body.in-game #c { visibility: visible; }
.paper { background: var(--paper) url(art/paper.webp) repeat; background-size: 512px; }

.screen { position: fixed; inset: 0; display: none; }
.screen.show { display: block; }
.hud { pointer-events: none; }
.hud > * { pointer-events: auto; }

/* ------------------------------------------------------------------ shared buttons (doodles) */
.round-btn { position: relative; width: calc(var(--u) * 14); height: calc(var(--u) * 14); min-width: 52px; min-height: 52px; border-radius: 50% 47% 52% 49% / 48% 52% 47% 51%; background: var(--card); color: var(--ink); display: grid; place-items: center; border: 3px solid var(--ink); box-shadow: var(--shadow); transition: transform .12s ease; }
.round-btn:active, .card:active, .pill-btn:active, .tile:active, .friend:active, .promo-btns button:active { transform: scale(.93) rotate(-1deg); }
.round-btn > svg:not(.ring) { width: 54%; height: 54%; }
.round-btn .ring { position: absolute; inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); transform: rotate(-90deg); }
.ring circle { fill: none; stroke: var(--pink); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 126; stroke-dashoffset: 126; }
.holding .ring circle { transition: stroke-dashoffset 3s linear; stroke-dashoffset: 0; }
.round-btn.off { opacity: .35; }
.pill-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: calc(var(--u) * 1.8); height: calc(var(--u) * 14); min-height: 52px; padding: 0 calc(var(--u) * 5) 0 calc(var(--u) * 3); border-radius: 999px 980px 999px 960px; font: 700 calc(var(--u) * 5.4) / 1 var(--head); color: #fff; border: 3px solid var(--ink); box-shadow: var(--shadow); white-space: nowrap; transition: transform .12s ease; background: var(--orange); }
@media (orientation: portrait) { .pill-btn { font-size: max(17px, calc(var(--u) * 5)); } }
.pill-btn span { padding-top: .12em; overflow: hidden; text-overflow: ellipsis; }
.pill-btn svg { width: calc(var(--u) * 7); height: calc(var(--u) * 7); min-width: 24px; min-height: 24px; flex: none; }
.pill-btn img { height: 120%; margin: -10% 0; flex: none; }
.pill-btn.green { background: #3fb35e; }
.pill-btn.blue { background: #3aa0e6; }
.pill-btn.purple { background: #8a74ec; }
.pill-btn.pink { background: #ff6b8f; }
.pill-btn.album { background: #ffd23d; color: var(--ink); }
.badge { position: absolute; top: -10px; right: -6px; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px; background: var(--pink); color: #fff; border: 2.5px solid var(--ink); font: 700 16px/26px var(--head); font-style: normal; text-align: center; display: none; }
.badge.on { display: block; animation: bounce 1.4s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.mini-btn { width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 2.5px solid var(--ink); display: grid; place-items: center; flex: none; }
.mini-btn svg { width: 60%; height: 60%; }

/* ------------------------------------------------------------------ splash */
#splash { background: radial-gradient(120% 120% at 50% 40%, #fffdf9 0%, #fff4ea 60%, #ffe9e0 100%); z-index: 50; place-items: center; transition: opacity .45s ease; }
#splash.show { display: grid; }
#splash.out { opacity: 0; pointer-events: none; }
.splash-inner { position: relative; display: flex; align-items: center; gap: calc(var(--u) * 4); }
.mark { width: calc(var(--u) * 34); height: calc(var(--u) * 34); filter: drop-shadow(0 18px 26px rgba(255, 79, 123, .32)); }
.mark .tile, .mark .glyph, .mark .eyes, .mark .smile, .mark .curl, .mark .cheek { transform-box: fill-box; transform-origin: center; }
.mark .tile { animation: tileIn .75s cubic-bezier(.3, 1.6, .5, 1) both; }
.mark .glyph { animation: glyphIn .6s cubic-bezier(.3, 1.7, .5, 1) .25s both; }
.mark .eyes { animation: blink .32s ease-in-out 1.15s both; }
.mark .smile { animation: smile .5s cubic-bezier(.3, 1.8, .5, 1) 1.25s both; }
.mark .curl { animation: curl .6s ease-out .55s both; }
.mark .cheek { animation: cheek .5s ease-out 1.3s both; }
@keyframes tileIn { 0% { transform: scale(0) rotate(-25deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes glyphIn { 0% { transform: scale(.2) translateY(30%); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes blink { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.1); } }
@keyframes smile { 0% { transform: scaleX(.5); } 100% { transform: scaleX(1.12); } }
@keyframes curl { 0% { transform: rotate(-40deg) scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes cheek { 0% { opacity: 0; } 100% { opacity: .65; } }
.word { font: 600 calc(var(--u) * 17) var(--brand); letter-spacing: -0.01em; color: #1d2350; display: flex; line-height: 1; }
.word span { display: inline-block; animation: drop .6s cubic-bezier(.3, 1.6, .5, 1) both; }
/* portrait (web version on a phone held upright): logo above the wordmark */
@media (orientation: portrait) { .splash-inner { flex-direction: column; gap: 5vw; } .mark { width: min(34vw, 220px); height: min(34vw, 220px); } .word { font-size: min(14vw, 96px); } }
.word span:nth-child(1) { animation-delay: .55s; } .word span:nth-child(2) { animation-delay: .62s; } .word span:nth-child(3) { animation-delay: .69s; }
.word span:nth-child(4) { animation-delay: .76s; } .word span:nth-child(5) { animation-delay: .83s; } .word span:nth-child(6) { animation-delay: .95s; }
.word span:nth-child(7) { animation-delay: 1.02s; }
.word .dot, .word .app { background: linear-gradient(135deg, #ff9a62, #ff4f7b); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes drop { 0% { transform: translateY(-120%) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
.spark { position: absolute; color: var(--sun); animation: twinkle 1.2s ease-in-out both; }
.spark svg { width: 100%; height: 100%; }
.spark.s1 { width: calc(var(--u) * 7); height: calc(var(--u) * 7); left: -6%; top: -18%; animation-delay: 1.0s; }
.spark.s2 { width: calc(var(--u) * 5); height: calc(var(--u) * 5); right: -4%; top: -14%; animation-delay: 1.2s; color: #ff4f7b; }
.spark.s3 { width: calc(var(--u) * 4); height: calc(var(--u) * 4); left: 30%; bottom: -24%; animation-delay: 1.35s; color: #3db7f0; }
@keyframes twinkle { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 40% { transform: scale(1.2) rotate(10deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }

/* ------------------------------------------------------------------ home */
#home { overflow: hidden; }
.home-doodles { position: absolute; inset: 0; pointer-events: none; }
.home-doodles img { position: absolute; animation: floaty 4s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); } 50% { transform: translateY(-6px) rotate(calc(var(--rot, 0deg) + 2deg)); } }
.home-top { position: absolute; top: var(--safe-t); left: var(--safe-l); right: var(--safe-r); display: flex; align-items: center; justify-content: space-between; gap: 12px; z-index: 2; }
.title { margin: 0; flex: 1; min-width: 0; text-align: center; font: 700 calc(var(--u) * 12) / 1.05 var(--head); letter-spacing: .01em; white-space: nowrap; }
.title span { display: inline-block; text-shadow: 2px 3px 0 rgba(58, 49, 80, .16); -webkit-text-stroke: 1.5px rgba(58, 49, 80, .55); animation: wob 3.2s ease-in-out infinite; }
@keyframes wob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(-3deg); } }
.brand { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; background: rgba(255, 255, 255, .8); border-radius: 999px; border: 2px solid rgba(58, 49, 80, .25); font: 600 calc(var(--u) * 4) var(--brand); color: #1d2350; }
.brand svg { width: calc(var(--u) * 7); height: calc(var(--u) * 7); min-width: 26px; min-height: 26px; }
.brand b { font-weight: 600; background: linear-gradient(135deg, #ff9a62, #ff4f7b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.menu { position: absolute; left: var(--safe-l); right: var(--safe-r); top: calc(var(--safe-t) + var(--u) * 19); bottom: calc(var(--safe-b) + var(--u) * 21); display: grid; grid-template-columns: repeat(4, 1fr); gap: calc(var(--u) * 3.5); align-items: stretch; z-index: 1; padding: 0 calc(var(--u) * 2); }
.card { position: relative; border-radius: var(--r); background: var(--card); border: 3.5px solid var(--ink); box-shadow: 4px 6px 0 rgba(58, 49, 80, .22); overflow: hidden; transition: transform .14s ease; animation: cardIn .6s cubic-bezier(.3, 1.5, .5, 1) both; }
.card:nth-child(1) { transform: rotate(-1.5deg); animation-delay: .05s; } .card:nth-child(2) { transform: rotate(1deg); animation-delay: .12s; }
.card:nth-child(3) { transform: rotate(-.8deg); animation-delay: .19s; } .card:nth-child(4) { transform: rotate(1.6deg); animation-delay: .26s; }
.card::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34%; background: repeating-linear-gradient(-48deg, var(--c) 0 5px, var(--c2) 5px 8px); opacity: .9; border-top: 3px solid var(--ink); }
.c-play { --c: #ffb05c; --c2: #ffc985; }
.c-duo { --c: #b4a5ff; --c2: #cdc2ff; }
.c-learn { --c: #7fd497; --c2: #a3e2b4; }
.c-puzzle { --c: #7cc9f2; --c2: #a6dcf8; }
.card .pics { position: absolute; left: 0; right: 0; top: 4%; bottom: 30%; }
.card .pics img { position: absolute; bottom: 2%; height: 80%; max-width: 62%; object-fit: contain; left: 50%; transform: translateX(-50%); filter: drop-shadow(2px 4px 0 rgba(58, 49, 80, .12)); z-index: 2; }
.card .pics img.wide { max-width: 92%; height: 84%; }
.card .pics img.l { height: 52%; max-width: 40%; left: 20%; bottom: 8%; z-index: 1; transform: translateX(-50%) rotate(-8deg); }
.card .pics img.r { height: 52%; max-width: 40%; left: 80%; bottom: 8%; z-index: 1; transform: translateX(-50%) rotate(8deg); }
.card .name { position: absolute; left: 5%; right: 5%; bottom: 4%; height: 26%; display: flex; align-items: center; justify-content: center; text-align: center; font: 700 calc(var(--u) * 5.6) / 1.02 var(--head); color: var(--ink); z-index: 2; }
.progress-dot { position: absolute; top: 6px; right: 8px; padding: 2px 9px 0; border-radius: 999px; background: #fff; border: 2.5px solid var(--ink); font: 700 calc(var(--u) * 4) / 1.4 var(--head); font-style: normal; z-index: 3; }
.progress-dot:empty { display: none; }
@keyframes cardIn { 0% { transform: translateY(40px) scale(.85); opacity: 0; } 100% { opacity: 1; } }
.home-bottom { position: absolute; left: var(--safe-l); right: var(--safe-r); bottom: var(--safe-b); display: flex; justify-content: center; z-index: 2; }
@media (orientation: portrait) {
  .menu { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 1fr; top: calc(var(--safe-t) + 96px); bottom: calc(var(--safe-b) + 84px); }
  .title { font-size: min(9vw, 44px); padding-right: 50px; } /* balances the gear so the name sits in the middle */
  .home-top { flex-wrap: wrap; }
  .home-top .brand { display: none; } /* no room beside the name on an upright phone; the logo intro shows the brand */
  .card .name { font-size: max(18px, calc(var(--u) * 5.4)); }
}

/* ------------------------------------------------------------------ bars and grids (pick, learn, puzzles, album) */
.bar { position: absolute; top: var(--safe-t); left: var(--safe-l); right: var(--safe-r); display: flex; align-items: center; gap: 16px; z-index: 2; }
.bar h2 { margin: 0; flex: 1; font: 700 calc(var(--u) * 8) / 1.1 var(--head); text-align: center; }
.bar .count { min-width: 52px; font: 700 calc(var(--u) * 5.5) / 1.3 var(--head); background: #fff; border-radius: 999px; padding: 4px 16px 2px; border: 2.5px solid var(--ink); text-align: center; }
.bar .count:empty { visibility: hidden; }
.bar > span:empty { width: 52px; }
@media (orientation: portrait) { .bar h2 { font-size: max(22px, calc(var(--u) * 7)); } }
.friends { position: absolute; left: var(--safe-l); right: var(--safe-r); top: calc(var(--safe-t) + var(--u) * 20); bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: calc(var(--u) * 3); align-items: center; padding: 0 calc(var(--u) * 2) calc(var(--u) * 4); }
.friend { position: relative; height: min(100%, calc(var(--u) * 64)); border-radius: var(--r); background: var(--card); border: 3.5px solid var(--ink); box-shadow: 4px 6px 0 rgba(58, 49, 80, .22); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(var(--u) * 3) calc(var(--u) * 1.5) calc(var(--u) * 2.5); animation: cardIn .5s cubic-bezier(.3, 1.5, .5, 1) both; transition: transform .14s ease; }
.friend:nth-child(odd) { rotate: -1.2deg; } .friend:nth-child(even) { rotate: 1.2deg; }
.friend img { width: 92%; aspect-ratio: 1; object-fit: contain; }
.friend b { font: 700 calc(var(--u) * 5.6) / 1.05 var(--head); text-align: center; max-width: 100%; white-space: nowrap; overflow: hidden; }
.friend small { font: 800 calc(var(--u) * 3.6) var(--body); color: var(--ink-2); text-align: center; }
.stars { display: inline-flex; gap: 2px; color: #e7dccb; }
.stars svg { width: calc(var(--u) * 4.4); height: calc(var(--u) * 4.4); min-width: 14px; min-height: 14px; }
.stars svg.on { color: var(--sun); filter: drop-shadow(1px 1px 0 rgba(58, 49, 80, .3)); }
.friend .crown { position: absolute; top: -18px; right: -10px; width: 44px; height: 44px; color: var(--sun); filter: drop-shadow(2px 2px 0 rgba(58, 49, 80, .35)); transform: rotate(18deg); display: none; }
.friend.won .crown { display: block; }
@media (orientation: portrait) {
  .friends { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; overflow-y: auto; top: calc(var(--safe-t) + 76px); touch-action: pan-y; padding-bottom: 30px; }
  .friend { height: auto; }
  .friend b { font-size: 20px; } .friend small { font-size: 13px; }
}
.grid { position: absolute; left: 0; right: 0; top: calc(var(--safe-t) + var(--u) * 19); bottom: 0; overflow-y: auto; padding: 8px var(--safe-r) 30px var(--safe-l); display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: calc(var(--u) * 3); touch-action: pan-y; }
@media (orientation: portrait) { .grid { top: calc(var(--safe-t) + 70px); } }
.tile { position: relative; flex: none; width: calc(var(--u) * 30); min-width: 110px; aspect-ratio: .86; border-radius: var(--r); background: var(--card); border: 3px solid var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 6px 6px 8px; transition: transform .14s ease; }
.tile:nth-child(3n) { rotate: 1deg; } .tile:nth-child(3n+1) { rotate: -1deg; }
.tile img { position: absolute; top: 8%; left: 10%; width: 80%; height: 62%; object-fit: contain; }
.tile .num { position: absolute; top: -10px; left: -8px; width: 36px; height: 36px; border-radius: 50%; background: var(--sun); border: 2.5px solid var(--ink); font: 700 18px/32px var(--head); text-align: center; }
.tile b { font: 700 calc(var(--u) * 4.2) / 1.05 var(--head); text-align: center; min-height: 2.1em; display: flex; align-items: center; justify-content: center; max-width: 100%; overflow: hidden; }
.tile .done { position: absolute; top: -10px; right: -8px; width: 38px; height: 38px; border-radius: 50%; background: var(--green); color: #fff; border: 2.5px solid var(--ink); display: none; place-items: center; }
.tile .done svg { width: 70%; height: 70%; }
.tile.ok .done { display: grid; }
@media (orientation: portrait) { .tile { width: calc(50vw - 30px); max-width: 190px; } .tile b { font-size: 16px; } }
.puzzle-grid .tile { width: calc(var(--u) * 21); min-width: 76px; aspect-ratio: 1; justify-content: center; }
.puzzle-grid .tile b { font-size: calc(var(--u) * 7); min-height: 0; }
.puzzle-grid .tile.ok { background: #e3f6e7; }
.puzzle-grid .tile.next { background: #fff3c2; animation: bounce 1.4s ease-in-out infinite; }
.puzzle-grid h3, .album-grid h3 { flex: 0 0 100%; margin: 8px 0 0; font: 700 calc(var(--u) * 5.5) / 1.1 var(--head); text-align: left; }
@media (orientation: portrait) { .puzzle-grid .tile { width: calc(25vw - 18px); } .puzzle-grid .tile b { font-size: 22px; } }
.album-hint { position: absolute; top: calc(var(--safe-t) + var(--u) * 14); left: var(--safe-l); right: var(--safe-r); margin: 0; font: 800 calc(var(--u) * 3.8) var(--body); color: var(--ink-2); text-align: center; }
.album-grid { top: calc(var(--safe-t) + var(--u) * 22); }
.album-grid .tile { width: calc(var(--u) * 25); min-width: 96px; }
.album-grid .tile.locked img { filter: brightness(0) opacity(.12); }
.album-grid .tile.locked b { color: #b9ae9e; }
.album-grid .tile.new::after { content: "★"; position: absolute; top: -12px; right: -6px; color: var(--sun); font-size: 30px; -webkit-text-stroke: 1.5px var(--ink); }

/* ------------------------------------------------------------------ game HUD */
.tl { position: absolute; top: var(--safe-t); left: var(--safe-l); }
.opp, .task, .turn { position: absolute; left: var(--safe-l); top: calc(var(--safe-t) + max(52px, var(--u) * 14) + 14px); width: max(150px, min(calc(var(--ml) - 30px), 340px)); background: var(--card); border: 3px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow); display: none; }
.opp.show, .task.show, .turn.show { display: block; animation: cardIn .4s cubic-bezier(.3, 1.5, .5, 1) both; }
.opp { display: none; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; }
.opp.show { display: flex; }
.opp img { width: min(calc(var(--u) * 15), 38%); height: auto; aspect-ratio: 1; min-width: 52px; flex: none; }
.opp-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.opp-text b { display: block; font: 700 min(calc(var(--u) * 5), 34px) / 1.05 var(--head); white-space: nowrap; overflow: hidden; }
.think { position: absolute; left: calc(var(--u) * 11); top: -14px; display: none; gap: 4px; padding: 4px 8px; background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; }
.opp.thinking .think { display: flex; }
.think i { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); animation: dots 1s ease-in-out infinite; }
.think i:nth-child(2) { animation-delay: .15s; } .think i:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-5px); opacity: 1; } }
.opp.oops img { animation: oops .5s ease 2; }
@keyframes oops { 50% { transform: rotate(-10deg) scale(1.06); } }
.task { padding: 8px 10px 10px; }
.task-head { display: flex; align-items: center; gap: 8px; }
.task-head img { width: min(44px, 22%); height: auto; aspect-ratio: 1; object-fit: contain; flex: none; }
.task-head b { flex: 1; font: 700 min(calc(var(--u) * 4.8), 30px) / 1.05 var(--head); min-width: 0; overflow: hidden; }
.task p { margin: 6px 0 0; font: 800 min(calc(var(--u) * 3.6), 21px) / 1.3 var(--body); color: var(--ink-2); overflow-wrap: break-word; hyphens: auto; } /* long Polish/German words break instead of leaving the card */
.task-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.task-foot .mini-btn { margin-left: auto; flex: none; }
.goals { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.goals svg { width: 26px; height: 26px; color: #e7dccb; }
.goals svg.on { color: var(--sun); animation: pop .45s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop { 0% { transform: scale(.3); } 100% { transform: scale(1); } }
.turn { display: none; padding: 6px 12px 6px 6px; align-items: center; gap: 8px; font: 700 min(calc(var(--u) * 5), 34px) / 1.1 var(--head); }
.turn span { min-width: 0; overflow: hidden; line-height: 1.05; } /* wraps to two lines rather than shrinking */
.turn.show { display: flex; }
.turn img { width: min(calc(var(--u) * 13), 34%); height: auto; aspect-ratio: 1; min-width: 46px; flex: none; }
.turn.b { background: #efeaff; } .turn.w { background: #fff1e2; }
.status { position: absolute; left: 50%; bottom: max(6px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(72vw, 920px); display: flex; align-items: center; padding: calc(var(--u) * 0.8) calc(var(--u) * 4.5) calc(var(--u) * 0.4) calc(var(--u) * 4); background: rgba(255, 253, 246, .94); border: 2.5px solid var(--ink); border-radius: 999px 960px 999px 980px; box-shadow: 2px 3px 0 rgba(58, 49, 80, .16); font: 700 min(calc(var(--u) * 4.8), 40px) / 1.2 var(--head); white-space: nowrap; pointer-events: none !important; transition: opacity .25s; }
.status.empty { opacity: 0; }
.status span { display: block; overflow: hidden; text-overflow: ellipsis; clip-path: inset(-20% calc(100% - var(--p, 100%)) -20% -5%); }
.status .crayon { position: absolute; top: 10%; left: calc(var(--u) * 4 + var(--p, 100%) * var(--w, 0) / 100); width: calc(var(--u) * 10); height: calc(var(--u) * 4); min-width: 34px; min-height: 14px; transform: rotate(-28deg); transform-origin: 0 50%; opacity: 0; transition: opacity .2s; }
.status.writing .crayon { opacity: 1; }
.status.alert { background: #ffe3e7; }
.tools { position: absolute; right: var(--safe-r); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: calc(var(--u) * 3); }
.tool { width: calc(var(--u) * 16); height: calc(var(--u) * 16); min-width: 58px; min-height: 58px; }
#btnHint { color: #e8a400; } #btnUndo { color: var(--blue); }
@media (orientation: portrait) {
  .opp, .task, .turn { left: calc(var(--safe-l) + 68px); top: var(--safe-t); width: calc(100vw - 100px - var(--safe-l)); }
  .status { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 74px); max-width: 92vw; font-size: max(16px, calc(var(--u) * 4.6)); }
  .tools { flex-direction: row; }
  .task p { font-size: 14px; } .task-head b { font-size: 18px; } .opp-text b, .turn { font-size: 18px; }
}

/* ------------------------------------------------------------------ overlays */
.overlay { background: rgba(58, 49, 80, .35); z-index: 20; display: none; place-items: center; }
.overlay.show { display: grid; }
.overlay.soft { background: rgba(255, 248, 235, .35); }
.sheet { position: relative; max-width: 94vw; max-height: 94vh; overflow: auto; background: var(--card) url(art/paper.webp); background-size: 512px; border: 3.5px solid var(--ink); border-radius: var(--r); box-shadow: 6px 8px 0 rgba(58, 49, 80, .25); padding: calc(var(--u) * 5) calc(var(--u) * 7); text-align: center; animation: cardIn .45s cubic-bezier(.3, 1.6, .5, 1) both; }
.sheet h2 { margin: 0 0 calc(var(--u) * 3); font: 700 calc(var(--u) * 8.5) / 1.1 var(--head); }
.sheet p { margin: 0 0 calc(var(--u) * 3); font: 800 calc(var(--u) * 4.4) / 1.35 var(--body); color: var(--ink-2); max-width: 70vw; margin-left: auto; margin-right: auto; }
@media (orientation: portrait) { .sheet h2 { font-size: max(24px, calc(var(--u) * 8)); } .sheet p { font-size: 16px; max-width: 82vw; } }
.promo-btns { display: flex; gap: calc(var(--u) * 3); justify-content: center; flex-wrap: wrap; }
.promo-btns button { width: calc(var(--u) * 28); min-width: 96px; aspect-ratio: .82; border-radius: var(--r); background: #fff; border: 3px solid var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 6px; font: 700 calc(var(--u) * 4.4) / 1.1 var(--head); transition: transform .12s; }
.promo-btns button img { width: 100%; height: 76%; object-fit: contain; }
.promo-btns button.best { background: #fff3c2; animation: bounce 1.4s ease-in-out infinite; }
.end-sheet { min-width: min(560px, 90vw); }
.end-stars { display: flex; justify-content: center; gap: 10px; color: var(--sun); margin-bottom: 4px; }
.end-stars svg { width: calc(var(--u) * 13); height: calc(var(--u) * 13); min-width: 38px; min-height: 38px; filter: drop-shadow(2px 3px 0 rgba(58, 49, 80, .3)); animation: pop .6s cubic-bezier(.3, 1.8, .5, 1) both; }
.end-stars svg:nth-child(2) { width: calc(var(--u) * 17); height: calc(var(--u) * 17); animation-delay: .15s; }
.end-stars svg:nth-child(3) { animation-delay: .3s; }
.end-stars.dim svg { color: #e7dccb; }
.end-pic { width: calc(var(--u) * 26); height: calc(var(--u) * 26); min-width: 80px; min-height: 80px; object-fit: contain; display: none; margin: -4px auto 4px; }
.end-pic.show { display: block; animation: pop .5s cubic-bezier(.3, 1.8, .5, 1); }
.end-sticker { display: none; align-items: center; justify-content: center; gap: 10px; margin: 0 auto calc(var(--u) * 3); padding: 6px 16px 6px 8px; background: #fff3c2; border: 2.5px solid var(--ink); border-radius: 30px; width: fit-content; max-width: 100%; font: 700 calc(var(--u) * 4.4) / 1.15 var(--head); text-align: left; }
.end-sticker.show { display: flex; animation: pop .6s cubic-bezier(.3, 1.8, .5, 1) .4s both; }
.end-sticker img { width: 54px; height: 54px; object-fit: contain; }
.end-btns { display: flex; justify-content: center; gap: calc(var(--u) * 3); flex-wrap: wrap; }
/* landscape phones: picture on the left, words and buttons on the right, so everything fits the short screen */
@media (orientation: landscape) {
  .end-sheet { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "pic stars" "pic title" "pic sub" "sticker sticker" "btns btns"; column-gap: calc(var(--u) * 5); align-items: center; padding: calc(var(--u) * 4) calc(var(--u) * 6); max-width: min(900px, 94vw); }
  .end-stars { grid-area: stars; margin: 0; }
  .end-stars svg { width: calc(var(--u) * 10); height: calc(var(--u) * 10); }
  .end-stars svg:nth-child(2) { width: calc(var(--u) * 13); height: calc(var(--u) * 13); }
  .end-pic { grid-area: pic; width: calc(var(--u) * 34); height: calc(var(--u) * 34); margin: 0; }
  .end-sheet h2 { grid-area: title; margin: calc(var(--u) * 1) 0; }
  .end-sheet p { grid-area: sub; margin: 0 0 calc(var(--u) * 2); max-width: 46vw; }
  .end-sticker { grid-area: sticker; margin: 0 auto calc(var(--u) * 2); }
  .end-btns { grid-area: btns; margin-top: calc(var(--u) * 3); }
}

/* parent area */
.gate { position: relative; background: var(--card); border: 3.5px solid var(--ink); border-radius: var(--r); padding: calc(var(--u) * 6) calc(var(--u) * 10); text-align: center; animation: cardIn .4s cubic-bezier(.3, 1.6, .5, 1) both; }
.gate p { margin: 0 0 calc(var(--u) * 5); font: 800 clamp(15px, calc(var(--u) * 4.4), 20px) var(--body); color: var(--ink); max-width: 60vw; }
.hold-btn { position: relative; width: calc(var(--u) * 30); height: calc(var(--u) * 30); min-width: 96px; min-height: 96px; max-width: 150px; max-height: 150px; border-radius: 50%; background: linear-gradient(135deg, #ff9a62, #ff4f7b); color: #fff; display: grid; place-items: center; margin: 0 auto; border: 3px solid var(--ink); box-shadow: var(--shadow); }
.hold-btn.small { width: calc(var(--u) * 22); height: calc(var(--u) * 22); }
.hold-btn .ico { width: 44%; height: 44%; }
.hold-btn .ring { position: absolute; inset: -12px; width: calc(100% + 24px); height: calc(100% + 24px); transform: rotate(-90deg); }
.hold-btn .ring circle { stroke-width: 7; stroke-dasharray: 340; stroke-dashoffset: 340; stroke: var(--sun); }
.hold-btn.holding .ring circle { stroke-dashoffset: 0; transition: stroke-dashoffset 3s linear; }
.gate .close { position: absolute; top: -18px; right: -18px; width: 56px; height: 56px; min-width: 0; min-height: 0; }
.panel { display: none; width: min(720px, 92vw); max-height: 92vh; background: #fff; border: 3px solid var(--ink); border-radius: 26px; overflow: hidden; flex-direction: column; animation: cardIn .4s cubic-bezier(.3, 1.6, .5, 1) both; font-size: clamp(15px, calc(var(--u) * 3.4), 19px); }
.panel.show { display: flex; }
.panel header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 10px 22px; border-bottom: 2px solid #f1e6dc; }
.panel h2 { margin: 0; font: 700 1.4em var(--head); }
.panel header .round-btn { width: 48px; height: 48px; min-width: 0; min-height: 0; box-shadow: none; }
.rows { overflow-y: auto; padding: 6px 22px 22px; touch-action: pan-y; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid #f6efe8; font: 800 1em var(--body); }
.row.col { flex-direction: column; align-items: stretch; }
.row input { display: none; }
.switch { position: relative; width: 62px; height: 36px; border-radius: 18px; background: #e3e6f2; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; left: 4px; top: 4px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
input:checked + .switch { background: var(--green); }
input:checked + .switch::after { transform: translateX(26px); }
.seg, .langs { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button, .langs button { padding: 9px 15px; border-radius: 999px; background: #f4f0fa; font: 800 .92em var(--body); }
.seg button.on, .langs button.on { background: var(--ink); color: #fff; }
.note { margin: 10px 0 0; font: 700 .85em/1.45 var(--body); color: var(--ink-2); }
.note:empty { display: none; }
.note.small { font-size: max(12px, .72em); }
.note.warn { color: #c0392b; }
.exit-btn { margin-top: 16px; width: 100%; padding: 13px; border-radius: 16px; background: #fdecee; color: #c2384a; font: 800 1em var(--body); }
.web .exit-btn { display: none; }

/* play time is over */
.night { background: linear-gradient(#1d2350, #3a2f7a); }
.sleep-card { text-align: center; color: #fff; padding: 20px; }
.sleep-card .moon { width: calc(var(--u) * 22); height: calc(var(--u) * 22); color: #ffe48a; margin: 0 auto; filter: drop-shadow(0 0 24px rgba(255, 228, 138, .6)); animation: bounce 3s ease-in-out infinite; }
.sleep-card h2 { font: 700 calc(var(--u) * 9) / 1.15 var(--head); margin: calc(var(--u) * 3) 0 calc(var(--u) * 2); }
.sleep-card p { font: 800 calc(var(--u) * 4.5) var(--body); opacity: .85; margin: 0 auto calc(var(--u) * 5); max-width: 70vw; }

.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 4px); z-index: 30; transform: translate(-50%, -10px) scale(.9); padding: 10px 22px 8px; background: #fff; border: 3px solid var(--ink); border-radius: 999px; font: 700 calc(var(--u) * 5) var(--head); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s cubic-bezier(.3, 1.6, .5, 1); white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
#fade { position: fixed; inset: 0; background: var(--paper); opacity: 0; pointer-events: none; transition: opacity .22s ease; z-index: 40; }
#fade.on { opacity: 1; pointer-events: auto; }
#noGl { background: var(--paper); color: var(--ink); text-align: center; font: 800 22px var(--body); padding: 30px; }
#noGl.show { display: grid; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; } }
