/* Fonts are bundled so the app works offline (SIL Open Font License, see fonts/) */
@font-face {
  font-family: 'Nunito';
  src: url('fonts/nunito-latin.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}
@font-face {
  font-family: 'Baloo 2';
  src: url('fonts/baloo2-800-latin.woff2') format('woff2');
  font-weight: 800;
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --gap: 10px;
  --board-size: min(95vw, 480px);
  --tile-size: calc((var(--board-size) - 5 * var(--gap)) / 4);
  /* Picnic skin */
  --text-dark: #7A3B2E;     /* cocoa */
  --accent: #FF5D7E;        /* strawberry red */
  --accent-dark: #C93F60;
  --mustard: #FFD36B;
  --mustard-dark: #D9A23A;
  --cream: #FFF8EC;
  --gingham: rgba(255, 140, 160, 0.13);
  --stitch: #FFB0C0;
  --tray: #F2DEC4;
  --tray-edge: #DCC2A0;
  --muted: #B88A7A;
  --display: 'Baloo 2', 'Nunito', ui-rounded, system-ui, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: none;   /* swipes belong to the game, not page scroll */
  /* no text/grid selection, magnifier or long-press menu while swiping */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
img { -webkit-user-drag: none; }
/* iOS browsers can still start a selection on individual text, so apply it everywhere */
* { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

body {
  font-family: 'Nunito', ui-rounded, -apple-system, system-ui, sans-serif;
  color: var(--text-dark);
  /* picnic-blanket gingham */
  background-color: var(--cream);
  background-image:
    repeating-linear-gradient(0deg, var(--gingham) 0 22px, transparent 22px 44px),
    repeating-linear-gradient(90deg, var(--gingham) 0 22px, transparent 22px 44px);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* keep clear of the iPhone notch and home bar when the app fills the screen */
  padding: calc(16px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  max-width: 520px;
  margin: 0 auto;
}

/* ── Header ── */
header { width: 100%; margin-bottom: 14px; }

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.title-block { display: flex; flex-direction: column; }

h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 9vw, 2.35rem);   /* shrinks on narrow phones */
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  white-space: nowrap;
  color: var(--accent);
  text-shadow: 0 3px 0 var(--accent-dark);
}

.subtitle {
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--muted);
}

/* Header icon buttons show drawn icons (set in game.js) */
#settingsBtn, #boardBtn { display: flex; align-items: center; justify-content: center; }
#settingsBtn svg, #boardBtn svg { width: 22px; height: 22px; display: block; }

.scores { display: flex; gap: 8px; }

.score-box {
  position: relative;
  background: #fff;
  border: 2px dashed var(--stitch);
  border-radius: 14px;
  padding: 5px 13px;
  text-align: center;
  min-width: 68px;
}
.score-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #E0708A;
}
.score-value {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-dark);
}

.controls { display: flex; gap: 8px; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 20px;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 0 var(--accent-dark);
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--accent-dark);
}
.btn:focus-visible { outline: 3px solid var(--text-dark); outline-offset: 2px; }
[hidden] { display: none !important; }
.btn-icon  {
  padding: 8px 14px; font-size: 1.1rem;
  background: var(--mustard);
  box-shadow: 0 4px 0 var(--mustard-dark);
}
.btn-icon:active { box-shadow: 0 1px 0 var(--mustard-dark); }
.btn-big   { padding: 13px 26px; font-size: 1rem; border-radius: 22px; }
.btn-secondary {
  background: var(--mustard);
  color: var(--text-dark);
  box-shadow: 0 4px 0 var(--mustard-dark);
}
.btn-secondary:active { box-shadow: 0 1px 0 var(--mustard-dark); }
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Board ── */
.board-wrapper { width: 100%; display: flex; justify-content: center; }

.board {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  /* wooden picnic tray */
  background-color: var(--tray);
  border-radius: 18px;
  padding: var(--gap);
  box-shadow:
    0 6px 0 var(--tray-edge),
    0 10px 24px rgba(160,110,60,0.18);
}

.grid-bg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--gap);
  position: absolute;
  inset: var(--gap);
}

.cell {
  background: rgba(255,255,255,0.45);
  border-radius: 10px;
}

