/* ClickStreak. Elite Fusion brand: steel blue on white, grey text, silver dividers. */

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("/fonts/roboto-latin-300-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/roboto-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/roboto-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/montserrat-latin-600-normal.woff2") format("woff2");
}

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #2e2e2e;
  --text-2: #3b3b3b;
  --muted: #666666;
  --line: #eaeaea;
  --border: #e0e0e0;
  --accent: #4682b4;
  --accent-strong: #3c6f9d; /* small text and pressed states (AA on white) */
  --accent-text: #3c6f9d;
  --accent-tint: rgba(70, 130, 180, 0.08);
  --accent-hover: #3f78a8; /* between steel and steel dark: hover darkens, press darkens more */
  --press-tint: rgba(46, 46, 46, 0.05);
  --on-accent: #ffffff;
  --danger: #c73a30;
  --danger-fill: #c73a30; /* white text on it: 5.2:1 */
  --focus: #4682b4;
  --shadow-rest: 0 12px 28px -14px rgba(46, 46, 46, 0.45);
  --shadow-down: 0 4px 10px -6px rgba(46, 46, 46, 0.45);
  --panel-shadow: 0 12px 32px -16px rgba(46, 46, 46, 0.22);
  --backdrop: rgba(14, 19, 24, 0.4);
  --font-head: "Montserrat", "Poppins", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Roboto", "Open Sans", -apple-system, "Segoe UI", Arial, sans-serif;
  --btn-size: 224px;
  --ring-ms: 600ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1318;
    --surface: #161d25;
    --text: #e6edf3;
    --text-2: #c9d4de;
    --muted: #8b9bab;
    --line: #27313d;
    --border: #27313d;
    --accent: #4682b4;
    --accent-strong: #3a6d97;
    --accent-text: #5b9bd0;
    --accent-tint: rgba(91, 155, 208, 0.1);
    --accent-hover: #4f8cc0; /* dark UI: hover lifts toward steel light */
    --press-tint: rgba(230, 237, 243, 0.06);
    --danger: #e0563d;
    --danger-fill: #b8432f; /* #e0563d under white text is only 3.8:1; this is 5.4:1 */
    --focus: #5b9bd0;
    --shadow-rest: 0 12px 28px -14px rgba(0, 0, 0, 0.7);
    --shadow-down: 0 4px 10px -6px rgba(0, 0, 0, 0.7);
    --panel-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.6); /* a dark page needs a deeper dim to set the panel apart */
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
  color: inherit;
}
button {
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
.wordmark {
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 10;
  padding: 8px 16px;
  border-radius: 6px;
  background: var(--accent-strong);
  color: var(--on-accent);
  font-weight: 500;
  text-decoration: none;
}
.skip:focus {
  top: 16px;
}

/* --- layout ---------------------------------------------------------------------- */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 24px 40px;
  padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 24px)); /* clear the home indicator */
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
}

.wordmark {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.wordmark-accent {
  color: var(--accent-text);
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 44px;
  max-width: 62%;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  line-height: 42px;
  white-space: nowrap;
  transition: border-color 120ms ease;
}
.chip:active {
  background: var(--press-tint);
}
.chip-label {
  color: var(--muted);
}
.chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: var(--text);
}

