/* Skyscrapers — full-bleed canvas logic puzzle. Self-contained. */

@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800;900&family=Geist+Mono:wght@400;500;600&display=swap");

:root{
  --ink: #eef2ff;
  --dim: rgba(238, 242, 255, 0.55);
  --faint: rgba(238, 242, 255, 0.3);
  --bg: #05060e;
  --warm: #ffb44a;
  --warm-lite: #ffdca6;
  --cool: #6fd8ff;
  --bad: #ff5f6d;
  --line: rgba(150, 180, 255, 0.16);
  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after{ box-sizing: border-box; }
html, body{
  height: 100%; margin: 0; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
canvas{
  display: block; width: 100%; height: 100%; touch-action: none;
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}

/* ---------- HUD ---------- */
.hud{
  position: fixed; z-index: 5; pointer-events: none;
  top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 26px; align-items: flex-end;
  font-family: var(--font-mono);
  padding: 7px 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(7, 8, 20, 0.6);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hud[hidden]{ display: none; }
.hud__cell{ display: flex; flex-direction: column; align-items: center; gap: 1px; }
.hud__k{ font-size: 8px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); }
.hud__cell span:last-child{ font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Bottom bar ---------- */
.bar{
  position: fixed; z-index: 6;
  left: 50%; transform: translateX(-50%);
  bottom: max(46px, calc(env(safe-area-inset-bottom) + 34px));
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 7px;
  padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 14px;
  background: rgba(7, 8, 20, 0.72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  width: max-content; max-width: calc(100vw - 24px);
}
.bar[hidden]{ display: none; }
.bar__sep{ width: 1px; align-self: stretch; background: var(--line); margin: 2px 2px; }
.btn{
  appearance: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500;
  letter-spacing: 0.06em;
  padding: 8px 12px; border-radius: 9px;
  border: 1px solid transparent; background: rgba(255,255,255,0.06); color: var(--ink);
  transition: background 140ms ease, transform 120ms ease, opacity 140ms ease;
}
.btn:hover:not(:disabled){ background: rgba(255,255,255,0.13); transform: translateY(-1px); }
.btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(111, 216, 255, 0.45); }
.btn.is-on{
  background: linear-gradient(180deg, var(--warm-lite), var(--warm));
  color: #2c1703; font-weight: 700;
}
.btn--go{ background: rgba(111, 216, 255, 0.14); color: var(--cool); font-weight: 700; }

/* ---------- Callout ---------- */
.callout{
  position: fixed; z-index: 6; pointer-events: none;
  /* the top row of clue chips lives where a top-anchored callout would land,
     so this sits above the toolbar instead, under the city */
  left: 50%; bottom: max(110px, calc(env(safe-area-inset-bottom) + 98px));
  transform: translateX(-50%);
  font-family: var(--font-display); font-weight: 900; letter-spacing: -0.02em;
  font-size: clamp(1.2rem, 4.6vw, 2.1rem); line-height: 1;
  color: var(--warm-lite); text-align: center;
  text-shadow: 0 0 34px rgba(255, 170, 70, 0.5), 0 6px 30px rgba(0,0,0,0.6);
}
.callout[hidden]{ display: none; }

/* ---------- Sound ---------- */
.sound-btn{
  position: fixed; z-index: 6;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(9, 10, 22, 0.6); color: var(--ink);
  font-size: 15px; cursor: pointer; backdrop-filter: blur(8px);
  transition: transform 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.sound-btn:hover{ transform: translateY(-1px); border-color: var(--cool); }
.sound-btn[aria-pressed="false"]{ opacity: 0.45; }
.sound-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(111, 216, 255, 0.4); }

/* ---------- Overlay ---------- */
.overlay{
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  background: radial-gradient(90% 70% at 50% 42%, rgba(6, 7, 16, 0.74), rgba(2, 2, 6, 0.95));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  transition: opacity 240ms ease;
}
.overlay[hidden]{ display: none; }
.overlay.is-out{ opacity: 0; pointer-events: none; }
.panel{
  max-width: 540px; text-align: center;
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid var(--line); border-radius: 16px;
  background: rgba(8, 9, 20, 0.8);
  box-shadow: 0 30px 90px -20px rgba(0,0,0,0.85);
}
.panel__eyebrow{ margin: 0 0 6px; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--warm); }
.panel__title{ margin: 0 0 12px; font-size: clamp(1.9rem, 7.4vw, 2.9rem); font-weight: 900; letter-spacing: -0.02em; }
.panel__text{ margin: 0 0 20px; font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.7; color: var(--dim); }
.panel__text b{ color: var(--ink); font-weight: 600; }
/* the rule is easier to see than to read: a worked row under the copy */
.demo{ margin: 0 auto 20px; display: block; width: min(340px, 82vw); height: auto; }
.play-btn{
  appearance: none; font-family: var(--font-display); font-weight: 800; font-size: 1rem;
  padding: 13px 30px; border-radius: 999px; cursor: pointer;
  border: 0; background: linear-gradient(180deg, var(--warm-lite), var(--warm));
  color: #2c1703; box-shadow: 0 10px 30px -8px rgba(255, 170, 70, 0.6);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.play-btn:hover{ transform: translateY(-2px); box-shadow: 0 16px 38px -10px rgba(255, 170, 70, 0.75); }
.play-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px rgba(255, 170, 70, 0.45); }
.panel__keys{ margin: 16px 0 0; font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.06em; color: var(--faint); }

/* ---------- Frame corners + hint ---------- */
.frame{ position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner{
  position: fixed; font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--faint);
}
.frame__corner--tl{ top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); }
.frame__corner--tr{ top: max(14px, env(safe-area-inset-top)); right: max(58px, calc(env(safe-area-inset-right) + 58px)); }
.frame__corner--bl{ bottom: max(14px, env(safe-area-inset-bottom)); left: max(14px, env(safe-area-inset-left)); pointer-events: auto; }
.frame__corner--bl a{ color: var(--faint); text-decoration: none; }
.frame__corner--bl a:hover{ color: var(--warm); }

.hint{
  position: fixed; z-index: 4; pointer-events: none;
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 6px)); left: 50%; transform: translateX(-50%);
  margin: 0; font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.1em;
  color: var(--faint); white-space: nowrap;
  transition: opacity 500ms ease;
}
.hint.is-gone{ opacity: 0; }