.tiles {
  position: absolute;
  inset: var(--gap);
  pointer-events: none;
}

/* ── Tiles ── */
.tile {
  position: absolute;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  z-index: 1;
  background: #FFD0E8;
  left: 0; top: 0;
  will-change: translate;
  /* translate (GPU-composited) powers the slide animation */
  transition: translate 0.13s cubic-bezier(0.4, 0, 0.2, 1);   /* = SLIDE_MS in game.js */
}

.tile img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }

/* Value badge is plain HTML so it uses the page font and costs nothing to move */
.tile::before {
  content: attr(data-v);
  position: absolute;
  top: 4%; left: 4%;
  z-index: 1;
  padding: 0.12em 0.55em;
  border-radius: 99px;
  background: rgba(255,255,255,0.92);
  color: var(--text-dark);
  font-weight: 900;
  font-size: calc(var(--tile-size) * 0.105);
  line-height: 1.25;
}

/* Tile spawns with a springy pop */
.tile-new {
  animation: tileAppear 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes tileAppear {
  from { transform: scale(0) rotate(-10deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}

/* Merge bounce — applied after slide finishes */
.tile-pop {
  animation: tilePop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes tilePop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Suppress transitions during resize re-layout */
.no-anim { transition: none !important; animation: none !important; }

/* ── Tile shadows: a soft drop onto the tray; gold glow past 2048 ── */
.tile  { box-shadow: 0 2px 0 rgba(160,110,60,0.22), 0 3px 8px rgba(160,110,60,0.12); }
.t4096, .t8192 { box-shadow: 0 0 18px rgba(255,200,60,0.7), 0 2px 0 rgba(160,110,60,0.22); }

/* ── Overlays ── */
.celebration, .gameover, .leaderboard, .howto, .settings {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  background: rgba(255, 248, 236, 0.6);
  backdrop-filter: blur(6px);
}
.celebration.show, .gameover.show, .leaderboard.show, .howto.show, .settings.show { opacity: 1; pointer-events: all; }

.celebration-content, .gameover-content, .leaderboard-content, .howto-content, .settings-content {
  background: #fff;
  border: 3px dashed var(--stitch);
  border-radius: 26px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 6px 0 var(--tray-edge), 0 16px 40px rgba(160,110,60,0.22);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 310px;
}

.big-emoji {
  font-size: 3.8rem;
  animation: floatBounce 1.1s ease-in-out infinite alternate;
}
@keyframes floatBounce {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-12px) scale(1.06); }
}

.celebration-content h2, .gameover-content h2, .leaderboard-content h2, .howto-content h2, .settings-content h2 {
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent);
}
.celebration-content p, .gameover-content p {
  color: var(--text-dark);
  font-size: 0.95rem;
  font-weight: 700;
}

.basket-art { width: 150px; height: 150px; display: block; }

.final-stats {
  display: grid;
  gap: 8px;
  width: min(100%, 250px);
  margin: 4px auto 6px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 2px dashed var(--stitch);
  text-align: left;
}
.stat-icon { width: 46px; height: 46px; flex: none; border-radius: 10px; display: block; }
.stat-star {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mustard);
  color: #fff;
  font-size: 24px;
  line-height: 1;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-family: var(--display);
  font-size: 1.25rem;
  line-height: 1.15;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  max-width: 9.5em;
}

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1; }

/* ── Hint ── */
.hint {
  margin-top: 14px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.2px;
}

/* ── Score bump ── */
.score-bump { animation: scoreBump 0.28s ease; }
@keyframes scoreBump {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.45); color: var(--accent); }
  100% { transform: scale(1); }
}

