/* Four Tumblers, practice edition (One Page Toys No. 153).
   The vault itself (door, windows, lamps, dial, handle, contact chart) is fourtumblers.com's own,
   styled by the vendored fourtumblers-kit.css. This file is the room around it, laid out like the
   daily site: a 1930s bank vault after hours, dark green, one lamp overhead. The start and result
   card is the shared toy chrome (assets/toy-chrome.css), kept in the vault's green with brass. */

:root {
  --banner: 34px;
  --strip: 60px;          /* the bottom strip: back link, the tickets pill above it, the tip jar and full-screen badges */
  --dial: 240px;          /* set by script.js to whatever the screen leaves */
  --brass-glow: rgba(255, 210, 120, 0.25);
  /* the shared card */
  --tc-accent: #f0cf86;
  --tc-on: #2b1d06;
  --tc-display: "Limelight", "Didot", serif;
  --tc-ground: #0a0f0d;
}

/* The kit tints its card from the accent, and brass over this green reads muddy olive: keep the
   card in the vault's own green, with brass on the eyebrow, the edge and the button.
   (:root.tc outranks the kit's html.tc, which loads after this file.) */
:root.tc {
  --tc-card: rgba(16, 27, 22, 0.94);
  --tc-edge: rgba(240, 207, 134, 0.3);
  --tc-text: #d9d2bd;
  --tc-faint: #a39d8a;
  --tc-ink: #f3ead2;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--room);
  color: #e8e2d2;
  font-family: var(--ui);
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
}
body {
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(255, 214, 140, 0.24), transparent 70%),
    radial-gradient(ellipse 120% 80% at 50% 120%, rgba(0, 0, 0, 0.6), transparent 60%),
    linear-gradient(180deg, var(--room-2), var(--room));
  background-attachment: fixed;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 3px; }

/* ---------- the daily banner ---------- */
.daily {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 25;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: calc(var(--banner) + env(safe-area-inset-top));
  padding: max(7px, env(safe-area-inset-top)) 12px 7px;
  background: linear-gradient(180deg, rgba(14, 22, 18, 0.97), rgba(9, 14, 12, 0.97));
  border-bottom: 1px solid rgba(240, 207, 134, 0.26);
  color: #efe7d2;
  text-decoration: none;
  font: 600 15px/1.2 var(--ui);
  letter-spacing: 0.02em;
}
.daily__k { color: #a39d8a; text-transform: uppercase; letter-spacing: 0.14em; font-size: 13px; }
.daily__t { font-variant-numeric: tabular-nums; }
.daily__go { color: var(--brass-hi); }
.daily:hover .daily__go { text-decoration: underline; text-underline-offset: 3px; }
.daily:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: -3px; }

/* ---------- frame corners ---------- */
.frame__corner {
  position: fixed;
  z-index: 26;
  font: 500 0.6rem/1 "Geist Mono", ui-monospace, monospace;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #8c877a;
  pointer-events: none;
}
/* portrait: a thin row under the banner */
.frame__corner--tl { top: calc(var(--banner) + env(safe-area-inset-top) + 9px); left: max(14px, env(safe-area-inset-left)); }
.frame__corner--tr { top: calc(var(--banner) + env(safe-area-inset-top) + 9px); right: max(14px, env(safe-area-inset-right)); }
.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: #8c877a; text-decoration: none; }
.frame__corner--bl a:hover { color: #efe7d2; }

/* ---------- the room ---------- */
.app {
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(var(--banner) + env(safe-area-inset-top) + 26px)
    max(14px, env(safe-area-inset-right))
    calc(max(14px, env(safe-area-inset-bottom)) + var(--strip))
    max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { min-width: 0; }
.brand__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(21px, 6.6vw, 27px);
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
  color: var(--brass-hi);
  text-shadow: 0 1px 0 #000, 0 0 18px var(--brass-glow);
}
.pick { display: flex; align-items: center; gap: 2px; margin: 3px 0 0 -8px; }
.pick__label {
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #b8b19e;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pick__arrow {
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--brass-hi);
  cursor: pointer;
}
.pick__arrow svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pick__arrow:hover { background: rgba(240, 207, 134, 0.1); }
.pick__arrow:active { transform: scale(0.92); }
.pick__arrow:disabled { opacity: 0.28; cursor: default; background: transparent; transform: none; }