@media (max-width: 620px){
  .hint{ font-size: 0.55rem; }
  /* the HUD is centred at the top and the toy name is pinned top-right; below
     this width they overlap, and the name is the one the page can spare */
  .frame__corner--tr{ display: none; }
  /* the tickets pill docks bottom-left and is 32px tall, so the hint clears it */
  .hint{ display: none; }
  /* the fourth readout pushed the HUD into the "No. 117" corner mark */
  .hud{ gap: 11px; padding: 6px 10px; }
  .hud__k{ font-size: 7px; letter-spacing: 0.12em; }
  .hud__cell span:last-child{ font-size: 15px; }
  .bar{ bottom: max(74px, calc(env(safe-area-inset-bottom) + 64px)); }
  .callout{ bottom: max(178px, calc(env(safe-area-inset-bottom) + 168px)); }
}
@media (max-height: 620px){
  .hud{ top: max(6px, env(safe-area-inset-top)); padding: 4px 11px; }
}
/* a landscape phone is wide enough to dodge the 620px rule but far too short:
   the centred hint runs straight through the bottom-left back-link */
@media (max-height: 500px){
  .hint{ display: none; }
}
@media (prefers-reduced-motion: reduce){
  .play-btn, .sound-btn, .overlay, .btn{ transition: none; }
}

/* The clue chips live on all four edges of the plate, and the shared tip-jar /
   fullscreen badges dock at right-CENTRE — straight on top of the right-hand
   sightlines on a phone. Move them to the bottom-right corner, which this toy
   leaves empty. Doubled classes out-specify the components' injected styles. */
.opt-tipjar.opt-tipjar {
  top: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: none;
}
.opt-fs.opt-fs {
  top: auto;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 54px);
  transform: none;
}
/* the attention nudge assumes the right-centre translateY(-50%) */
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }
