/*! © 2026 LogosVox. All rights reserved. Copying, modifying or redistributing this code is not permitted. https://games.logosvox.com/terms */
/*
 * LogosVox game kit: the page around the open-source games we forked
 * (games/<id>/public). The tokens (--lv-*), the top bar, sheets, theme and
 * safe areas are the shared shell's (packages/shell/src/shell.css, linked
 * before this file as /<id>/kit/lv-shell.css). This adds the page, buttons,
 * score chips, the d-pad, overlays and toasts.
 * Copied into each game that links it, as /<id>/kit/lv-kit.css, by scripts/games.mjs.
 */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/*
 * One screen while playing: the page is exactly the visible viewport
 * (--lv-vvh, set by lv-kit.js from visualViewport; dvh before it runs), and
 * never scrolls, bounces or zooms. A game's board fits inside (.lv-stage).
 */
html.lv-kit { overflow: hidden; overscroll-behavior: none; }
html.lv-kit body { height: var(--lv-vvh, 100dvh); min-height: 0; overflow: hidden; }
body {
  background: var(--lv-void);
  color: var(--lv-ink);
  font-family: var(--lv-font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  /* Top and sides: the shell's bar and .lv-main keep clear of notches. */
  padding: 0 0 env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lv-cobalt); outline-offset: 2px; }

/* Score chips, in the shell's bar (LVShell.slot()). */
.lv-chips { display: flex; gap: 6px; flex: none; }
.lv-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  padding: 3px 8px;
  border-radius: var(--lv-radius);
  background: var(--lv-surface);
  border: 1px solid var(--lv-edge);
}
.lv-chip b { font-size: 15px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.lv-chip small { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--lv-ink-subtle); line-height: 1.2; }

.lv-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.lv-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.lv-hint { color: var(--lv-ink-subtle); font-size: 13px; text-align: center; margin: 0; }

.lv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--lv-radius);
  border: 1px solid var(--lv-edge-strong);
  background: var(--lv-void);
  color: var(--lv-ink);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background var(--lv-fast) var(--lv-ease), transform var(--lv-fast) var(--lv-ease);
  user-select: none;
}
.lv-btn:hover { background: var(--lv-surface-hover); }
.lv-btn:active { transform: scale(0.97); background: var(--lv-surface-active); }
.lv-btn--primary { background: var(--lv-ink); color: var(--lv-void); border-color: var(--lv-ink); }
.lv-btn--primary:hover { background: var(--lv-ink); opacity: 0.9; }
.lv-btn[aria-pressed="true"] { background: var(--lv-ink); color: var(--lv-void); border-color: var(--lv-ink); }
.lv-btn:disabled { opacity: 0.4; cursor: default; }

.lv-seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: var(--lv-radius); background: var(--lv-surface); border: 1px solid var(--lv-edge); }
.lv-seg button { border: 0; background: transparent; min-height: 44px; padding: 0 12px; border-radius: 0.55rem; font-size: 14px; font-weight: 600; color: var(--lv-ink-muted); cursor: pointer; }
.lv-seg button[aria-pressed="true"] { background: var(--lv-void); color: var(--lv-ink); box-shadow: 0 1px 2px rgb(13 13 13 / 0.12); }

/* The d-pad for games played with arrows. */
.lv-pad { display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: repeat(2, 52px); gap: 6px; justify-content: center; user-select: none; }
.lv-pad button { border-radius: var(--lv-radius); border: 1px solid var(--lv-edge-strong); background: var(--lv-surface); font-size: 22px; cursor: pointer; touch-action: none; }
.lv-pad button:active, .lv-pad button.is-down { background: var(--lv-surface-active); }
.lv-pad [data-dir="up"] { grid-column: 2; grid-row: 1; }
.lv-pad [data-dir="left"] { grid-column: 1; grid-row: 2; }
.lv-pad [data-dir="down"] { grid-column: 2; grid-row: 2; }
.lv-pad [data-dir="right"] { grid-column: 3; grid-row: 2; }
.lv-pad [data-dir="extra"] { grid-column: 3; grid-row: 1; font-size: 18px; }
@media (hover: hover) and (pointer: fine) { .lv-touch-only { display: none !important; } }