.tools { display: flex; gap: 6px; }
.icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(240, 207, 134, 0.25);
  background: radial-gradient(circle at 40% 30%, #2a332f, #121815);
  display: grid; place-items: center;
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.2s;
}
.icon:active { transform: translateY(1px) scale(0.96); }
.icon:hover { border-color: rgba(240, 207, 134, 0.6); }
.icon svg { width: 22px; height: 22px; fill: none; stroke: var(--brass-hi); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon svg .fill { fill: var(--brass-hi); }
#soundBtn[aria-pressed="true"] .off,
#soundBtn[aria-pressed="false"] .on { display: none; }
#soundBtn[aria-pressed="false"] svg { stroke: #8c877a; }
#soundBtn[aria-pressed="false"] svg .fill { fill: #8c877a; }

/* the vault: the dial takes what the screen leaves (script.js measures it) */
#vault { flex: 0 0 auto; }
.app .dial-wrap { width: var(--dial); }

/* The hint line is a pencil note on the contact chart (script.js moves it into the paper). */
.paper { position: relative; }
.hint {
  position: absolute;
  top: 12px;
  right: 12px;
  margin: 0;
  max-width: 58%;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 600 12.5px/1.2 var(--ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  pointer-events: none;
}

/* portrait: a slightly tighter door than the daily's, so the dial gets the room */
@media (orientation: portrait) {
  .door { padding: 12px; gap: 8px; }
  .windows { padding: 7px; gap: 7px; }
  .wv { font-size: 31px; }
}
/* short phones (375 x 667): tighten so the dial keeps its size */
@media (orientation: portrait) and (max-height: 720px) {
  :root { --banner: 30px; }
  .app { gap: 7px; padding-top: calc(var(--banner) + env(safe-area-inset-top) + 22px); }
  .frame__corner--tl, .frame__corner--tr { top: calc(var(--banner) + env(safe-area-inset-top) + 7px); }
  .brand__name { font-size: 22px; }
  .pick__label { font-size: 13px; }
  .pick__arrow { width: 28px; height: 28px; }
  .icon { width: 38px; height: 38px; }
  .door { padding: 10px; gap: 8px; }
  .windows { padding: 6px; gap: 6px; }
  .wv { font-size: 28px; }
  .handle { height: 46px; font-size: 19px; }
  .strip, .chart-label { height: 22px; }
  .chart { gap: 2px; }
  .paper { padding: 7px 10px 4px; }
  .paper h2 { margin-bottom: 4px; font-size: 15px; }
  .hint { top: 8px; font-size: 11.5px; }
}

/* ---------- landscape: the header and chart on the left, the door on the right ----------
   The door is on the right so it can run to the bottom of the screen: the bottom-left corner
   belongs to the back link and the tickets pill, and the badges join them there. */
@media (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .app {
    max-width: 980px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr;
    grid-template-areas: "top door" "paper door";
    column-gap: 22px;
    row-gap: 10px;
    padding-top: calc(var(--banner) + env(safe-area-inset-top) + 12px);
    padding-bottom: calc(max(10px, env(safe-area-inset-bottom)) + 4px);
    align-content: start;
  }
  .top { grid-area: top; }
  #vault { display: contents; }
  .ft-vault { display: contents; }
  .door { grid-area: door; align-self: start; width: max(calc(var(--dial) + 44px), 250px); }
  .paper { grid-area: paper; align-self: start; margin-top: 8px; }
  .windows { padding: 6px; gap: 6px; }
  .wv { font-size: 28px; }
  .handle { height: 44px; font-size: 17px; }
  .handle:disabled { font-size: 14px; }
  .strip, .chart-label { height: 30px; }
  .chart { gap: 5px; }
  /* the corners ride the banner's own line: it is wide enough here */
  .frame__corner--tl, .frame__corner--tr { top: calc(env(safe-area-inset-top) + (var(--banner) - 9.6px) / 2); }
  .frame__corner--tl { left: max(16px, calc(env(safe-area-inset-left) + 4px)); }
  .frame__corner--tr { right: max(16px, calc(env(safe-area-inset-right) + 4px)); }
}
/* a computer: the room sits in the middle of the screen, the header and chart centered beside the door */
@media (orientation: landscape) and (min-aspect-ratio: 4/3) and (min-height: 501px) {
  .app {
    grid-template-rows: 1fr auto auto 1fr;
    grid-template-areas: ". door" "top door" "paper door" ". door";
    align-content: center;
    row-gap: 14px;
  }
  .paper { margin-top: 0; }
  .door { align-self: center; }
}
@media (orientation: landscape) and (max-height: 500px) {
  :root { --banner: 30px; }
  /* a phone on its side: the badges join the back link bottom-left, under the chart, so the
     door on the right can run to the bottom */
  .opt-tipjar.opt-tipjar { right: auto; left: calc(max(16px, env(safe-area-inset-left)) + 206px); }
  .opt-fs.opt-fs { right: auto; left: calc(max(16px, env(safe-area-inset-left)) + 156px); }
  .daily { font-size: 14px; }
  .brand__name { font-size: 22px; }
  .pick__label { font-size: 12.5px; }
  .icon { width: 36px; height: 36px; }
  .icon svg { width: 19px; height: 19px; }
  .app { row-gap: 6px; padding-top: calc(var(--banner) + env(safe-area-inset-top) + 8px); }
  .door { padding: 8px 10px 10px; gap: 7px; }
  .door::before, .door::after { top: 7px; }
  .windows { padding: 5px; gap: 5px; }
  .win { padding: 2px 0 4px; }
  .wv { font-size: 24px; }
  .handle { height: 40px; font-size: 16px; }
  .handle-row { gap: 10px; }
  .strip, .chart-label { height: 24px; }
  .chart { gap: 3px; }
  .paper { padding: 7px 10px 4px; }
  .paper h2 { margin-bottom: 3px; font-size: 14px; }
}

/* ---------- the start / result card (the rest comes from toy-chrome.css) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  background: rgba(4, 7, 6, 0.62);
}
.overlay.help { z-index: 31; }
html.tc .overlay .panel__title { font-weight: 400; letter-spacing: 0.03em; color: var(--brass-hi); text-shadow: 0 1px 0 #000, 0 0 22px var(--brass-glow); }
html.tc .overlay .panel__text--small { font-size: 13.5px; margin-top: -6px; margin-bottom: 18px; color: var(--tc-faint); }
html.tc .overlay .panel__text { font-size: 15px; }
/* the button is the vault's brass handle, not a flat pill */
html.tc .overlay .panel .play-btn {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, #9c7128);
  color: #2b1d06;
  font: 600 19px/50px var(--ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 250, 230, 0.8), inset 0 -2px 0 rgba(90, 60, 10, 0.5), 0 4px 0 #5c4115, 0 8px 18px rgba(0, 0, 0, 0.5);
}
html.tc .overlay .panel .play-btn:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 250, 230, 0.8), 0 1px 0 #5c4115; }
html.tc .overlay .panel .play-btn:focus-visible { box-shadow: 0 0 0 3px var(--tc-ground), 0 0 0 5px var(--brass-hi); }

.legend {
  list-style: none;
  margin: -6px 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 12px;
  text-align: left;
  font: 400 15px/1.2 var(--tc-body);
  color: var(--tc-text);
}
.legend li { display: flex; align-items: center; gap: 8px; }
.legend b { color: var(--tc-ink); font-weight: 600; }
.legend .lamp { flex: 0 0 auto; }

.intro-link { color: var(--brass-hi); font-weight: 600; text-decoration: underline; text-decoration-color: rgba(240, 207, 134, 0.45); text-underline-offset: 3px; }
.intro-link:hover { text-decoration-color: var(--brass-hi); }

/* result */
.res-line { margin: -4px 0 12px; color: var(--tc-text); font: 400 15.5px/1.45 var(--tc-body); text-wrap: pretty; }
.res-line b { color: var(--tc-ink); font-weight: 600; }
.grid { display: inline-grid; gap: 4px; margin: 0 auto 12px; }
.grid > div { display: flex; gap: 4px; }
.grid .lamp { width: 18px; height: 18px; border-radius: 4px; }
.grid .lamp.drop { animation: lamp-in 260ms cubic-bezier(0.2, 1.5, 0.4, 1) both; }
@keyframes lamp-in { from { transform: scale(0.3); opacity: 0; } }
.res-combo { margin: 0 0 12px; color: var(--tc-text); font: 400 15px/1.4 var(--tc-body); }
.res-combo b { display: inline-block; color: var(--brass-hi); font: 600 24px/1 var(--ui); letter-spacing: 0.08em; margin-left: 4px; vertical-align: -2px; }
.res-stats { margin: 0 0 16px; color: var(--tc-faint); font: 400 13.5px/1.4 var(--tc-body); font-variant-numeric: tabular-nums; }
.verdict { animation: verdict-in 620ms cubic-bezier(0.2, 1.5, 0.4, 1) 80ms both; }
.is-locked .verdict { color: #e8a87a; text-shadow: 0 1px 0 #000; animation: verdict-thud 560ms ease-out 80ms both; }
@keyframes verdict-in { from { transform: scale(0.5); opacity: 0; } }
@keyframes verdict-thud { 0% { transform: translateY(-14px); opacity: 0; } 60% { transform: translateY(2px); opacity: 1; } 100% { transform: none; } }

/* the end-of-vault invitation to the daily */
.cta {
  margin-top: 14px;
  padding: 13px 14px 14px;
  border-radius: 14px;
  background: rgba(4, 7, 6, 0.45);
  border: 1px solid rgba(240, 207, 134, 0.24);
}
.cta__text { margin: 0 0 10px; color: var(--tc-text); font: 400 14px/1.45 var(--tc-body); text-wrap: pretty; }
.cta__text b { color: var(--brass-hi); font-weight: 600; }
.cta__btn {
  display: block;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--brass-hi);
  color: var(--brass-hi);
  font: 600 16px/41px var(--ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
}
.cta__btn:hover { background: rgba(240, 207, 134, 0.1); }
.cta__btn:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
.cta__domain { margin: 7px 0 0; color: var(--tc-faint); font: 400 13px/1.2 var(--tc-body); letter-spacing: 0.04em; }
.cta__domain[hidden] { display: none; }

.ghost-btn {
  display: block;
  width: 100%;
  min-height: 46px;
  border-radius: 999px;
  border: 1.5px solid var(--brass-hi);
  background: transparent;
  color: var(--brass-hi);
  font: 600 17px/1 var(--ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.ghost-btn:hover { background: rgba(240, 207, 134, 0.1); }

/* More Toys belongs to the end of a vault; the start card stays about the vault */
.panel:not(.is-result) > [data-more-games] { display: none !important; }

/* short phones: the tallest result (eight rows of lamps) still fits without scrolling */
@media (orientation: portrait) and (max-height: 760px) {
  html.tc .overlay .panel { padding: 16px 18px 10px; }
  html.tc .overlay .panel__title { font-size: 31px; margin-bottom: 6px; }
  html.tc .overlay .panel__eyebrow { margin-bottom: 5px; }
  .res-line { margin-bottom: 10px; font-size: 15px; }
  .grid .lamp { width: 14px; height: 14px; border-radius: 3px; }
  .grid, .grid > div { gap: 3px; }
  .grid { margin-bottom: 6px; }
  .res-stats { margin-bottom: 10px; }
  html.tc .overlay .panel .play-btn { min-height: 46px; line-height: 46px; }
  .cta { margin-top: 10px; padding: 10px 12px 12px; }
  .cta__text { margin-bottom: 8px; font-size: 13.5px; }
  .cta__btn { min-height: 40px; line-height: 37px; font-size: 15px; }
  html.tc .overlay .opt-share { margin-top: 6px; }
}

/* The result after a vault that took all eight tries is the tallest card: on a full-size phone
   it tightens just enough to fit with the daily invitation and More Toys under it. */
@media (orientation: portrait) and (max-height: 900px) {
  html.tc .overlay .panel.is-result { padding-top: 18px; padding-bottom: 10px; }
  .is-result .grid .lamp { width: 15px; height: 15px; border-radius: 3px; }
  .is-result .grid, .is-result .grid > div { gap: 3px; }
  .is-result .grid { margin-bottom: 8px; }
  .is-result .res-combo { margin-bottom: 8px; }
  .is-result .res-stats { margin-bottom: 12px; }
  .is-result .cta { margin-top: 10px; padding: 10px 12px 12px; }
  .is-result .cta__text { margin-bottom: 8px; }
}
/* Small phones (375 x 667): smaller still. */
@media (orientation: portrait) and (max-height: 700px) {
  html.tc .overlay .panel.is-result .panel__title { font-size: 27px; }
  .is-result .res-line { margin-bottom: 6px; font-size: 14px; }
  .is-result .grid .lamp { width: 11px; height: 11px; border-radius: 2px; }
  .is-result .grid, .is-result .grid > div { gap: 2px; }
  .is-result .res-combo { font-size: 14px; }
  .is-result .res-combo b { font-size: 20px; }
  .is-result .res-stats { margin-bottom: 8px; font-size: 12.5px; }
  html.tc .overlay .panel.is-result .play-btn { min-height: 42px; line-height: 42px; }
  .is-result .cta__text { font-size: 13px; }
  .is-result .cta__btn { min-height: 38px; line-height: 35px; }
  .is-result .cta__domain { margin-top: 5px; font-size: 12px; }
}

/* badges: right-center would sit on the door's bolts. Dock them in the bottom strip, side by side. */
.opt-tipjar.opt-tipjar { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); transform: none; }
.opt-fs.opt-fs { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); right: calc(max(16px, env(safe-area-inset-right)) + 50px); transform: none; }
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }

/* Phones, once the countdown runs: the label goes so the countdown and the link fit one line. */
@media (max-width: 480px) {
  .daily.is-live .daily__k { display: none; }
}

/* A phone on its side: the cards go wide, and the result splits into two columns. */
@media (orientation: landscape) and (max-height: 500px) {
  html.tc .overlay .panel__text--small { margin-top: -4px; margin-bottom: 10px; font-size: 12.5px; }
  .legend { grid-template-columns: repeat(4, auto); justify-content: center; gap: 4px 16px; margin: -2px 0 10px; font-size: 14px; }
  .grid .lamp { width: 15px; height: 15px; }
  .grid, .grid > div { gap: 3px; }
  .res-line { font-size: 14px; margin-bottom: 8px; }
  .res-stats { margin-bottom: 10px; }
  .cta { margin-top: 10px; padding: 10px 12px; }
  .cta__text { font-size: 13px; margin-bottom: 8px; }
  .cta__btn { min-height: 38px; line-height: 35px; font-size: 15px; }
  .ghost-btn { min-height: 40px; font-size: 15px; }
  html.tc .overlay .panel.is-result { columns: 2; column-gap: 28px; column-fill: auto; }
  html.tc .overlay .panel.is-result .result { break-inside: avoid; }
  /* the left column holds the vault (title, lamps, combination); the count, the button and the
     daily invitation start the right one */
  html.tc .overlay .panel.is-result .res-stats { break-before: column; margin-top: 0; }
  html.tc .overlay .panel.is-result .play-btn { margin-top: 0; min-height: 42px; line-height: 42px; }
  .is-result .res-stats { margin-bottom: 6px; font-size: 13px; }
  .is-result .cta { margin-top: 7px; padding: 8px 12px 8px; }
  .is-result .cta__text { margin-bottom: 7px; }
  .is-result .cta__btn { min-height: 36px; line-height: 33px; }
  .is-result .cta__domain { margin-top: 4px; font-size: 12px; }
  .is-result .grid .lamp { width: 12px; height: 12px; border-radius: 3px; }
  .is-result .grid { margin-bottom: 6px; }
  .is-result .res-combo { margin-bottom: 0; }
  /* WebKit paints a backdrop-filtered element inside a multi-column box blank */
  html.tc .overlay .panel.is-result .mg-card { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .verdict, .grid .lamp.drop { animation: none !important; }
  .icon, .pick__arrow { transition: none; }
}
