/* Rock Pool styles. Same family as Riptide: fonts, colours and building blocks.
   Fonts are self-hosted (see fonts/). */

@font-face {
  font-family: 'Syne';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url('../fonts/syne.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/outfit.woff2') format('woff2');
}

:root {
  --abyss: #061014;
  --depth: #0e2c30;
  --trench: #03080c;
  --foam: #e8f6f3;
  --mist: #93b0b4;
  --tide: #2ee6c7;
  --flare: #ff5d3a;
  --sand: #f0c14d;
  --panel: rgba(12, 30, 33, 0.96);
  --line: rgba(232, 246, 243, 0.14);

  /* Reserved band at the top (as in Riptide) so a ~44px platform badge can
     never cover the game. Short landscape phones use the side layout instead. */
  --badge-reserve: 56px;
  --safe-top: calc(var(--badge-reserve) + env(safe-area-inset-top, 0px));
  --safe-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  --gutter: 16px;
  --pad: 12px;
  --display: 'Syne', 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (max-width: 359px) {
  :root { --gutter: 6px; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #040b0e;
  color: var(--foam);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 110%, rgba(14, 58, 60, 0.55), transparent 60%),
    radial-gradient(80% 60% at 50% -10%, rgba(14, 44, 48, 0.35), transparent 70%),
    #040b0e;
}

p, h1, h2, ol, dl { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--sand); outline-offset: 3px; }
button:disabled { cursor: default; opacity: 0.45; }

.nums { font-variant-numeric: tabular-nums; }
.noscript { position: fixed; inset: auto 0 20px; text-align: center; }

/* ---------- Layout ---------- */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  padding: var(--safe-top) max(var(--gutter), env(safe-area-inset-right, 0px)) var(--safe-bottom) max(var(--gutter), env(safe-area-inset-left, 0px));
}
.app.wide {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  column-gap: clamp(24px, 4vw, 72px);
}
.app.wide .stage { grid-column: 2; }
/* Short landscape phones: no top band, the board uses the full height. */
.app.split {
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
}

.rail { min-width: 0; display: none; }
.app.wide .rail { display: block; }
.rail-left { justify-self: end; }
.rail-right { justify-self: start; }
.rail-copy, .rail .rules { width: min(340px, 100%); }
.rail-left .rail-copy { margin-left: auto; }

.rail-title {
  margin: 10px 0 14px;
  font-family: var(--display);
  font-weight: 800;
  line-height: 1;
  color: var(--foam);
}
.rail .lede { color: var(--foam); opacity: 0.9; }

.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.rules li { display: grid; grid-template-columns: 10px 1fr; gap: 12px; align-items: start; color: var(--mist); font-size: 14px; line-height: 1.5; }
.rules strong { display: block; color: var(--foam); font-weight: 600; font-size: 15px; }
.pip { width: 9px; height: 9px; border-radius: 50%; background: var(--tide); margin-top: 6px; }
.pip.sand { background: var(--sand); }
.pip.flare { background: var(--flare); }

/* The stage is sized by JS (js/app.js, layout()). */
.stage {
  position: relative;
  width: min(420px, 100%);
  height: 100%;
  border-radius: 28px;
  overflow: hidden;
  background: var(--abyss);
  border: 1px solid rgba(147, 176, 180, 0.2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 6px rgba(46, 230, 199, 0.03);
  user-select: none;
  -webkit-user-select: none;
  container-type: inline-size;
}
.stage.compact { border-radius: 20px; }

/* ---------- Fit-to-width text (JS sets the exact size) ---------- */

.fit { white-space: nowrap; overflow: visible; }
.fit > span { display: inline-block; white-space: nowrap; }

/* ---------- Shared text + buttons ---------- */

.kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mist);
}
.lede { font-size: 15px; line-height: 1.5; font-weight: 500; }
.fine-print { font-size: 11.5px; line-height: 1.4; color: var(--mist); }

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(232, 246, 243, 0.22);
  background: rgba(6, 16, 20, 0.35);
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; }