.lv-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(13 13 13 / 0.32);
  backdrop-filter: blur(4px);
  z-index: 50;
  animation: lv-fade var(--lv-base) var(--lv-ease);
}
.lv-card {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  border-radius: var(--lv-radius-card);
  background: var(--lv-void);
  border: 1px solid var(--lv-edge);
  box-shadow: var(--lv-shadow);
  text-align: center;
  animation: lv-rise var(--lv-base) var(--lv-ease);
}
.lv-card h2 { font-family: var(--lv-display); font-size: 24px; margin: 0 0 8px; letter-spacing: -0.01em; }
.lv-card p { color: var(--lv-ink-muted); margin: 0 0 20px; }
.lv-card .lv-row { flex-direction: column; align-items: stretch; }
.lv-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--lv-ink);
  color: var(--lv-void);
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  animation: lv-rise var(--lv-base) var(--lv-ease);
  max-width: calc(100vw - 32px);
  text-align: center;
}
@keyframes lv-fade { from { opacity: 0; } }
@keyframes lv-rise { from { opacity: 0; transform: translateY(8px); } }
.lv-toast { animation-name: lv-toast; }
@keyframes lv-toast { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/*
 * The height a board may use: the viewport, less the shell's bar beyond the
 * 56 px the games' sizes were drawn for (on phones the chips take a second row).
 */
:root { --lv-avail: calc(var(--lv-vvh, 100dvh) - var(--lv-shell-h, 56px) + 56px); }
@media (max-width: 719.98px) {
  .lv-shell-slot .lv-chip { flex-direction: row; align-items: baseline; gap: 6px; min-width: 0; padding: 3px 10px; }
  .lv-shell-slot .lv-chips { gap: 6px; flex-wrap: wrap; justify-content: center; }
}

/* ======================================================================
 * The LogosVox Games board style, shared by every game made ours.
 * One language for all eight: a tray (.lv-board) holding wells (.lv-well)
 * and pieces (.lv-piece) that look like soft keycaps: lit from above, a
 * darker lip below, our aurora colours tuned for light and dark. Canvas
 * games draw the same piece with LV.drawPiece() and read the same colours
 * with LV.palette(). Numbers are tabular and heavy, in the display face.
 * ====================================================================== */
:root {
  --lv-g-tray: #eceef3;
  --lv-g-tray-edge: rgb(13 13 13 / 0.07);
  --lv-g-well: rgb(255 255 255 / 0.72);
  --lv-g-well-shade: rgb(13 13 13 / 0.06);
  --lv-g-violet: #8c14fc;
  --lv-g-cobalt: #2a4bff;
  --lv-g-cyan: #00a9cc;
  --lv-g-magenta: #f0287f;
  --lv-g-gold: #f2a114;
  --lv-g-green: #0fae7a;
  --lv-g-coral: #ff6340;
  --lv-g-on: #ffffff;
  --lv-g-lift: 0 1px 2px rgb(13 13 13 / 0.08), 0 14px 32px -20px rgb(13 13 13 / 0.35);
  --lv-g-glow: rgb(255 255 255 / 0.9);
  --lv-g-piece-r: 0.6rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --lv-g-tray: #1e1f25;
    --lv-g-tray-edge: rgb(255 255 255 / 0.07);
    --lv-g-well: rgb(255 255 255 / 0.045);
    --lv-g-well-shade: rgb(0 0 0 / 0.35);
    --lv-g-violet: #a24bff;
    --lv-g-cobalt: #5573ff;
    --lv-g-cyan: #19c6e6;
    --lv-g-magenta: #ff4c9b;
    --lv-g-gold: #ffb733;
    --lv-g-green: #2fcf93;
    --lv-g-coral: #ff7a5c;
    --lv-g-lift: 0 1px 2px rgb(0 0 0 / 0.4), 0 18px 40px -22px rgb(0 0 0 / 0.8);
    --lv-g-glow: rgb(255 255 255 / 0.12);
  }
}
:root[data-theme="dark"] {
  --lv-g-tray: #1e1f25;
  --lv-g-tray-edge: rgb(255 255 255 / 0.07);
  --lv-g-well: rgb(255 255 255 / 0.045);
  --lv-g-well-shade: rgb(0 0 0 / 0.35);
  --lv-g-violet: #a24bff;
  --lv-g-cobalt: #5573ff;
  --lv-g-cyan: #19c6e6;
  --lv-g-magenta: #ff4c9b;
  --lv-g-gold: #ffb733;
  --lv-g-green: #2fcf93;
  --lv-g-coral: #ff7a5c;
  --lv-g-lift: 0 1px 2px rgb(0 0 0 / 0.4), 0 18px 40px -22px rgb(0 0 0 / 0.8);
  --lv-g-glow: rgb(255 255 255 / 0.12);
}

