@font-face { font-family: 'Fredoka'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/fredoka-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/fredoka-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/dm-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/dm-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/dm-sans-latin-700-normal.woff2') format('woff2'); }
:root { padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
[hidden] { display: none !important; }
/* Layout: one phone-width column: header, score strip, board well, hint, piece tray, actions. */
:root {
  --bg: #14172B; --panel: #1E2240; --slot: #2A2F55; --fg: #E8ECFF; --muted: #A9B0D6;
  --space: #0F1226; --ink: #14172B; --accent: #FFC93C; --accent-text: #FFC93C; --ok: #8BE04E;
  --ghost: rgba(255, 201, 60, 0.45);
  --display: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) {
  --bg: #EEF0FA; --panel: #FFFFFF; --slot: #D5D9EE; --fg: #14172B; --muted: #555B85;
  --space: #14172B; --accent-text: #7A5400; --ok: #2E7D12; --ghost: rgba(122, 84, 0, 0.35); color-scheme: light } }
:root[data-theme="light"] {
  --bg: #EEF0FA; --panel: #FFFFFF; --slot: #D5D9EE; --fg: #14172B; --muted: #555B85;
  --space: #14172B; --accent-text: #7A5400; --ok: #2E7D12; --ghost: rgba(122, 84, 0, 0.35); color-scheme: light }

body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; padding-inline: 16px; padding-block: 16px; -webkit-user-select: none; user-select: none; }
.game { --gap: 4px; --cell: clamp(38px, calc((100vw - 112px) / 5), 58px); --tcell: 34px;
  max-width: 420px; margin-inline: auto; display: flex; flex-direction: column; gap: 14px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1; }
#pick { font: inherit; font-weight: 700; min-width: 0; min-height: 44px; padding: 0 10px; border: 0; border-radius: 12px; background: var(--panel); color: var(--fg); }
#pick:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
button { font-family: inherit; cursor: pointer; border: 0; color: var(--fg); background: var(--panel); border-radius: 14px; font-size: 15px; font-weight: 700; min-height: 48px; padding: 0 16px; }
button:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--panel); border-radius: 14px; padding: 8px 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
.stat b { font-family: var(--display); font-weight: 600; font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.well { background: var(--panel); border-radius: 20px; padding: 10px 12px; display: flex; justify-content: center;
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 10; box-shadow: 0 0 0 8px var(--bg); }
.frame { display: grid; grid-template-columns: 14px auto 14px; grid-template-rows: 14px auto 14px; gap: 6px; }
.nums, .ticks { display: grid; gap: var(--gap); font-size: 12px; font-weight: 700; color: var(--muted); }
.nums > *, .ticks > * { display: flex; align-items: center; justify-content: center; }
.across { grid-template-columns: repeat(5, var(--cell)); }
.down { grid-auto-rows: var(--cell); }
.ticks svg { width: 14px; height: 14px; color: var(--ok); opacity: 0; transition: opacity .2s; }
.ticks .on svg { opacity: 1; }
.ticks .near svg { opacity: 1; color: var(--accent-text); }
#board { position: relative; display: grid; grid-template-columns: repeat(5, var(--cell)); grid-auto-rows: var(--cell); gap: var(--gap); }
.slot { border-radius: calc(var(--cell) * .18); background: var(--slot); box-shadow: inset 0 3px 0 rgba(0,0,0,.14); }
.slot.gap { background: var(--space); box-shadow: none; }
.slot.ghost { box-shadow: inset 0 0 0 3px var(--ghost); }
.piece { display: grid; gap: var(--gap); grid-auto-rows: var(--cell); pointer-events: none; }
.piece.in-tray { --cell: var(--tcell); --gap: 3px; }
.piece.on-board { position: absolute; left: calc(var(--c0) * (var(--cell) + var(--gap))); top: calc(var(--r0) * (var(--cell) + var(--gap))); }
.piece.dragging { position: fixed; z-index: 50; filter: drop-shadow(0 10px 12px rgba(0,0,0,.35)); }
.pc { pointer-events: auto; touch-action: none; cursor: grab; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  border-radius: calc(var(--cell) * .18); background: var(--c); color: var(--ink);
  font-family: var(--display); font-weight: 600; font-size: calc(var(--cell) * .46);
  box-shadow: inset 0 calc(var(--cell) * -.09) 0 rgba(0,0,0,.2); }
.pc.sp { background: var(--space); box-shadow: none; border: max(2px, calc(var(--cell) * .055)) solid var(--c); }
.pc.pop { animation: pop .45s ease both; }
@keyframes pop { 40% { transform: scale(1.14); } }
.hint { background: var(--panel); border: 2px solid var(--accent-text); border-radius: 14px; padding: 10px 14px; }
.hint span { display: block; font-size: 12px; font-weight: 700; color: var(--accent-text); text-transform: uppercase; letter-spacing: 0.8px; }
.hint p { margin: 2px 0 0; line-height: 1.3; }
.note { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
#tray { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; justify-content: center; }
.tslot { padding: 8px; touch-action: none; cursor: grab; display: flex; align-items: center; justify-content: center; }
#win .sheet { text-align: center; }
.winbtns { display: flex; flex-direction: column; gap: 8px; }
#share { display: flex; align-items: center; justify-content: center; gap: 8px; }
.sheet .sec, .sheet a.btn { background: var(--slot); color: var(--fg); }
a.btn { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 14px; font-size: 15px; font-weight: 700; text-decoration: none; }
a.btn:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
#win h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 24px; }
#shareText { text-align: center; white-space: pre-wrap; font-family: var(--body); font-size: 14px; line-height: 1.5; background: var(--bg); border-radius: 12px; padding: 12px; margin: 0 0 14px; -webkit-user-select: text; user-select: text; }
.stgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.stgrid div { background: var(--bg); border-radius: 12px; padding: 8px 4px; }
.stgrid b { display: block; font-family: var(--display); font-weight: 600; font-size: 20px; font-variant-numeric: tabular-nums; }
.stgrid span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
#win #countdown { margin: 0 0 14px; color: var(--fg); font-weight: 700; font-variant-numeric: tabular-nums; }
#win p { margin: 6px 0 14px; color: var(--muted); }
.actions { display: grid; gap: 8px; }
.primary { background: var(--accent); color: var(--ink); box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); }
.hbtns { display: flex; gap: 8px; }
.logo { display: grid; grid-template-columns: repeat(4, 24px); gap: 2px; }
.logo span { height: 24px; border-radius: 6px; background: var(--c); color: var(--ink); font-size: 15px; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
#snd { width: 48px; padding: 0; display: flex; align-items: center; justify-content: center; }
#snd .sl, #snd.off .wv { display: none; } #snd.off .sl { display: inline; }
.hint.nudge { animation: nudge .5s ease; }
@keyframes nudge { 40% { transform: scale(1.04); } }
#info { width: 48px; padding: 0; font-family: var(--display); font-size: 20px; }
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(8, 10, 24, .72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { max-height: 100%; overflow-y: auto; background: var(--panel); border-radius: 20px; padding: 20px; width: 100%; max-width: 360px; box-sizing: border-box; }
.sheet h2 { margin: 0 0 12px; font-family: var(--display); font-weight: 600; font-size: 22px; }
.sheet ul { margin: 0 0 16px; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; line-height: 1.35; }
.sheet .g { color: var(--ok); } .sheet .y { color: var(--accent-text); }
.sheet button { width: 100%; }
#coach { margin: 0; padding: 10px 14px; border: 2px solid var(--accent-text); border-radius: 14px; background: var(--panel); font-weight: 500; line-height: 1.3; }
.coaching .piece.in-tray { animation: bob 1.8s ease-in-out infinite; }
.coaching .tslot:nth-child(3n+2) .piece { animation-delay: .3s; }
.coaching .tslot:nth-child(3n) .piece { animation-delay: .6s; }
.piece.dragging { animation: none !important; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.demo { position: relative; width: 214px; height: 166px; margin: 0 auto 14px; }
.drow { display: grid; grid-template-columns: repeat(5, 34px); gap: 3px; }
.drow i { height: 34px; border-radius: 7px; background: var(--slot); }
.drow i.g { background: var(--space); }
.dp { position: absolute; left: 0; top: 0; display: grid; grid-auto-rows: 34px; gap: 3px; }
.d1 { grid-template-columns: repeat(2, 34px); } .d2 { grid-template-columns: repeat(3, 34px); }
.dp i { visibility: hidden; }
.dp b.sp { box-sizing: border-box; background: var(--space); border: 2px solid var(--c); box-shadow: none; }
.dp b { height: 34px; border-radius: 7px; background: var(--c); color: var(--ink); font-family: var(--display); font-weight: 600; font-size: 17px; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
.d1 { animation: d1 5s ease-in-out infinite; z-index: 1; }
.d2 { animation: d2 5s ease-in-out infinite; }
.dtick { position: absolute; left: 190px; top: 6px; color: var(--ok); animation: dtick 5s ease-in-out infinite; }
@keyframes d1 { 0% { transform: translate(111px, 95px); opacity: 0; } 8%, 14% { transform: translate(111px, 95px); opacity: 1; } 32%, 92% { transform: none; opacity: 1; } 100% { transform: none; opacity: 0; } }
@keyframes d2 { 0% { transform: translate(0, 95px); opacity: 0; } 8%, 40% { transform: translate(0, 95px); opacity: 1; } 58%, 92% { transform: translate(74px, 0); opacity: 1; } 100% { transform: translate(74px, 0); opacity: 0; } }
@keyframes dtick { 0%, 60% { opacity: 0; transform: scale(.4); } 68%, 92% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.slot.gap.pulse { animation: gapPulse .7s ease 2; }
#coach.shake { animation: shake .4s ease; }
@keyframes shake { 20% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 80% { transform: translateX(-3px); } }
#skipBtn { background: var(--panel); }
.well.cheer { animation: wellCheer 1.6s ease; }
@keyframes wellCheer { 0% { box-shadow: 0 0 0 8px var(--bg), 0 0 0 8px var(--ok); } 30% { box-shadow: 0 0 0 8px var(--bg), 0 0 0 14px var(--ok); } 100% { box-shadow: 0 0 0 8px var(--bg), 0 0 0 8px var(--bg); } }
@keyframes gapPulse { 50% { box-shadow: 0 0 0 4px var(--accent-text); } }
@media (prefers-reduced-motion: reduce) {
  .coaching .piece.in-tray, .d1, .d2, .dtick, .slot.gap.pulse, #coach.shake, .well.cheer { animation: none; }
  .d2 { transform: translate(74px, 0); }
}
@media (prefers-reduced-motion: reduce) { .pc.pop, .hint.nudge { animation: none; } }
.ca { --c: #FFC93C; } .cb { --c: #FF7A59; } .cc { --c: #2ED3B7; }
.fine { margin: 14px 0 0; font-size: 13px; text-align: center; color: var(--muted); }
.fine a { color: var(--muted); }
.page { max-width: 560px; margin: 0 auto; padding-block: 4px 32px; line-height: 1.5; -webkit-user-select: text; user-select: text; }
.page h1 { margin: 8px 0 12px; font-family: var(--display); font-weight: 600; font-size: 28px; }
.page h2 { margin: 26px 0 6px; font-family: var(--display); font-weight: 600; font-size: 19px; }
.page p { margin: 0 0 10px; }
.page a { color: var(--accent-text); }
.page .sec { background: var(--panel); }
.page .fine { text-align: left; margin-top: 28px; }
.fine a + a { margin-left: 16px; }
.page .fine + .fine { margin-top: 8px; }
