/* Inlay: a marquetry bench under a warm work lamp. Cut veneers of walnut, maple, cherry and ebony
   are laid into a recessed cabinetmaker's board. The world is drawn on the canvas (script.js); this
   sheet styles the plaques and the card laid over it. */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap");

*, *::before, *::after { box-sizing: border-box; }

:root {
  --brass: #d6a85c;
  --brass-hi: #f4dca6;
  --brass-lo: #7a5424;
  --ink: #f0e2c6;            /* holly cream, for text on the dark bench */
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  /* shared toy chrome (assets/toy-chrome.css): lamp brass on the walnut dark of the bench */
  --tc-accent: #d6a85c;
  --tc-on: #241405;
  --tc-display: var(--serif);
  --tc-ground: #140c07;
}

html, body {
  -webkit-tap-highlight-color: transparent;
  margin: 0; height: 100%; overflow: hidden;
  background: #140d09;
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

#canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
  touch-action: none; outline: none;
}

/* ---------- HUD: a walnut plaque with a brass fillet and engraved figures ---------- */
.hud {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left));
  z-index: 5; display: inline-flex; align-items: stretch; pointer-events: none;
}
html.tc .hud.hud {
  padding: 3px; gap: 3px; border-radius: 12px;
  background: linear-gradient(180deg, #e9c98a 0%, #b4873f 45%, #6e4b1d 100%);
  border: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), 0 12px 26px -12px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 240, 205, 0.6);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.hud__cell {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-width: 70px; padding: 5px 12px 6px; border-radius: 9px;
  background:
    repeating-linear-gradient(92deg, rgba(255, 220, 170, 0.035) 0 2px, rgba(0, 0, 0, 0.05) 2px 5px, rgba(255, 220, 170, 0.02) 5px 9px),
    linear-gradient(180deg, #3a2516 0%, #24160c 100%);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.hud__cell--score { min-width: 96px; }
html.tc .hud .hud__k { font-size: 8px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(236, 200, 132, 0.62); line-height: 1.3; }
.hud__cell > span:last-child {
  font: 600 20px/1.1 var(--serif); font-variant-numeric: tabular-nums lining-nums;
  color: #f6e3b8; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7), 0 0 12px rgba(240, 190, 100, 0.18);
}
.hud__cell:not(.hud__cell--score) > span:last-child { font-size: 15px; color: rgba(246, 227, 184, 0.78); line-height: 1.5; }

/* ---------- Top button: a brass-rimmed walnut knob ---------- */
.topbtns {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  z-index: 6; display: inline-flex; align-items: center; gap: 8px;
}
.iconbtn {
  appearance: none; font-family: inherit; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(214, 168, 92, 0.6);
  background: radial-gradient(110% 110% at 35% 25%, #4a3020 0%, #24150c 70%);
  color: var(--brass-hi);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 225, 160, 0.18), 0 8px 18px -10px rgba(0, 0, 0, 0.9);
  transition: border-color 140ms ease, color 140ms ease, transform 120ms ease, box-shadow 140ms ease;
}
.iconbtn:hover { border-color: var(--brass-hi); color: #fff3d6; }
.iconbtn:active { transform: translateY(1px); }
.iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 2px #140d09, 0 0 0 4px var(--brass-hi); }
.iconbtn .off { display: none; }
.iconbtn[aria-pressed="false"] { color: rgba(244, 220, 166, 0.4); }
.iconbtn[aria-pressed="false"] .wave { display: none; }
.iconbtn[aria-pressed="false"] .off { display: inline; }

/* ---------- overlay: the card over the dimmed bench ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 40%, rgba(16, 10, 6, 0.42), rgba(8, 5, 3, 0.84));
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: opacity 280ms ease;
}
.overlay.is-hidden { opacity: 0; pointer-events: none; }
.panel { animation: pop 320ms cubic-bezier(0.2, 0.9, 0.25, 1) both; }
@keyframes pop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* the card wears a fine boxwood stringing line inside its edge, like the board */
html.tc .overlay .panel.panel {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 26px 70px rgba(0, 0, 0, 0.62),
    0 0 80px rgba(214, 168, 92, 0.12),
    inset 0 0 0 5px color-mix(in srgb, var(--tc-accent) 13%, var(--tc-ground) 87%),
    inset 0 0 0 6px rgba(234, 214, 170, 0.22);
}
html.tc .overlay .panel__title {
  font-weight: 600; letter-spacing: -0.01em; font-size: clamp(42px, 12vw, 56px); line-height: 1.02;
  padding-bottom: 3px; font-variation-settings: "opsz" 144;
  background-image: linear-gradient(176deg, #fff4da 0%, #f0cf88 38%, #c48c3c 70%, #8a5a22 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 3px 16px rgba(216, 160, 80, 0.26));
  font-variant-numeric: lining-nums;
}
.panel__text .newbest { color: #f4d48a; font-weight: 600; }
.panel__stats {
  display: flex; justify-content: center; gap: 6px; margin: 0 0 18px; padding: 0; list-style: none;
}
.panel__stats li {
  flex: 1; max-width: 108px; padding: 8px 6px 7px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid rgba(214, 168, 92, 0.22);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.panel__stats b { font: 600 19px/1.1 var(--serif); color: #f6e3b8; font-variant-numeric: tabular-nums lining-nums; }
.panel__stats span { font: 500 9.5px/1.2 "Geist Mono", ui-monospace, Menlo, monospace; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(236, 200, 132, 0.6); }
.panel__stats[hidden] { display: none; }

/* ---------- frame + hint ---------- */
.frame { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner {
  position: absolute; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(240, 226, 198, 0.5);
}
.frame__corner--tl { display: none; } /* top-left holds the score plaque */
.frame__corner--tr { display: none; } /* top-right holds the sound knob */
.frame__corner--bl { bottom: max(14px, calc(env(safe-area-inset-bottom) + 4px)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; }
.frame__corner a:hover { color: var(--brass-hi); }
.frame__corner a:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 3px; border-radius: 3px; }

.hint {
  position: fixed; bottom: max(16px, calc(env(safe-area-inset-bottom) + 6px)); left: 50%; transform: translateX(-50%); z-index: 4; margin: 0;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; color: rgba(240, 226, 198, 0.62);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none; white-space: nowrap; transition: opacity 400ms ease; text-align: center;
}
.hint.is-gone { opacity: 0; }

@media (max-width: 620px) {
  .frame__corner--bl { display: none; }
}

/* Dock the shared tip-jar / fullscreen badges side by side at the bottom right, so they sit in the
   strip the board leaves free instead of over the tray (their default is right-center).
   Doubled classes out-specify the components' injected styles; silence the entrance nudge. */
.opt-tipjar.opt-tipjar {
  top: auto; bottom: max(12px, calc(env(safe-area-inset-bottom) + 2px)); transform: none;
}
.opt-fs.opt-fs {
  top: auto; bottom: max(12px, calc(env(safe-area-inset-bottom) + 2px)); transform: none;
  right: calc(max(8px, env(safe-area-inset-right)) + 50px);
}
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }

/* ---------- short landscape (a phone on its side, 874 x 402) ----------
   The score plaque stands at the left; the board and the tray share the middle (script.js measures
   the plaque). The card goes two columns: the words on the left, the actions on the right. */
@media (orientation: landscape) and (max-height: 500px) {
  html.tc .hud.hud {
    top: max(12px, env(safe-area-inset-top)); flex-direction: column;
    left: max(12px, env(safe-area-inset-left));
  }
  .hud__cell, .hud__cell--score { min-width: 84px; }
  html.tc #overlay > .panel.panel {
    width: min(100%, 650px); max-width: 650px; padding: 16px 26px 14px; text-align: left;
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 30px; align-content: start; grid-auto-flow: dense;
  }
  html.tc #overlay > .panel > * { grid-column: 2; }
  html.tc #overlay > .panel > .panel__lede { grid-column: 1; grid-row: 1 / span 12; }
  html.tc #overlay > .panel > .play-btn { max-width: none; margin: 4px 0 0; }
  html.tc .overlay .panel__title { font-size: 46px; margin-bottom: 6px; }
  html.tc #overlay .panel__text { margin-bottom: 4px; }
  html.tc #overlay .panel__keys { text-align: center; }
  .panel__stats { margin: 0 0 10px; }
  html.tc #overlay .panel .mg { margin-top: 10px; }
  html.tc #overlay .panel .opt-share { margin-top: 10px; }
  .hint { display: none; }
  html.tc #overlay .panel__keys { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
  .overlay, .hint { transition: none; }
}
