/* The Button — the count, the arcade button, celebrations, and stats extras.
   Shared page, button, and stats styles live in /assets/site.css. The navy
   stays navy in dark mode. */

body.game-button {
  --game-bg: #14254F;
  --game-deep: #0B1733;
  --game-accent: #14254F;
  --tb-red: #E5322D;
  --tb-yellow: #FFD23F;
  --tb-muted: #B9C3DA;
  --card-line: #E6ECF7;
  --btn: min(65vw, 280px);
  --count-size: clamp(56px, 17vw, 96px);
}

@media (min-width: 900px) {
  body.game-button {
    --btn: min(360px, max(240px, calc(100vh - 480px)));
    --count-size: 120px;
  }
}

/* ── Count ─────────────────────────────────────────────── */

.tb-count-wrap { text-align: center; padding: 8px 16px 0; }

.tb-count {
  margin: 0;
  font-size: var(--count-size);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: #FFFFFF;
}

.tb-caption {
  margin: 6px 0 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--tb-muted);
}

.tb-now {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--tb-muted);
}

/* Hidden at zero, but keeps its space so the button doesn't jump. */
.tb-now[hidden] { display: inline-flex; visibility: hidden; }

.tb-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3BD16F;
  box-shadow: 0 0 0 0 rgba(59, 209, 111, 0.6);
  animation: tb-pulse 1.8s ease-out infinite;
}

@keyframes tb-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(59, 209, 111, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(59, 209, 111, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 209, 111, 0); }
}

/* ── The Button ────────────────────────────────────────── */

.tb-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(var(--btn) * 1.14);
  height: calc(var(--btn) * 1.14);
  margin: 14px auto 0;
}

.tb-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.tb-ring circle { fill: none; stroke-width: 1.6; }
.tb-ring-track { stroke: rgba(255, 255, 255, 0.1); }

.tb-ring-fill {
  stroke: #FFFFFF;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  opacity: 0.35;
}

.tb-ring-fill.is-filling { animation: tb-ring 1s linear forwards; }

@keyframes tb-ring {
  0%   { stroke-dashoffset: 100; opacity: 1; }
  94%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0.35; }
}

/* The bezel: chunky brushed metal with a drop shadow. */
.tb-button {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--btn);
  height: var(--btn);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #5E6573 0 60%, transparent 61%),
    conic-gradient(from 200deg, #F2F4F7, #9FA6B2, #D9DDE3, #7D8591, #E8EBEF, #A3AAB5, #F2F4F7);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.7),
    inset 0 -3px 5px rgba(0, 0, 0, 0.35),
    0 calc(var(--btn) * 0.04) 0 #2E3440,
    0 calc(var(--btn) * 0.08) calc(var(--btn) * 0.12) rgba(0, 0, 0, 0.5);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* The glossy red dome, standing a few pixels proud of the bezel. */
.tb-dome {
  display: block;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 55% 38% at 50% 24%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 70%),
    radial-gradient(circle at 50% 38%, #FF5A52 0%, var(--tb-red) 48%, #B41D19 88%, #8E1411 100%);
  box-shadow:
    0 calc(var(--btn) * 0.035) 0 #7A0F0C,
    0 calc(var(--btn) * 0.05) calc(var(--btn) * 0.04) rgba(0, 0, 0, 0.45),
    inset 0 -6px 12px rgba(0, 0, 0, 0.25);
  transform: translateY(calc(var(--btn) * -0.03));
  transition: transform 60ms ease, box-shadow 60ms ease, filter 120ms ease;
}

.tb-button:active .tb-dome,
.tb-button.is-down .tb-dome {
  transform: translateY(calc(var(--btn) * 0.004));
  box-shadow:
    0 calc(var(--btn) * 0.006) 0 #7A0F0C,
    0 calc(var(--btn) * 0.01) calc(var(--btn) * 0.015) rgba(0, 0, 0, 0.45),
    inset 0 -4px 10px rgba(0, 0, 0, 0.3);
  filter: brightness(0.94);
}

.tb-button:disabled { cursor: default; }
.tb-button:disabled .tb-dome { filter: saturate(0.5) brightness(0.8); }

body.game-button .tb-button:focus-visible { outline: 3px solid var(--tb-yellow); outline-offset: calc(var(--btn) * 0.09); }

.tb-kbd-hint { margin: 6px 0 0; color: var(--tb-muted); line-height: 1; }
.tb-kbd-hint .kbd { margin: 0; }

/* ── Result and lines under the button ─────────────────── */

.tb-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 92px;
  padding: 12px 16px 0;
  text-align: center;
}