.launch {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 999px;
  background: var(--tide);
  color: #03201b;
  font-family: var(--display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(46, 230, 199, 0.18);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.launch:hover { filter: brightness(1.06); }
.launch.long { font-size: 14px; letter-spacing: 0.08em; white-space: nowrap; padding: 0 12px; }
.launch:active { transform: scale(0.98); }
.launch .btn-main { display: block; line-height: 1.1; }
.launch .btn-sub { display: block; margin-top: 2px; font-family: var(--text); font-weight: 600; font-size: 12px; letter-spacing: 0.06em; text-transform: none; opacity: 0.85; }

.ghost {
  width: 100%;
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(232, 246, 243, 0.22);
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0 8px;
}
.ghost:hover { background: rgba(232, 246, 243, 0.05); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.text-btn {
  justify-self: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  background: transparent;
  color: var(--foam);
  font-weight: 600;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(232, 246, 243, 0.4);
}

/* ---------- Puzzle screen ---------- */

.play {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 44px 22px auto 20px 48px;
  grid-template-areas: "top" "meter" "board" "status" "controls";
  row-gap: 8px;
  align-content: center;
  padding: var(--pad);
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; min-width: 0; }
.titles { flex: 1; min-width: 0; text-align: center; }
.titles .kicker { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 17px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meter { grid-area: meter; display: flex; align-items: center; justify-content: center; gap: 14px; min-width: 0; white-space: nowrap; }
.meter-item { font-size: 13px; color: var(--mist); }
.meter-item strong { color: var(--foam); font-family: var(--display); font-weight: 800; font-size: 16px; margin-left: 3px; }
.meter-item.over strong { color: var(--sand); }
.meter-tag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  color: var(--tide);
}
.meter-tag.medium { color: var(--sand); }
.meter-tag.hard { color: var(--flare); }
.play.behind { visibility: hidden; }
.board-wrap { grid-area: board; display: grid; place-items: center; min-width: 0; min-height: 0; }
.status { grid-area: status; font-size: 13px; line-height: 20px; color: var(--mist); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.hint-on { color: var(--sand); font-weight: 600; }
.controls { grid-area: controls; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ctl {
  min-height: 48px;
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid rgba(232, 246, 243, 0.22);
  background: rgba(6, 16, 20, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 600;
  font-size: 14px;
  padding: 0 8px;
}
.ctl svg { width: 19px; height: 19px; flex: none; }
.ctl.hint { border-color: rgba(240, 193, 77, 0.55); color: var(--sand); background: rgba(240, 193, 77, 0.08); }
.ctl:not(:disabled):hover { background: rgba(232, 246, 243, 0.06); }

/* Side-by-side (short landscape phones): board on the left, panel on the right. */
.app.split .play {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 44px auto minmax(0, 1fr) auto 48px;
  grid-template-areas:
    "board top"
    "board meter"
    "board ."
    "board status"
    "board controls";
  align-content: stretch;
  column-gap: 12px;
  padding: 8px;
}
.app.split .controls { gap: 6px; }
.app.split .meter { flex-wrap: wrap; row-gap: 4px; column-gap: 12px; padding-top: 4px; }
.app.split .status { white-space: normal; line-height: 1.35; padding: 4px 0; }
.app.split .play-title { font-size: 15px; }
.app.split .topbar { gap: 6px; }
.app.split .ctl { flex-direction: column; gap: 1px; font-size: 11.5px; border-radius: 16px; }
.app.split .ctl svg { width: 17px; height: 17px; }

/* ---------- Board ---------- */

.board {
  position: relative;
  touch-action: none;
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}
.board .pool { position: absolute; inset: 0; display: block; }
.pieces { position: absolute; inset: 0; touch-action: none; }
.piece {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: calc(var(--cell, 40px) * 0.26);
  touch-action: none;
  cursor: grab;
  transition: transform 0.14s ease-out;
  will-change: transform;
}
.piece canvas { display: block; pointer-events: none; transition: transform 0.12s ease-out, filter 0.12s ease-out; }
.piece.h { cursor: ew-resize; }
.piece.v { cursor: ns-resize; }
.piece:focus { outline: none; }
.piece.dragging { transition: none; cursor: grabbing; z-index: 3; }
/* Drag feedback: the piece lifts (a little bigger, with a deeper shadow) and
   settles with a tiny bounce when let go. */
.piece.dragging canvas { transform: scale(1.06); filter: drop-shadow(0 calc(var(--cell, 40px) * 0.12) calc(var(--cell, 40px) * 0.1) rgba(0, 0, 0, 0.5)) brightness(1.06); }
.piece.settling { transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1); }
/* Selected: a thick light ring plus a dark halo, readable without colour. */
.piece.selected { box-shadow: 0 0 0 3px var(--foam), 0 0 0 6px rgba(3, 8, 12, 0.7); z-index: 2; }
.piece:focus-visible { box-shadow: 0 0 0 3px var(--sand), 0 0 0 6px rgba(3, 8, 12, 0.8); z-index: 2; }
.board.preview .piece { cursor: default; transition: none; }
.piece.bump canvas { animation: bump 0.2s ease; }
@keyframes bump { 30% { transform: scale(0.95); filter: brightness(1.3); } 70% { transform: scale(1.02); } }

/* Hint: the piece pulses with a dashed yellow ring; a dashed ghost shows where it goes. */
.piece.hinted { outline: 3px dashed var(--sand); outline-offset: 2px; z-index: 2; animation: hintpulse 0.8s ease-in-out infinite alternate; }
@keyframes hintpulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }
.hint-ghost {
  position: absolute;
  left: 0;
  top: 0;
  border: 3px dashed var(--sand);
  border-radius: calc(var(--cell, 40px) * 0.26);
  background: rgba(240, 193, 77, 0.16);
  pointer-events: none;
  display: grid;
  place-items: center;
  z-index: 1;
}
.hint-ghost::after {
  content: '';
  width: calc(var(--cell, 40px) * 0.34);
  height: calc(var(--cell, 40px) * 0.34);
  border-top: 4px solid var(--sand);
  border-right: 4px solid var(--sand);
  transform: rotate(45deg);
}
.hint-ghost[data-dir="left"]::after { transform: rotate(-135deg); }
.hint-ghost[data-dir="up"]::after { transform: rotate(-45deg); }
.hint-ghost[data-dir="down"]::after { transform: rotate(135deg); }

/* Solved: a happy hop, then a scuttle out through the gap into the sea. */
.piece.happy canvas { animation: hop 0.2s ease-out 2 alternate; }
@keyframes hop { from { transform: translateY(0) rotate(0); } to { transform: translateY(-18%) rotate(-5deg); } }
.piece.leaving { transition: transform 0.45s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.2s ease-in 0.32s; opacity: 0; }
.piece.leaving canvas { animation: scuttle 0.08s linear infinite alternate; }
@keyframes scuttle { from { transform: rotate(-7deg) translateY(-4%); } to { transform: rotate(7deg) translateY(4%); } }
.piece.gone { opacity: 0; transition: opacity 0.25s linear; }

/* ---------- Water, tide and surf (decorative CSS layers over the pool canvas) ---------- */

.water { position: absolute; overflow: hidden; pointer-events: none; }
.shimmer {
  position: absolute;
  inset: -40%;
  background-image:
    radial-gradient(ellipse 9% 4% at 20% 30%, rgba(232, 255, 250, 0.16), transparent 70%),
    radial-gradient(ellipse 7% 3% at 65% 18%, rgba(232, 255, 250, 0.13), transparent 70%),
    radial-gradient(ellipse 10% 4% at 45% 62%, rgba(232, 255, 250, 0.12), transparent 70%),
    radial-gradient(ellipse 6% 3% at 82% 75%, rgba(232, 255, 250, 0.14), transparent 70%),
    radial-gradient(ellipse 8% 3% at 12% 82%, rgba(232, 255, 250, 0.1), transparent 70%);
  background-size: 50% 50%;
  animation: drift 18s ease-in-out infinite alternate;
}
.shimmer.two { background-size: 37% 41%; opacity: 0.8; animation: drift2 23s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(0, 0) rotate(0deg); } to { transform: translate(6%, 4%) rotate(3deg); } }
@keyframes drift2 { from { transform: translate(3%, 5%) rotate(2deg); } to { transform: translate(-4%, -2%) rotate(-2deg); } }
/* The tide going out: the wet edge just inside the rim slowly grows, then eases back. */
.tideline {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 calc(var(--cell, 40px) * 0.1) calc(var(--cell, 40px) * 0.02) rgba(214, 190, 140, 0.25);
  animation: tide 9s ease-in-out infinite alternate;
}
@keyframes tide {
  to { box-shadow: inset 0 0 calc(var(--cell, 40px) * 0.35) calc(var(--cell, 40px) * 0.1) rgba(214, 190, 140, 0.3); }
}
/* Surf in the gap: little foam crests slipping out to sea. */
.surf {
  position: absolute;
  overflow: hidden;
  pointer-events: none;
  background-image: radial-gradient(ellipse 60% 48% at 0% 50%, transparent 62%, rgba(232, 246, 243, 0.8) 66%, transparent 74%);
  background-size: calc(var(--cell, 40px) * 0.42) 100%;
  animation: surf 2.4s linear infinite;
}
@keyframes surf { to { background-position: calc(var(--cell, 40px) * 0.42) 0; } }
.board.freed .surf { animation-duration: 0.9s; }

/* Drag: the track the piece can slide along, and where it will land. */
.lane, .snap { position: absolute; left: 0; top: 0; pointer-events: none; border-radius: calc(var(--cell, 40px) * 0.26); }
.lane { background: rgba(232, 246, 243, 0.06); border: 2px dashed rgba(232, 246, 243, 0.3); }
.snap { border: 2px solid rgba(46, 230, 199, 0.75); background: rgba(46, 230, 199, 0.12); }

/* Celebration: splash rings, bubbles and confetti at the gap. */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.fx i { position: absolute; display: block; }
.splash-ring {
  width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  border: 3px solid rgba(232, 246, 243, 0.85); border-radius: 50%;
  animation: ring 0.7s ease-out var(--d) both;
}
@keyframes ring { from { transform: scale(0.2); opacity: 1; } to { transform: scale(1); opacity: 0; } }
.bubble {
  width: calc(var(--r) * 2); height: calc(var(--r) * 2); margin: calc(var(--r) * -1) 0 0 calc(var(--r) * -1);
  border-radius: 50%; border: 2px solid rgba(232, 246, 243, 0.8);
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.7), rgba(46, 230, 199, 0.15) 60%);
  animation: rise 1.3s ease-out var(--d) both;
}
@keyframes rise { from { transform: translate(0, 0) scale(0.5); opacity: 0; } 15% { opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; } }
.confetti {
  width: calc(var(--cell, 40px) * 0.12); height: calc(var(--cell, 40px) * 0.22); border-radius: 2px; background: var(--c);
  animation: burst 1.4s cubic-bezier(0.2, 0.7, 0.4, 1) var(--d) both;
}
@keyframes burst {
  from { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  60% { transform: translate(var(--dx), var(--dy)) rotate(calc(var(--rot) * 0.6)); opacity: 1; }
  to { transform: translate(var(--dx), calc(var(--dy) + var(--fall))) rotate(var(--rot)); opacity: 0; }
}

/* ---------- Sheets ---------- */

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 18px 20px;
  background: linear-gradient(180deg, rgba(14, 34, 38, 0.97), rgba(9, 24, 27, 0.99));
  border-top: 1px solid var(--line);
  z-index: 3;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet.cover { top: 0; border-top: 0; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-title { font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1.15; margin-top: 2px; }

.title-head { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; min-height: 0; }
.title-actions { display: grid; gap: 10px; }
.wordmark {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 800;
  line-height: 1;
  color: var(--foam);
}
.hero { flex: 1 1 0; min-height: 0; position: relative; }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.high { font-size: 13px; color: var(--mist); }
.high strong { color: var(--sand); font-weight: 700; }
.sheet-foot { text-align: center; font-size: 11.5px; color: var(--mist); opacity: 0.9; line-height: 1.2; margin: -6px 0; }
.foot-link {
  font-size: inherit;
  color: var(--mist);
  text-decoration: underline;
  text-underline-offset: 3px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  padding: 0 3px;
}
.foot-link:hover, .foot-link:focus-visible { color: var(--foam); }
.foot-link:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }
.save-note { text-align: center; }

/* Practice tiers */
.tier-list { display: grid; gap: 10px; }
.tier-btn {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 16px;
  border-radius: 18px;
  border: 1px solid rgba(232, 246, 243, 0.2);
  background: rgba(3, 8, 12, 0.45);
  text-align: left;
}
.tier-btn:hover { background: rgba(232, 246, 243, 0.05); }
.tier-btn .pip { margin: 0; width: 12px; height: 12px; }
.tier-btn .pip.square { border-radius: 2px; }
.tier-btn .pip.diamond { border-radius: 1px; transform: rotate(45deg); width: 10px; height: 10px; }
.tier-name { font-family: var(--display); font-weight: 800; font-size: 18px; display: block; }
.tier-note { font-size: 12.5px; color: var(--mist); display: block; margin-top: 2px; }
.tier-count { font-size: 12.5px; color: var(--mist); text-align: right; }
.tier-count strong { display: block; color: var(--sand); font-family: var(--display); font-size: 16px; }

/* Last 7 days */
.week-list { display: grid; gap: 8px; }
.day-btn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 14px;
  border-radius: 14px;
  border: 1px solid rgba(232, 246, 243, 0.18);
  background: rgba(3, 8, 12, 0.45);
  text-align: left;
}
.day-btn:hover { background: rgba(232, 246, 243, 0.05); }
.day-name { font-weight: 700; font-size: 14.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-tier { font-size: 12px; color: var(--mist); display: block; }
.day-state { font-size: 12.5px; color: var(--mist); white-space: nowrap; display: flex; align-items: center; gap: 2px; }
.day-state.done { color: var(--sand); }
.mini-star { width: 15px; height: 15px; }

/* Solved */
.solved-main { display: flex; flex-direction: column; gap: 12px; }
.stars { display: flex; justify-content: center; gap: 10px; }
.stars svg { width: 44px; height: 44px; }
.star-on { fill: var(--sand); stroke: #7a5a12; }
.star-off { fill: none; stroke: rgba(232, 246, 243, 0.4); stroke-dasharray: 3 3; }
.stars .pop { animation: starpop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.stars .pop:nth-child(1) { animation-delay: 0.15s; }
.stars .pop:nth-child(2) { animation-delay: 0.4s; }
.stars .pop:nth-child(3) { animation-delay: 0.65s; }
@keyframes starpop { from { transform: scale(0.3) rotate(-30deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.sheet.solved.enter { animation: sheetup 0.32s ease-out both; }
@keyframes sheetup { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }
/* One mute button on the solved screen: in the stacked layout the puzzle header
   (with its mute) stays visible above the sheet, so the sheet's own is hidden. */
.app:not(.split) .solved-mute { display: none; }
.app:not(.split) #solved-sheet { max-height: calc(100% - var(--pad) - 52px); }
.mark {
  text-align: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sand);
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats > div {
  min-width: 0;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(3, 8, 12, 0.55);
  border: 1px solid rgba(232, 246, 243, 0.06);
  text-align: center;
}
.stats dt { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mist); }
.stats dd { margin: 4px 0 0; font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1.2; }
.actions { display: grid; gap: 10px; }

/* Split layout: sheets cover the stage in two columns. */
.app.split .sheet { top: 0; border-top: 0; padding: 12px 16px; gap: 8px; }
.app.split #title-sheet,
.app.split #solved-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  column-gap: 18px;
  align-items: center;
}
.app.split #title-sheet[hidden],
.app.split #solved-sheet[hidden] { display: none !important; }
.app.split .title-head { gap: 6px; }
.app.split .title-actions { gap: 8px; }
.app.split .launch { min-height: 48px; }
/* Side layout: the four footer links stay on one line (at 568x320 a second line would push the sheet past the stage). */
.app.split .sheet-foot { white-space: nowrap; font-size: 11px; }
.app.split .sheet-foot .foot-link { padding: 0 1px; }
.app.split .ghost { min-height: 44px; }
.app.split .lede { font-size: 13.5px; line-height: 1.4; }
.app.split .solved-main { gap: 6px; }
.app.split .stars svg { width: 34px; height: 34px; }
.app.split .stats > div { padding: 5px 6px; }
.app.split .stats dd { font-size: 16px; margin-top: 1px; }
.app.split .week-list { grid-template-columns: 1fr 1fr; gap: 6px; }
.app.split .day-btn { min-height: 44px; padding: 3px 10px; }
.app.split .tier-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.app.split .tier-btn { grid-template-columns: 12px 1fr; min-height: 88px; }
.app.split .tier-count { grid-column: 1 / -1; text-align: left; }
.app.split .tier-count strong { display: inline; margin-right: 4px; }

/* ---------- Modal (How to play) ---------- */

.modal {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  align-items: safe center;
  padding: 14px;
  overflow-y: auto;
  background: rgba(3, 8, 12, 0.72);
  backdrop-filter: blur(3px);
}
.card {
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 12px;
  padding: 20px 18px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid rgba(46, 230, 199, 0.35);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.card-title { font-family: var(--display); font-weight: 800; font-size: 21px; line-height: 1.15; }
.card .rules { gap: 12px; }
.app.split .card { max-width: 560px; padding: 14px 16px; gap: 8px; }
.app.split .card .rules { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.app.split .card .rules li { font-size: 12.5px; line-height: 1.4; }

.toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 8;
  pointer-events: none;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(9, 24, 27, 0.96);
  border: 1px solid rgba(46, 230, 199, 0.5);
  color: var(--foam);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ---------- Title minor row ---------- */

.minor-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 12px; }
/* ---------- Modal cards ---------- */

.modal { overflow-x: hidden; }
.modal > .card { min-width: 0; max-width: min(420px, 100%); }
.card-copy { font-size: 14.5px; line-height: 1.5; }
.card .foot-link { min-height: 44px; }

/* ---------- Small / short screens ---------- */

@container (max-width: 340px) {
  .meter { gap: 10px; }
  .meter-item { font-size: 12px; }
  .sheet { padding: 14px 12px 16px; gap: 10px; }
  .lede { font-size: 14px; }
  .ghost { letter-spacing: 0.06em; font-size: 13px; }
  .ctl { font-size: 13px; gap: 5px; }
  .week-list { gap: 5px; }
  .day-btn { min-height: 44px; padding: 3px 12px; }
}
@media (max-height: 700px) {
  .sheet { gap: 9px; padding: 14px 14px 16px; }
  .launch { min-height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .launch, .piece, .piece.leaving, .piece.settling, .piece canvas { transition: none; }
  .piece.hinted, .piece.bump canvas, .piece.happy canvas, .piece.leaving canvas, .stars .pop, .sheet.solved.enter,
  .shimmer, .tideline, .surf, .fx i { animation: none; }
  .piece.dragging canvas { transform: none; }
  .fx { display: none; }
}

/* Read by screen readers, not shown (used for the hint's "N moves to go" tail on narrow phones). */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Audio: music credit (CC-BY) on the title, credits card, ?audiodebug readout */
.music-credit { display: block; margin: 6px 0 0; font-size: 9.5px; line-height: 1.3; opacity: .85; white-space: normal; overflow-wrap: anywhere; }

.credits-link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.card.credits .fine-print { overflow-wrap: anywhere; text-align: left; }
.audio-debug { position: fixed; left: 6px; top: 6px; z-index: 2001; font: 11px/1.3 ui-monospace, monospace; color: #fff; background: rgba(0,0,0,.6); padding: 3px 6px; border-radius: 4px; pointer-events: none; }
/* Make room for the music credit so the title hero keeps its height */
#title-sheet .title-head, #title-sheet .title-actions { gap: 7px; }
.mc-short { display: none; }
/* Very short screens (e.g. 320x568, phone landscape): a shorter credit here, the full line in Credits */
@media (max-height: 600px) {
  .mc-full { display: none; }
  .mc-short { display: inline; }
  .music-credit { margin-top: 2px; }
}
.app.split .music-credit { white-space: normal; }
/* Short landscape: the credit sits under the streak row in the left column, where there's room */
@media (max-height: 600px) {
  .app.split .music-credit { position: absolute; left: 16px; bottom: 12px; width: calc(50% - 24px); margin: 0; text-align: left; }
}

/* ---------- Phones: full-screen play (any size, any orientation) ----------
   No floating card: the stage covers the whole display and its background
   runs under the notch and home bar. Content is inset by the safe areas
   only, and the board is sized by JS to the largest square that fits. */
html.phone-full body { background: var(--abyss); }
html.phone-full .app,
html.phone-full .app.split {
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  grid-template-columns: minmax(0, 1fr);
}
html.phone-full .rail { display: none !important; }
html.phone-full .stage {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  max-width: none;
}

/* ---------- iOS app: shop, grown-up check, privacy card, Starter lock ---------- */
.gate-modal { z-index: 9; }
.gate-label { font-size: 14.5px; line-height: 1.5; text-align: center; }
.gate-input {
  justify-self: center;
  width: 150px;
  min-height: 48px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(232, 246, 243, 0.4);
  background: rgba(3, 8, 12, 0.5);
  color: var(--foam);
  font: 700 22px var(--text);
  text-align: center;
  letter-spacing: 0.12em;
  -webkit-user-select: text;
  user-select: text;
}
.gate-input:focus { outline: 2px solid var(--sand); outline-offset: 2px; }
.shop-list { display: grid; gap: 10px; }
.shop-list .launch { letter-spacing: 0.08em; font-size: 15px; }
.shop-list .launch:disabled { opacity: 0.6; filter: saturate(0.6); }
.shop-err { font-size: 13.5px; line-height: 1.4; color: var(--coral, #ff7a4a); }
.shop-err.good { color: var(--tide); }
.owned-note { font-size: 13px; color: var(--sand); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.restore-msg { text-align: center; }
.tier-btn.locked { opacity: 0.82; border-style: dashed; }
.tier-lock strong { font-size: 18px; }
.tier-lock-note { margin-top: 12px; text-align: center; }
.tier-shop { margin-top: 10px; }
button.foot-link { background: none; border: 0; padding: 0 3px; font: inherit; cursor: pointer; }
@media (max-height: 420px) {
  #privacy .card, #shop .card, #gate .card { gap: 6px; padding: 12px 16px; }
  #privacy .card .card-copy, #gate .card .card-copy { font-size: 13px; line-height: 1.35; }
  #privacy .card .fine-print, #shop .card .fine-print { font-size: 11px; line-height: 1.3; }
  #privacy .card .launch, #privacy .card .ghost { min-height: 44px; }
}

/* Mac (mouse/trackpad): a gentle hover glow on pieces you can drag. Touch screens never see it. */
@media (hover: hover) and (pointer: fine) {
  .board:not(.preview) .piece:not(.dragging):not(.leaving):hover canvas { filter: brightness(1.1); }
}
