/* /tower-blocks/ — Tower Blocks, port of the Pocket Games stacker (tower.css). The canvas paints the
   skyline; the HUD, the lobby and the result card sit on top of it and take the skyline's own tokens
   (Daybreak / Lagoon / Afterglow), like the app. Page frame, rank rows and the more-games row come from
   games.css. Also linked by /tower-blocks-leaderboard/ for its Season 2 / Classic switch. */

.tb-play { display: grid; gap: var(--space-3); }
.tb-play > .tb-h1 { font-size: var(--step-4); text-align: center; margin: 0; }
.tb-h1-sub { text-align: center; color: var(--text-muted); margin: 0 auto; max-inline-size: 60ch; }
@media (max-width: 640px) {
  .tb-play > .tb-h1 { font-size: var(--step-2); }
  .tb-h1-sub { display: none; }
}

/* ── skyline tokens (tower.css "bright skyline finishes") ── */
.tb-stage {
  --tb-bg: #b9ecff; --tb-surface: #fffefd; --tb-panel: #d9e7ff; --tb-ink: #243879; --tb-muted: #5a6998;
  --tb-accent: #7544ed; --tb-border: #b9cdf1; --tb-chrome: #d8f4ff; --tb-hot: linear-gradient(125deg, #9560ff, #6434db);
  --tb-soft: #b3cdf4; --tb-sky: linear-gradient(165deg, #67ccff, #c5f5ff 64%, #fff2b4); --tb-button-ink: #fff; --tb-start: #188dff;
}
.tb-stage[data-sky="lagoon"] {
  --tb-bg: #baf7e0; --tb-surface: #faffef; --tb-panel: #ceefdc; --tb-ink: #155b62; --tb-muted: #438486;
  --tb-accent: #098dcb; --tb-border: #a8dcce; --tb-chrome: #cbfae7; --tb-hot: linear-gradient(125deg, #14b6eb, #007fc5);
  --tb-soft: #9ddfcd; --tb-sky: linear-gradient(165deg, #37cdd9, #c6ffe4 64%, #f0ffac); --tb-button-ink: #fff; --tb-start: #05aacd;
}
.tb-stage[data-sky="afterglow"] {
  --tb-bg: #6836c7; --tb-surface: #6231b5; --tb-panel: #8146d5; --tb-ink: #fff8e6; --tb-muted: #e4c5ff;
  --tb-accent: #ffd455; --tb-border: #a877e4; --tb-chrome: #5030b2; --tb-hot: linear-gradient(125deg, #ffe367, #ffb738);
  --tb-soft: #914fce; --tb-sky: linear-gradient(165deg, #4f35c9, #9d3dd0 65%, #f48b98); --tb-button-ink: #593b6e; --tb-start: #4234ca;
}