/* The tray: every board sits in one. Touch on it never scrolls, zooms or selects. */
.lv-board {
  position: relative;
  background: var(--lv-g-tray);
  border: 1px solid var(--lv-g-tray-edge);
  border-radius: var(--lv-radius-card);
  box-shadow: inset 0 1px 0 var(--lv-g-glow), var(--lv-g-lift);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* A well: an empty place on the board, pressed in. */
.lv-well {
  background: var(--lv-g-well);
  border-radius: var(--lv-g-piece-r);
  box-shadow: inset 0 1px 2px var(--lv-g-well-shade);
}
/* A piece: a soft keycap in one colour (--c). */
.lv-piece {
  --c: var(--lv-g-violet);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.28), rgb(255 255 255 / 0) 46%), var(--c);
  color: var(--lv-g-on);
  border-radius: var(--lv-g-piece-r);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.35), inset 0 -0.18em 0 rgb(0 0 0 / 0.16), 0 1px 2px rgb(13 13 13 / 0.18);
}
.lv-c-violet { --c: var(--lv-g-violet); }
.lv-c-cobalt { --c: var(--lv-g-cobalt); }
.lv-c-cyan { --c: var(--lv-g-cyan); }
.lv-c-magenta { --c: var(--lv-g-magenta); }
.lv-c-gold { --c: var(--lv-g-gold); }
.lv-c-green { --c: var(--lv-g-green); }
.lv-c-coral { --c: var(--lv-g-coral); }
.lv-num { font-family: var(--lv-display); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* A row of tools under or beside a board: undo, new game, pause, hints (LV.tool()). */
.lv-tools { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.lv-tool {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 60px;
  min-height: 52px;
  padding: 4px 10px;
  border: 1px solid var(--lv-edge);
  border-radius: var(--lv-radius);
  background: var(--lv-void-raised);
  color: var(--lv-ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background var(--lv-fast) var(--lv-ease), transform var(--lv-fast) var(--lv-ease);
}
.lv-tool svg { width: 20px; height: 20px; flex: none; }
.lv-tool:hover { background: var(--lv-surface-hover); }
.lv-tool:active { transform: scale(0.95); background: var(--lv-surface-active); }
.lv-tool[aria-pressed="true"] { background: var(--lv-ink); color: var(--lv-void); border-color: var(--lv-ink); }
.lv-tool:disabled { opacity: 0.38; cursor: default; transform: none; }

/* Keyboard controls (LV.keys()), shown with a mouse and keyboard only. */
.lv-keys { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--lv-ink-subtle); }
.lv-keys li { display: inline-flex; align-items: center; gap: 4px; }
.lv-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid var(--lv-edge-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--lv-void-raised);
  color: var(--lv-ink);
  font: 600 11px/1 var(--lv-font);
}
@media not ((hover: hover) and (pointer: fine)) { .lv-desktop-only { display: none !important; } }

/* The game's screens (start, pause, win, lose): LV.screen(). */
.lv-card { position: relative; overflow: hidden; }
.lv-card .lv-screen-icon { width: 64px; height: 64px; margin: 0 auto 12px; display: block; }
.lv-card .lv-screen-icon img { width: 100%; height: 100%; display: block; }
.lv-card .lv-kicker { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--lv-ink-subtle); }
.lv-card[data-tone="win"] .lv-kicker { color: var(--lv-g-green); }
.lv-card[data-tone="lose"] .lv-kicker { color: var(--lv-g-coral); }
.lv-stats { display: flex; justify-content: center; gap: 8px; margin: 0 0 20px; padding: 0; }
.lv-stats div { flex: 1; max-width: 120px; padding: 8px 6px; border-radius: var(--lv-radius); background: var(--lv-surface); border: 1px solid var(--lv-edge); }
.lv-stats dt { font-size: 11px; color: var(--lv-ink-subtle); text-transform: uppercase; letter-spacing: 0.06em; }
.lv-stats dd { margin: 2px 0 0; font: 700 20px/1.2 var(--lv-display); font-variant-numeric: tabular-nums; }
.lv-stats .is-best dd { color: var(--lv-g-gold); }
.lv-card .lv-choice { margin: 0 0 16px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.lv-card .lv-choice small { font-size: 12px; color: var(--lv-ink-subtle); }
.lv-card .lv-choice .lv-seg { display: flex; }
.lv-card .lv-choice .lv-seg button { flex: 1; }
.lv-card .lv-keys { margin: -6px 0 18px; }

/* Small, cheap feedback: a pop, a shake, a sparkle burst (LV.burst). Off with reduced motion. */
@keyframes lv-pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes lv-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes lv-spark { from { transform: translate(-50%, -50%) scale(1); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2); opacity: 0; } }
.lv-anim-pop { animation: lv-pop 220ms var(--lv-ease) both; }
.lv-anim-shake { animation: lv-shake 320ms ease-in-out; }
.lv-spark { position: fixed; z-index: 70; width: 7px; height: 7px; border-radius: 50%; pointer-events: none; animation: lv-spark 520ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards; }
@media (prefers-reduced-motion: reduce) { .lv-anim-pop, .lv-anim-shake { animation: none; } .lv-spark { display: none; } }
:root[data-motion="reduce"] .lv-spark { display: none; }