/* --- hero ------------------------------------------------------------------------ */
.hero {
  margin-top: 40px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.global {
  --fit: 88px;
  /* A fixed line box (the unshrunk size from fitGlobal) so the page below never moves
     when a longer number makes the digits smaller. */
  --line: calc(clamp(40px, 18vw, 88px) * 1.1);
  height: var(--line);
  margin: 8px 0 0;
  font-family: var(--font-body);
  font-weight: 300;
  font-size: var(--fit);
  line-height: var(--line);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
  overflow: hidden;
  color: var(--text);
}

.sub {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 24px;
  color: var(--muted);
}

/* --- the button ------------------------------------------------------------------ */
.press {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 40px;
}

.button-wrap {
  position: relative;
  width: var(--btn-size);
  height: var(--btn-size);
}

.big {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: var(--shadow-rest);
  transform: scale(1);
  transition:
    transform 140ms cubic-bezier(0.2, 0.7, 0.3, 1),
    box-shadow 140ms ease,
    background-color 140ms ease,
    opacity 200ms ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.big:not(.is-live) {
  opacity: 0.85; /* lowest that keeps the white label at 3:1 on both themes */
  cursor: progress;
  box-shadow: none;
}
.big.is-live:active {
  background: var(--accent-strong);
}
.big.is-down {
  transform: scale(0.965);
  box-shadow: var(--shadow-down);
  background: var(--accent-strong);
  transition-duration: 40ms;
}
.big:focus-visible {
  outline-offset: 6px;
}

.ring {
  position: absolute;
  inset: 0;
  z-index: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  animation: ring var(--ring-ms) cubic-bezier(0.2, 0.6, 0.35, 1) forwards;
}

@keyframes ring {
  from {
    opacity: 0.5;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(1.32);
  }
}

.status {
  min-height: 24px;
  margin: 24px 0 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.verify {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  text-align: center;
}
.verify-text {
  max-width: 34ch;
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
}
.verify-widget {
  min-height: 65px;
}
.ts-hidden {
  height: 0;
  overflow: hidden;
}
.ts-hidden.is-visible {
  height: auto;
  margin-top: 8px;
}

/* --- your counters --------------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 24px 8px 16px;
}
.stat + .stat {
  border-left: 1px solid var(--line);
}

.stat-label {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  font-size: 32px;
  line-height: 40px; /* fixed, so the smaller long-number sizes do not move the row */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
}
.stat-value.is-long {
  font-size: 20px;
}
.stat-value.is-xlong {
  font-size: 16px;
}

.best {
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 0 24px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.best span {
  color: var(--text-2);
}

/* --- leaderboard ----------------------------------------------------------------- */
.board {
  margin-top: 56px;
}

.board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.board-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.board-sub {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0;
  color: var(--muted);
}

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.seg-btn {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    color 120ms ease;
}
.seg-btn[aria-pressed="true"] {
  background: var(--accent-strong);
  color: var(--on-accent);
}

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

.lb-row {
  display: grid;
  grid-template-columns: 3.5ch minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.lb-rank {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}
/* Player names are data, not prose: no "fl"/"fi" ligatures merging their letters. */
.chip-name,
.lb-name,
.you,
.input,
.key {
  font-variant-ligatures: none;
}

.lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-count {
  color: var(--text-2);
  text-align: right;
}
.lb-row.is-me {
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent);
}
.lb-row.is-me .lb-rank,
.lb-row.is-me .lb-name {
  color: var(--accent-text);
  font-weight: 500;
}

.board-empty {
  margin: 0;
  padding: 24px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.more {
  display: block;
  min-height: 44px;
  margin: 8px auto 0;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
}
.more:active {
  opacity: 0.7;
}

.you {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.you-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.you-count {
  flex: none;
}
.you strong {
  color: var(--accent-text);
  font-weight: 500;
}
.you .linkish {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding-block: 11px;
  margin-block: -11px;
  flex: none;
  white-space: nowrap;
}

/* --- footer ---------------------------------------------------------------------- */
.foot {
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.foot p {
  margin: 0;
}
.foot-small {
  max-width: 56ch;
  margin: 8px auto 0 !important;
  font-size: 12px;
  line-height: 20px;
}

/* --- player panel ---------------------------------------------------------------- */
.panel {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--panel-shadow);
  overflow: auto;
  overscroll-behavior: contain;
}
.panel::backdrop {
  background: var(--backdrop);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px 24px;
}
.panel-title {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:active {
  background: var(--press-tint);
}

.block {
  margin: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}
.block:first-of-type {
  border-top: 0;
}
.block-last {
  padding-bottom: 24px;
}

.label {
  display: block;
  margin: 0;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}
.hint {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.input {
  flex: 1 1 180px;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.input:focus-visible {
  outline-offset: 0;
  border-color: var(--accent);
}
.mono,
.key {
  font-family: "Roboto Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.key {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-size: 15px;
  line-height: 42px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow-x: auto;
  user-select: all;
}

.btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background-color 120ms ease;
}
.btn:active:not(:disabled) {
  background: var(--press-tint);
}
.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}
.btn-primary {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--on-accent);
}
.btn-primary:active:not(:disabled) {
  background: var(--accent-strong);
  filter: brightness(0.92);
}
.btn-quiet {
  color: var(--text-2);
}
.btn-danger {
  border-color: var(--danger-fill);
  background: var(--danger-fill);
  color: #ffffff;
}
.btn-danger:active:not(:disabled) {
  background: var(--danger-fill);
  filter: brightness(0.92);
}

.msg {
  min-height: 0;
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.msg:empty {
  margin: 0;
}
.msg.is-error {
  color: var(--danger);
}
.msg.is-ok {
  color: var(--accent-text);
}

.confirm {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--danger);
  border-radius: 8px;
}
.confirm-text {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-2);
}

/* --- hover (real pointers only) ------------------------------------------------------ */
@media (hover: hover) {
  .big.is-live:not(.is-down):hover {
    background: var(--accent-hover);
  }
  .chip:hover,
  .btn:hover:not(:disabled) {
    border-color: var(--accent);
  }
  .seg-btn:hover:not([aria-pressed="true"]),
  .icon-btn:hover {
    color: var(--text);
  }
  /* Filled buttons darken on hover: a lighter fill would drop white text below 4.5:1. */
  .btn-primary:hover:not(:disabled):not(:active),
  .btn-danger:hover:not(:disabled):not(:active) {
    filter: brightness(0.95);
  }
  .btn-primary:hover:not(:disabled) {
    border-color: var(--accent-strong);
  }
  .btn-danger:hover:not(:disabled) {
    border-color: var(--danger-fill);
  }
  .more:hover,
  .you .linkish:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
  }
}

/* --- small screens ----------------------------------------------------------------- */
@media (max-width: 480px) {
  :root {
    --btn-size: 184px;
  }
  .page {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .hero {
    margin-top: 32px;
  }
  .press {
    margin-top: 32px;
  }
  .stat-value {
    font-size: 26px;
    line-height: 32px;
  }
  .board {
    margin-top: 48px;
  }
  .board-head {
    flex-direction: column;
    align-items: stretch;
  }
  .seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .seg-btn {
    min-height: 44px; /* a thumb target on phones */
  }
  .chip-label {
    display: none;
  }
  .key {
    flex-basis: 100%;
    font-size: 14px;
    letter-spacing: 0;
  }
  .input.mono {
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  :root {
    --btn-size: 168px;
  }
  .wordmark {
    font-size: 18px;
  }
  .stat-value.is-xlong {
    font-size: 14px;
  }
  .lb-row {
    gap: 8px;
    padding: 0 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .big,
  .big.is-down,
  .chip,
  .seg-btn,
  .btn {
    transition: none;
  }
  .ring {
    display: none;
  }
}