/* ── stage ── */
.tb-card { padding: var(--space-2); }
.tb-stage {
  --tb-h: clamp(460px, calc(100svh - var(--header-stuck, 64px) - 140px), 760px);
  position: relative; block-size: var(--tb-h); inline-size: 100%;
  border-radius: var(--radius-lg, 16px); overflow: hidden; isolation: isolate;
  background: var(--tb-start); color: var(--tb-ink);
  font-family: var(--font-body); container-type: inline-size; container-name: tb;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.tb-stage b, .tb-stage strong, .tb-stage small, .tb-stage em { color: inherit; }
.tb-stage h2 { text-transform: none; letter-spacing: normal; }
.tb-stage:focus { outline: none; }
.tb-stage:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tb-stage.is-playing { touch-action: none; cursor: pointer; }
.tb-canvas { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; display: block; touch-action: none; }

/* ── HUD: floating score, floors, high score ── */
.tb-hud {
  position: absolute; inset-block-start: 0; inset-inline: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 22px 0;
  pointer-events: none; color: #fff;
}
.tb-hud > div { display: flex; flex-direction: column; gap: 3px; min-inline-size: 82px; }
.tb-hud__side--end { text-align: end; align-items: flex-end; }
.tb-hud span { font-size: 10px; font-weight: 800; letter-spacing: 1.1px; color: #ffffffd9; text-shadow: 0 1px 4px #0a1f5a66; }
.tb-hud b { font-size: 27px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; text-shadow: 0 2px 8px #0a1f5a66; }
.tb-hud__height { align-items: center; }
/* The HUD floats over sky, clouds and sun on every skyline: each reading sits on a soft dark
   glass chip so the white labels keep their contrast on the palest cloud. */
.tb-hud > div:not(:empty) {
  padding: 5px 12px 6px; border-radius: 14px;
  background: rgb(10 31 90 / 0.38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.16);
}
.tb-hud span { color: #fff; }
.tb-stage .tb-hud__height b { font-size: 34px; color: #fff7c2; }
.tb-weather {
  position: absolute; inset-block-start: 84px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 30px;
  background: color-mix(in srgb, var(--tb-surface), transparent 5%); border: 2px solid #ffffff6e; box-shadow: 0 3px 0 #263b7020;
  color: var(--tb-ink); white-space: nowrap; pointer-events: none;
}
.tb-weather > span { font-size: 18px; line-height: 1; }
.tb-weather > b { font-size: 10px; letter-spacing: .8px; font-weight: 800; }
.tb-weather > i { block-size: 5px; border-radius: 5px; background: var(--tb-accent); }
.tb-weather > i[hidden] { display: none; }
.tb-weather.is-turn { border-color: var(--tb-accent); box-shadow: 0 3px 0 var(--tb-accent); }
.tb-streak {
  position: absolute; inset-block-start: 122px; inset-inline-end: 19px; z-index: 2;
  padding: 5px 9px; border-radius: 10px; background: var(--tb-surface); border: 1px solid var(--tb-border);
  font-size: 12px; color: var(--tb-ink); pointer-events: none;
}
.tb-streak b { font-size: 16px; }
.tb-streak[hidden], .tb-note[hidden] { display: none; }
.tb-note {
  position: absolute; inset-block-end: 10px; inset-inline: 30px; z-index: 2;
  padding: 6px 9px; border-radius: 12px; text-align: center;
  background: color-mix(in srgb, var(--tb-surface), transparent 15%); color: var(--tb-ink);
  font-size: 10px; font-weight: 800; letter-spacing: .6px; pointer-events: none;
}
.tb-stage:not(.is-live) :is(.tb-hud, .tb-weather, .tb-streak, .tb-note) { display: none; }
@container tb (min-width: 760px) {
  .tb-note { inset-inline: 30%; }
}

/* ── praise (kit.praise) ── */
.tb-praise {
  position: absolute; inset-inline: 0; inset-block-start: 25%; z-index: 3;
  display: flex; flex-direction: column; align-items: center; pointer-events: none; opacity: 0;
}
.tb-praise.is-on { animation: tb-praise 1.1s ease forwards; }
.tb-praise strong {
  max-inline-size: 82%; text-align: center; line-height: 1.12; overflow-wrap: anywhere;
  font-size: clamp(23px, 6vw, 35px); font-weight: 900; color: var(--tb-ink);
  text-shadow: 0 2px 0 var(--tb-surface), 0 5px 22px var(--tb-surface);
}
.tb-praise small { max-inline-size: 82%; text-align: center; margin-block-start: 2px; font-size: 11px; font-weight: 900; letter-spacing: 1px; color: var(--tb-ink); text-shadow: 0 2px 8px var(--tb-surface); }
@keyframes tb-praise {
  0% { transform: scale(.4) translateY(10px); opacity: 0; }
  18% { transform: scale(1.12) translateY(0); opacity: 1; }
  30% { transform: scale(1); }
  75% { transform: scale(1) translateY(-6px); opacity: 1; }
  100% { transform: scale(.9) translateY(-24px); opacity: 0; }
}

/* ── overlay: lobby / pause / result ── */
.tb-overlay {
  position: absolute; inset: 0; z-index: 5; overflow: auto; overscroll-behavior: contain;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px 22px 26px; background: var(--tb-sky); color: var(--tb-ink);
}
.tb-overlay[hidden] { display: none; }
.tb-overlay:not([data-kind="lobby"]) { align-items: center; background: color-mix(in srgb, var(--tb-bg), transparent 30%); backdrop-filter: blur(2px); }
.tb-panel { inline-size: min(100%, 380px); margin: auto; }
.tb-panel--pause, .tb-panel--result {
  padding: 22px 20px; border-radius: 24px; text-align: center;
  background: color-mix(in srgb, var(--tb-surface), transparent 6%); border: 3px solid color-mix(in srgb, var(--tb-surface), white 35%);
  box-shadow: 0 7px 0 color-mix(in srgb, var(--tb-accent), transparent 80%), 0 13px 28px #293e702b;
}
.tb-eyebrow { display: block; font-size: 10px; letter-spacing: 2.4px; font-weight: 900; margin: 0 0 12px; color: var(--tb-ink); text-transform: uppercase; }
.tb-word {
  margin: 0; font-family: var(--font-body); font-size: 56px; font-weight: 900; line-height: .9; letter-spacing: -2.5px; text-transform: none;
  color: var(--tb-ink); text-shadow: 0 3px 0 color-mix(in srgb, var(--tb-surface), transparent 45%);
}
.tb-word em { font-style: normal; color: var(--tb-accent); }
.tb-stage .tb-title { margin: 0; font-family: var(--font-body); font-size: 26px; font-weight: 900; line-height: 1.15; color: var(--tb-ink); letter-spacing: -.3px; }
.tb-tagline { font-size: 13px; font-weight: 800; line-height: 1.5; margin: 12px 0 16px; }
.tb-records { display: flex; gap: 12px; margin: 16px 0 14px; text-align: start; }
.tb-records > div {
  flex: 1; min-inline-size: 0; display: grid; gap: 5px; padding: 11px 13px; border-radius: 15px;
  background: var(--tb-surface); border: 1px solid color-mix(in srgb, var(--tb-border), white 35%);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--tb-accent), transparent 88%);
}
.tb-records > div:last-child { text-align: end; }
.tb-records span { font-size: 9px; font-weight: 900; letter-spacing: .8px; }
.tb-records b { font-size: 26px; line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
.tb-records small { font-size: 11px; font-weight: 700; color: var(--tb-muted); }
.tb-launch {
  inline-size: 100%; min-block-size: 55px; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 15px;
  border-radius: 17px; border: 1px solid #ffffff5e; background: var(--tb-hot); color: var(--tb-button-ink);
  font-family: var(--font-body); font-weight: 900; font-size: 17px; cursor: pointer; text-align: start;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--tb-accent), black 18%), 0 9px 18px #34389322;
  transition: transform var(--dur-fast, 120ms) var(--ease), box-shadow var(--dur-fast, 120ms) var(--ease);
}
.tb-launch > span { font-size: 25px; line-height: 1; }
.tb-launch:hover { filter: brightness(1.05); }
.tb-launch:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--tb-accent), black 18%); }
.tb-ghost {
  inline-size: 100%; min-block-size: 46px; margin-block-start: 12px; border-radius: 15px; cursor: pointer;
  font-family: var(--font-body); font-weight: 800; font-size: 15px; color: var(--tb-ink);
  background: color-mix(in srgb, var(--tb-surface), transparent 8%); border: 2px solid var(--tb-border);
}
.tb-how { font-size: 12px; line-height: 1.65; text-align: center; margin: 14px 0 18px; font-weight: 700; }
.tb-sub { font-size: 13px; margin: 0 0 16px; color: var(--tb-muted); font-weight: 700; }
.tb-sub b { color: var(--tb-ink); }
.tb-best-badge {
  display: inline-block; margin: 10px 0 0; padding: 4px 12px; border-radius: 99px;
  background: var(--tb-hot); color: var(--tb-button-ink); font-weight: 900; font-size: 13px;
}
.tb-finishes > span, .tb-next > span { font-size: 9px; font-weight: 900; letter-spacing: 1.2px; }
.tb-finishes > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-block-start: 10px; }
.tb-finish {
  padding: 9px 5px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; cursor: pointer;
  background: color-mix(in srgb, var(--tb-surface), transparent 8%); border: 2px solid var(--tb-border); box-shadow: 0 3px 0 #27305a13;
  color: var(--tb-ink); font-family: var(--font-body);
}
.tb-finish[aria-pressed="true"] { border-color: var(--tb-accent); box-shadow: 0 3px 0 var(--tb-accent); background: var(--tb-surface); }
.tb-finish:disabled { opacity: .53; cursor: default; }
.tb-finish strong { font-size: 12px; font-weight: 900; }
.tb-finish small { font-size: 10px; margin-block-start: 4px; line-height: 1.3; text-align: center; }
.tb-finish > i { display: flex; align-items: flex-end; gap: 3px; block-size: 30px; margin: 2px 0 8px; }
.tb-finish > i > b { inline-size: 13px; block-size: 20px; border-radius: 2px 2px 0 0; background: #ff7964; box-shadow: inset -3px 0 #10396845, inset 0 2px 0 #ffffff88; }
.tb-finish > i > b:nth-child(2) { block-size: 30px; background: #00bde8; }
.tb-finish > i > b:nth-child(3) { block-size: 25px; background: #9956f5; }
.tb-finish--lagoon > i > b { background: #06d5a9; }
.tb-finish--lagoon > i > b:nth-child(2) { background: #428cff; }
.tb-finish--lagoon > i > b:nth-child(3) { background: #ffbd29; }
.tb-finish--afterglow > i > b { background: #ff59ac; }
.tb-finish--afterglow > i > b:nth-child(2) { background: #38d6ff; }
.tb-finish--afterglow > i > b:nth-child(3) { background: #ffce41; }
.tb-next { margin-block-start: 18px; padding-block-start: 14px; border-block-start: 1px solid var(--tb-border); text-align: start; }
.tb-next > b { display: block; font-size: 13px; margin: 7px 0 10px; }
.tb-next > div { block-size: 6px; border-radius: 4px; background: var(--tb-soft); overflow: hidden; }
.tb-next i { display: block; block-size: 100%; border-radius: 4px; background: var(--tb-accent); }
.tb-fx {
  margin-block-start: 14px; inline-size: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 12px; cursor: pointer; font-family: var(--font-body); font-size: 12px; color: var(--tb-ink);
  background: color-mix(in srgb, var(--tb-surface), transparent 30%); border: 1px solid var(--tb-border);
}
.tb-fx span { font-weight: 800; }
.tb-fx b { font-weight: 900; color: var(--tb-accent); }
.tb-overlay button:focus-visible { outline: 2px solid var(--tb-ink); outline-offset: 2px; }

/* Wide stage: the lobby is a card at the start edge and the preview tower shows beside it. */
@container tb (min-width: 700px) {
  .tb-overlay[data-kind="lobby"] { justify-content: flex-start; padding: 22px 28px; background: linear-gradient(90deg, color-mix(in srgb, var(--tb-bg), transparent 15%), transparent 62%); }
  [dir="rtl"] .tb-overlay[data-kind="lobby"] { background: linear-gradient(270deg, color-mix(in srgb, var(--tb-bg), transparent 15%), transparent 62%); }
  .tb-panel--lobby { margin: auto 0; padding: 20px 22px; border-radius: 24px; background: color-mix(in srgb, var(--tb-surface), transparent 22%); box-shadow: 0 13px 28px #293e701f; }
  .tb-panel--lobby .tb-word { font-size: 46px; }
  .tb-panel--lobby .tb-word br { display: none; }
  .tb-panel--lobby .tb-word em { margin-inline-start: .22em; }
  .tb-panel--lobby .tb-tagline { margin: 10px 0 12px; }
  .tb-panel--lobby .tb-records { margin: 12px 0; }
  .tb-panel--lobby .tb-records > div { padding: 9px 12px; }
  .tb-panel--lobby .tb-how { margin: 10px 0 12px; }
  .tb-panel--lobby .tb-finish > i { block-size: 24px; margin-block-end: 5px; }
  .tb-panel--lobby .tb-next { margin-block-start: 12px; padding-block-start: 10px; }
  .tb-panel--lobby .tb-fx { margin-block-start: 10px; }
}
@container tb (max-width: 380px) {
  .tb-word { font-size: 46px; }
  .tb-records b { font-size: 22px; }
  .tb-hud { padding-inline: 16px; }
  .tb-hud b { font-size: 24px; }
}

/* ── play layer: the stage takes the slot ── */
.play-slot .tb-play { inline-size: min(100%, 1100px); gap: var(--space-2); }
.play-slot .tb-card { padding: 0; border: 0; background: none; box-shadow: none; }
/* the shell's top bar already shows the score and the best: the HUD keeps the floor count */
.play-slot .tb-hud__side { visibility: hidden; }

/* ── page bits under the game ── */
.tb-lb-cta { display: flex; justify-content: center; margin-block: var(--space-4); }

/* ── reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .tb-praise.is-on { animation: none; opacity: 1; }
  .tb-launch { transition: none; }
}

/* ── /tower-blocks-leaderboard/: Season 2 + Classic ── */
.tb-classic[hidden], .tb-season2[hidden] { display: none !important; }
.tb-classic-note { text-align: center; color: var(--text-muted); max-inline-size: 70ch; margin: 0 auto var(--space-3); }
.tb-classic .lb-categories { margin-block-end: var(--space-3); }

/* A phone lobby grows with its controls; the live tower keeps its fixed stage. */
@media (max-width: 700px) {
  .tb-stage.is-lobby { block-size: auto; min-block-size: var(--tb-h); }
  .tb-stage.is-lobby > .tb-overlay[data-kind="lobby"] {
    position: relative; inset: auto; min-block-size: var(--tb-h);
    overflow: visible; overscroll-behavior: auto;
  }
}