/* Phones held sideways: the board beside its controls, for a game that opts in (.lv-main--split, .lv-side). */
@media (orientation: landscape) and (max-height: 540px) {
  .lv-main--split { flex-direction: row; max-width: none; gap: 16px; }
  .lv-main--split > .lv-side { display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; }
}

/* ======================================================================
 * Phones: the board as large as the screen allows, gestures on it, and
 * on-screen buttons only when the player asks for them.
 * ====================================================================== */

/*
 * The stage: the space a board may use (it takes what the rows above and
 * below leave). A board in it with .lv-fit and --ar (columns / rows, as a
 * number) is the largest box of that shape that fits, centred:
 *   <div class="lv-stage"><div class="lv-board lv-fit" style="--ar: 1">…</div></div>
 */
.lv-stage {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  touch-action: none;
  overscroll-behavior: none;
}
.lv-fit {
  --ar: 1;
  width: min(100cqw, 100cqh * var(--ar));
  height: min(100cqh, 100cqw / var(--ar));
}

/* On-screen buttons: hidden unless "Show buttons" is on (and never with a mouse). */
:root:not([data-lv-buttons="on"]) .lv-buttons { display: none !important; }
@media (hover: hover) and (pointer: fine) { .lv-buttons { display: none !important; } }

/* The game menu's button, after the chips in the bar. */
.lv-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 36px;
  margin: 0 -4px 0 0;
  padding: 0;
  border: 1px solid var(--lv-edge);
  border-radius: 999px;
  background: var(--lv-surface);
  color: var(--lv-ink);
  cursor: pointer;
  transition: background var(--lv-fast) var(--lv-ease);
}
.lv-menu-btn svg { width: 20px; height: 20px; }
.lv-menu-btn:hover { background: var(--lv-surface-hover); }
.lv-menu-btn:active { background: var(--lv-surface-active); }
.lv-shell-item > svg { width: 20px; height: 20px; flex: none; }
.lv-menu-how h3, .lv-menu-about h3 { margin: 0 0 4px; font: 600 13px/1.3 var(--lv-font); color: var(--lv-ink-subtle); text-transform: uppercase; letter-spacing: 0.06em; }
.lv-menu-how p, .lv-menu-about p { margin: 0; color: var(--lv-ink-muted); font-size: 14px; line-height: 1.5; }
.lv-menu-how .lv-keys { justify-content: flex-start; margin-top: 10px; }
.lv-menu-about { padding-top: 12px; border-top: 1px solid var(--lv-edge); }
.lv-menu-about a { color: var(--lv-ink); text-underline-offset: 3px; }
.lv-menu-about .lv-menu-credits { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 600; }

/* The gesture tip, once, on first play (LV.hint). */
.lv-tip {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 55;
  width: min(300px, calc(100vw - 48px));
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-radius: var(--lv-radius-card);
  background: var(--lv-void-overlay, var(--lv-void));
  border: 1px solid var(--lv-edge);
  box-shadow: var(--lv-shadow);
  text-align: center;
  animation: lv-tip-in var(--lv-base) var(--lv-ease);
}
.lv-tip p { margin: 0; font-size: 15px; line-height: 1.45; color: var(--lv-ink); }
.lv-tip .lv-btn { min-width: 140px; }
.lv-tip-hand { display: inline-flex; color: var(--lv-g-violet); animation: lv-tip-hand 1.6s var(--lv-ease) infinite; }
@keyframes lv-tip-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); } }
@keyframes lv-tip-hand { 0%, 100% { transform: translateX(-10px); } 50% { transform: translateX(10px); } }
@media (prefers-reduced-motion: reduce) { .lv-tip-hand { animation: none; } }
:root[data-motion="reduce"] .lv-tip-hand, :root[data-motion="reduce"] .lv-anim-pop, :root[data-motion="reduce"] .lv-anim-shake { animation: none; }

/* Phones: a compact chip row; the bar's second row holds the chips and the menu. */
@media (max-width: 719.98px) {
  .lv-shell-slot .lv-chip { padding: 2px 9px; }
  .lv-shell-slot .lv-chip b { font-size: 14px; }
  .lv-shell-slot .lv-chips { flex-wrap: nowrap; }
  .lv-menu-btn { height: 30px; width: 40px; margin: 0; }
}