.tb-result-line {
  min-height: 1.3em;
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  color: #FFFFFF;
}

.tb-result-line strong { color: var(--tb-yellow); font-variant-numeric: tabular-nums; }

.tb-celebrate {
  min-height: 1.3em;
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--tb-yellow);
}

.tb-celebrate.is-big { font-size: 26px; font-weight: 900; letter-spacing: 0.01em; }

.tb-message { margin-top: 4px; }

.tb-next,
.tb-visit {
  margin: 6px 16px 0;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  color: var(--tb-muted);
  font-variant-numeric: tabular-nums;
}

.tb-visit { font-size: 14px; font-weight: 500; }

@media (min-width: 900px) {
  .tb-result-line { font-size: 28px; }
  .tb-celebrate { font-size: 22px; }
  .tb-celebrate.is-big { font-size: 30px; }
}

/* ── Full-screen celebration (#100,000 and #1,000,000) ─── */

.tb-party {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 16, 38, 0.88);
  cursor: pointer;
  animation: tb-fade 300ms ease;
}

.tb-party[hidden] { display: none; }

.tb-party-text {
  margin: 0;
  max-width: 900px;
  font-size: clamp(40px, 10vw, 96px);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  color: var(--tb-yellow);
  text-shadow: 0 4px 0 var(--tb-red), 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: tb-throb 900ms ease-in-out infinite alternate;
}

@keyframes tb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tb-throb { from { transform: scale(1); } to { transform: scale(1.06); } }

@media (hover: hover) and (pointer: fine) {
  .tb-button:hover:not(:disabled) .tb-dome { filter: brightness(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .tb-dot, .tb-party, .tb-party-text { animation: none; }
  .tb-dome { transition: none; }
}

/* ── Stats extras ──────────────────────────────────────── */

.tb-hall { margin: 0; padding: 0; list-style: none; }

.tb-hall li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 9px 0 9px 12px;
  border-bottom: 1px solid var(--card-line);
  border-left: 3px solid transparent;
}

.tb-hall li:last-child { border-bottom: 0; }

.tb-hall-n { font-weight: 800; font-variant-numeric: tabular-nums; }
.tb-hall-at { font-size: 13px; color: var(--card-muted); }
.tb-hall-gap { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; font-size: 13px; color: var(--card-muted); }

.tb-hall li.is-10k { border-left-color: var(--tb-yellow); background: #FFFAE6; }
.tb-hall li.is-10k .tb-hall-n { font-size: 20px; }

.tb-hall-more {
  margin-top: 10px;
  padding: 8px 14px;
  border: 1px solid var(--card-line);
  border-radius: 999px;
  background: #FFFFFF;
  color: var(--game-accent);
  font: 700 14px/1 var(--ws-font);
  cursor: pointer;
}

.tb-records { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tb-record { padding: 12px; border-radius: 12px; background: #F3F6FC; }
.tb-record-label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--card-muted); }
.tb-record-value { margin-top: 2px; font-size: 20px; font-weight: 800; }
.tb-record-detail { font-size: 13px; color: var(--card-muted); }

.tb-fun-nums { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }

.tb-fun-nums span {
  padding: 2px 7px;
  border-radius: 999px;
  background: #FFF4C2;
  color: #5A4300;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tb-live { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tb-live .big-number { font-size: 40px; }
.tb-live .detail { margin-top: 2px; }

.tb-big-total { font-size: clamp(56px, 12vw, 96px); letter-spacing: -0.03em; }