/* ── Spooky Picnic: moonlit night ─────────────────────────────────────────── */
html[data-skin="halloween"] {
  --text-dark: #F3E8FF;
  --accent: #FF8A2A;
  --accent-dark: #B8520C;
  --mustard: #8E6CD8;
  --mustard-dark: #5A3F94;
  --tray: #3A2D55;
  --tray-edge: #22183A;
  --muted: #BFA8E0;
  --stitch: #8E6CD8;
}
html[data-skin="halloween"] body {
  background-color: #1E1533;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 18%, #fff 60%, transparent),
    radial-gradient(1.4px 1.4px at 38% 8%, #fff 60%, transparent),
    radial-gradient(1.2px 1.2px at 64% 22%, #fff 60%, transparent),
    radial-gradient(1.3px 1.3px at 90% 12%, #fff 60%, transparent),
    radial-gradient(1.2px 1.2px at 6% 62%, #fff 60%, transparent),
    linear-gradient(170deg, #2E2052 0%, #171028 100%);
  background-size: auto;
}
html[data-skin="halloween"] h1 { font-size: clamp(1.6rem, 8.2vw, 2.1rem); }
html[data-skin="halloween"] .tile::before { color: #4A2A4C; }
html[data-skin="halloween"] .score-box { background: rgba(255, 255, 255, 0.08); }
html[data-skin="halloween"] .score-label { color: #FFB870; }
html[data-skin="halloween"] .score-value { color: #fff; }
html[data-skin="halloween"] .cell { background: rgba(255, 255, 255, 0.07); }
/* Header buttons: a pastel colour each, the same in both themes */
.controls .btn-icon { background: var(--b); box-shadow: 0 4px 0 var(--bd); }
.controls .btn-icon:active { box-shadow: 0 1px 0 var(--bd); }
#boardBtn    { --b: #FFE07A; --bd: #E3B547; }
#settingsBtn { --b: #FFB3CF; --bd: #E7859F; }
/* Spooky Picnic: richer Halloween-candy colours that suit the night sky */
html[data-skin="halloween"] #boardBtn    { --b: #FFA24A; --bd: #C9701E; }
html[data-skin="halloween"] #settingsBtn { --b: #B48CF0; --bd: #7A55C0; }
html[data-skin="halloween"] .controls .btn-icon svg { stroke: #3A2550; }
html[data-skin="halloween"] .controls .btn-icon svg [fill="#FFFDF8"] { fill: #FFF6E8; }
html[data-skin="halloween"] .celebration,
html[data-skin="halloween"] .gameover,
html[data-skin="halloween"] .leaderboard,
html[data-skin="halloween"] .howto,
html[data-skin="halloween"] .settings { background: rgba(20, 12, 40, 0.55); }
html[data-skin="halloween"] .celebration-content,
html[data-skin="halloween"] .gameover-content,
html[data-skin="halloween"] .leaderboard-content,
html[data-skin="halloween"] .howto-content,
html[data-skin="halloween"] .settings-content {
  background: #2C2148;
  border-color: #FF8A2A;
  box-shadow: 0 6px 0 #170F2A, 0 16px 40px rgba(0, 0, 0, 0.4);
}
html[data-skin="halloween"] .celebration-content p,
html[data-skin="halloween"] .gameover-content p { color: #F3E8FF; }
html[data-skin="halloween"] .stat { background: rgba(255, 255, 255, 0.08); }
html[data-skin="halloween"] .stat-label { color: #FFB870; }
html[data-skin="halloween"] .btn-secondary { color: #fff; }

/* ── Friends leaderboard ── */
.leaderboard-content { width: min(340px, calc(100vw - 32px)); max-width: none; padding: 26px 18px; gap: 12px; }
.lb-list { list-style: none; width: 100%; max-height: min(52vh, 460px); overflow-y: auto; display: grid; gap: 6px; padding: 2px; }
.lb-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px 9px 8px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.035);
  font-weight: 800; color: var(--text-dark);
}
.lb-list li.me { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.lb-rank { width: 1.6em; text-align: center; font-family: var(--display); color: var(--muted); }
.lb-list li:nth-child(1) .lb-rank, .lb-list li:nth-child(2) .lb-rank, .lb-list li:nth-child(3) .lb-rank { color: var(--accent); }
.lb-name { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-family: var(--display); font-variant-numeric: tabular-nums; color: var(--accent); }
.lb-note { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.lb-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-weight: 800; color: var(--accent); text-decoration: underline;
}
.lb-post { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; justify-items: center; width: min(100%, 250px); }
.lb-form { display: flex; gap: 6px; width: 100%; }
.lb-input {
  flex: 1; min-width: 0;
  -webkit-user-select: text; user-select: text;
  font: 700 16px var(--display, sans-serif);   /* 16px stops iPhone zooming in */
  padding: 8px 12px; border-radius: 14px;
  border: 2px dashed var(--stitch); background: rgba(255, 255, 255, 0.8); color: var(--text-dark);
}
.lb-save { padding: 8px 14px; white-space: nowrap; }
html[data-skin="halloween"] .lb-list li { background: rgba(255, 255, 255, 0.06); color: #F3E8FF; }
html[data-skin="halloween"] .lb-list li.me { background: rgba(255, 138, 42, 0.22); }
html[data-skin="halloween"] .lb-note { color: #BFA8E0; }
html[data-skin="halloween"] .lb-input { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* Very narrow phones: tighten the button row so all the buttons fit */
@media (max-width: 359px) {
  .controls .btn-icon { padding: 8px 11px; }
  #newGameBtn { padding: 8px 14px; }
}

/* ── How to play ── */
.hint-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-weight: 800; color: var(--accent); text-decoration: underline;
}
.howto-content { width: min(330px, calc(100vw - 32px)); max-width: none; padding: 26px 20px; gap: 12px; }
.steps { display: grid; gap: 10px; width: 100%; text-align: left; max-height: 62vh; overflow-y: auto; }
.step { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(0, 0, 0, 0.035); }
.step .num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font: 800 14px var(--display);
}
.step .txt { font-weight: 700; font-size: 0.92rem; line-height: 1.3; color: var(--text-dark); }
.step .txt b { font-family: var(--display); font-weight: 800; }
.pics { display: flex; align-items: center; gap: 4px; margin-top: 5px; font: 800 15px var(--display); color: var(--muted); }
.pics img { width: 34px; height: 34px; border-radius: 8px; }
.swipe-pic { margin-top: 4px; font: 900 18px var(--display); letter-spacing: 3px; color: var(--accent); }

/* First-game coach: a bubble and a little hand showing the swipe */
.coach { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.coach-bubble {
  position: absolute; left: 50%; top: 4%; transform: translateX(-50%);
  white-space: nowrap; padding: 8px 14px; border-radius: 16px;
  background: #fff; border: 2.5px dashed var(--stitch); box-shadow: 0 4px 0 var(--tray-edge);
  font: 800 clamp(13px, 3.9vw, 15px) var(--display); color: var(--text-dark);
}
.coach-bubble b { color: var(--accent); }
.coach-trail {
  position: absolute; left: 22%; width: 52%; top: 36%; height: 6px; border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 8px, transparent 8px 14px); opacity: 0.7;
}
.coach-hand { position: absolute; left: 50%; top: 34%; width: 15%; animation: coachSwipe 1.8s ease-in-out infinite; }
.coach-hand svg { width: 100%; display: block; }
@keyframes coachSwipe {
  0%   { transform: translateX(80%); opacity: 0; }
  15%  { opacity: 1; }
  70%  { transform: translateX(-160%); opacity: 1; }
  100% { transform: translateX(-160%); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .coach-hand { animation: none; } }
.board-wrapper { position: relative; }
.coach-toast {
  position: absolute; left: 50%; top: calc(100% + 10px); z-index: 6;
  transform: translate(-50%, 8px); opacity: 0; transition: opacity 0.3s, transform 0.3s;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 6px 14px 6px 6px; border-radius: 18px;
  background: #fff; border: 2.5px dashed var(--stitch); box-shadow: 0 4px 0 var(--tray-edge);
  font: 800 15px var(--display); color: var(--text-dark);
}
.coach-toast.show { opacity: 1; transform: translate(-50%, 0); }
.coach-toast img { width: 38px; height: 38px; border-radius: 9px; }
html[data-skin="halloween"] .coach-bubble,
html[data-skin="halloween"] .coach-toast { background: #2C2148; border-color: #FF8A2A; color: #F3E8FF; box-shadow: 0 4px 0 #170F2A; }
html[data-skin="halloween"] .step { background: rgba(255, 255, 255, 0.06); }
html[data-skin="halloween"] .step .txt { color: #F3E8FF; }

/* ── Settings ── */
.settings-content { width: min(330px, calc(100vw - 32px)); max-width: none; padding: 26px 20px; gap: 12px; }
.set-rows { display: grid; gap: 8px; width: 100%; }
.set-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px 8px 8px; border: none; border-radius: 14px; cursor: pointer;
  background: rgba(0, 0, 0, 0.035); color: var(--text-dark);
  font: 800 1rem var(--display); text-align: left;
}
.set-row:focus-visible, .theme-opt:focus-visible { outline: 3px solid var(--text-dark); outline-offset: 2px; }
.set-ico {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; background: var(--b);
}
.set-ico svg { width: 22px; height: 22px; display: block; }
#soundIco   { --b: #FFB3CF; }
#hapticsIco { --b: #AEE8D2; }
.set-label { flex: 1; }
/* An on/off switch: strawberry red when on */
.switch {
  flex: none; position: relative; width: 46px; height: 28px; border-radius: 14px;
  background: #E6D6C6; transition: background 0.2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.set-row[aria-checked="true"] .switch { background: var(--accent); }
.set-row[aria-checked="true"] .switch::after { transform: translateX(18px); }
.set-heading {
  align-self: flex-start; margin: 4px 0 -4px 4px;
  font: 800 0.72rem var(--display); letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
}
.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.theme-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border-radius: 14px; cursor: pointer;
  border: 3px solid transparent; background: rgba(0, 0, 0, 0.035);
  font: 800 0.88rem var(--display); color: var(--text-dark);
}
.theme-opt img { width: 54px; height: 54px; border-radius: 12px; display: block; }
.theme-opt[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
html[data-skin="halloween"] .set-row,
html[data-skin="halloween"] .theme-opt { background: rgba(255, 255, 255, 0.06); color: #F3E8FF; }
html[data-skin="halloween"] .theme-opt[aria-checked="true"] { background: rgba(255, 138, 42, 0.18); }
html[data-skin="halloween"] .switch { background: rgba(255, 255, 255, 0.18); }
html[data-skin="halloween"] #soundIco   { --b: #B48CF0; }
html[data-skin="halloween"] #hapticsIco { --b: #6FD3C2; }
html[data-skin="halloween"] .set-ico svg { stroke: #3A2550; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

/* "+4" that floats up from a tile (guided first game) */
.tile-points {
  position: absolute; z-index: 40; pointer-events: none; white-space: nowrap;
  font-family: var(--display); font-weight: 800;
  font-size: calc(var(--tile-size) * 0.24);
  color: var(--accent);
  -webkit-text-stroke: calc(var(--tile-size) * 0.035) #fff; paint-order: stroke fill;
  text-shadow: 0 2px 6px rgba(74, 42, 76, 0.25);
  animation: tilePoints 0.95s ease-out forwards;
}
@keyframes tilePoints {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  18%  { transform: translate(-50%, -70%) scale(1.1); opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translate(-50%, -150%) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  @keyframes tilePoints { 0%, 100% { opacity: 0; transform: translate(-50%, -70%); } 20%, 70% { opacity: 1; transform: translate(-50%, -70%); } }
}

/* Guided first game: bubble updates, score glow, mystery tile */
.coach.no-hand .coach-hand, .coach.no-hand .coach-trail { display: none; }
.coach-bubble.coach-new { animation: coachIn 0.35s ease-out; }
@keyframes coachIn { from { transform: translateX(-50%) scale(0.9); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.coach { transition: opacity 0.35s; }
.coach.coach-out { opacity: 0; }
.coach-bubble { display: flex; align-items: center; gap: 6px; }
.coach-q, .mystery-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(0, 0, 0, 0.05); border: 2px dashed var(--stitch);
  font: 800 15px var(--display); color: var(--accent);
}
.mystery-tile { width: 34px; height: 34px; border-radius: 8px; font-size: 18px; }
html[data-skin="halloween"] .coach-q, html[data-skin="halloween"] .mystery-tile { background: rgba(255, 255, 255, 0.08); }
.score-box.score-glow { animation: scoreGlow 1.4s ease-out; }
@keyframes scoreGlow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  25% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent); }
}
