/* Kalshi Sans — from the official brand kit (kalshi.com/brandkit) */
@font-face {
  font-family: 'Kalshi Sans';
  src: url('assets/fonts/KalshiSans_Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Kalshi Sans';
  src: url('assets/fonts/KalshiSans_Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Kalshi Sans';
  src: url('assets/fonts/KalshiSans_Semibold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Kalshi Sans';
  src: url('assets/fonts/KalshiSans_Bold.woff2') format('woff2');
  font-weight: 700 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Kalshi Sans Condensed';
  src: url('assets/fonts/KalshiSansCondensed_Semibold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Kalshi Sans Condensed';
  src: url('assets/fonts/KalshiSansCondensed_Bold.woff2') format('woff2');
  font-weight: 700 900; font-style: normal; font-display: swap;
}

:root {
  --green: #00DD94;
  --green2: #00CE8E;
  --dark: #01201A;
  --near-black: #0B0F0E;
  --red: #FF4E64;
  --gold: #FFD24A;
  --blue: #39C2FF;
  --panel: rgba(11, 15, 14, 0.86);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--near-black);
  font-family: "Kalshi Sans", "Trebuchet MS", "Segoe UI", sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#timer {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  font-size: clamp(26px, 4.5vw, 40px); font-weight: 800; color: #fff;
  background: rgba(1, 32, 26, 0.78); padding: 4px 18px; border-radius: 8px;
  border: 2px solid var(--green); letter-spacing: 2px; font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}
#timer.urgent { color: var(--red); border-color: var(--red); animation: pulse 1s infinite; }

#score {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  font-size: clamp(22px, 4vw, 34px); font-weight: 800; color: var(--green);
  background: rgba(1, 32, 26, 0.78); padding: 4px 16px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}

#run-info {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
#run-info div {
  min-width: 86px; padding: 6px 9px; border-radius: 8px;
  background: rgba(1, 32, 26, 0.76); border: 1px solid rgba(0,221,148,0.26);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
#run-info span, #combo-readout span {
  display: block; color: #9fc4b5; font-size: 10px; font-weight: 800;
  letter-spacing: 1px; line-height: 1.1;
}
#run-info strong {
  display: block; margin-top: 3px; color: #fff; font-size: 16px; font-weight: 900;
  font-variant-numeric: tabular-nums;
}

#combo-readout {
  position: absolute; top: max(64px, calc(env(safe-area-inset-top) + 58px)); left: 50%;
  transform: translateX(-50%); min-width: 92px; padding: 7px 14px 8px;
  background: rgba(1, 32, 26, 0.72); border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); text-align: center;
}
#combo-readout strong {
  display: block; color: #fff; font-size: 18px; font-weight: 900; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
#combo-readout[data-tier="warm"] strong { color: var(--gold); }
#combo-readout[data-tier="hot"] strong {
  color: var(--gold); text-shadow: 0 0 14px rgba(255,210,74,0.55);
}

#combo {
  position: absolute; top: 56%; left: 50%; transform: translate(-50%, 0);
  font-size: clamp(20px, 3.5vw, 30px); font-weight: 900; color: var(--gold);
  text-shadow: 0 2px 8px rgba(0,0,0,0.7); letter-spacing: 1px;
}
#combo.pop { animation: comboPop 0.3s; }

#announce {
  position: absolute; top: 32%; left: 50%; transform: translateX(-50%);
  font-size: clamp(24px, 5vw, 44px); font-weight: 900; color: #fff; white-space: nowrap;
  text-shadow: 0 3px 12px rgba(0,0,0,0.8); animation: announceIn 1.5s forwards;
}

#powerups {
  position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
#powerups .chip {
  position: relative; overflow: hidden;
  padding: 4px 12px; border-radius: 20px; font-weight: 800; font-size: 14px;
  background: rgba(1, 32, 26, 0.82); border: 2px solid currentColor;
  box-shadow: 0 6px 18px rgba(0,0,0,0.24);
}
#powerups .chip::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--pct, 100%);
  background: currentColor; opacity: 0.16;
}
#powerups .chip span { position: relative; }

#crosshair {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 28px; height: 28px; opacity: 0.9; transition: opacity 0.1s;
  --cooldown-angle: 360deg; --hit-color: var(--gold);
}

#crosshair::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  background: conic-gradient(var(--green) var(--cooldown-angle), rgba(255,255,255,0.16) 0deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
}
#crosshair::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border-top: 3px solid var(--hit-color); border-bottom: 3px solid var(--hit-color);
  opacity: 0; transform: rotate(45deg) scale(0.7);
}
#crosshair span {
  position: absolute; inset: 0; border: 2.5px solid #fff; border-radius: 50%;
  box-shadow: 0 0 4px rgba(0,0,0,0.6), inset 0 0 4px rgba(0,0,0,0.6);
  transition: border-color 0.12s, transform 0.12s;
}
#crosshair span::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 4px; height: 4px;
  background: var(--green); border-radius: 50%; transform: translate(-50%, -50%);
}
#crosshair.cooling { opacity: 0.55; }
#crosshair.hit span { border-color: var(--hit-color); transform: scale(1.18); }
#crosshair.hit::after { animation: hitMark 0.18s ease-out; }
#crosshair.penalty { --hit-color: var(--red); }

@keyframes pulse { 50% { transform: translateX(-50%) scale(1.08); } }
@keyframes comboPop { 50% { transform: translate(-50%, 0) scale(1.45); } }
@keyframes hitMark {
  0% { opacity: 0; transform: rotate(45deg) scale(0.6); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: rotate(45deg) scale(1.25); }
}
@keyframes announceIn {
  0% { transform: translateX(-50%) scale(0.4); opacity: 0; }
  12% { transform: translateX(-50%) scale(1.15); opacity: 1; }
  22% { transform: translateX(-50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Touch controls ---------- */
#touch-ui { position: fixed; inset: 0; z-index: 20; pointer-events: none; }

#joystick {
  position: absolute; left: max(24px, calc(env(safe-area-inset-left) + 24px));
  bottom: max(70px, calc(env(safe-area-inset-bottom) + 70px)); width: 124px; height: 124px;
  border-radius: 50%; background: rgba(255,255,255,0.08);
  border: 2px solid rgba(0,221,148,0.5);
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px;
  border-radius: 50%; background: rgba(0,221,148,0.55);
  border: 2px solid var(--green);
  transform: translate(-50%, -50%);
}

#throw-btn {
  position: absolute; right: max(24px, calc(env(safe-area-inset-right) + 24px));
  bottom: max(66px, calc(env(safe-area-inset-bottom) + 66px)); width: 110px; height: 110px;
  border-radius: 50%; font-size: 52px; pointer-events: auto;
  background: rgba(0, 221, 148, 0.25); border: 3px solid var(--green);
  color: #fff; cursor: pointer;
}
#throw-btn:active { background: rgba(0, 221, 148, 0.6); transform: scale(0.93); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(1,32,26,0.92), rgba(4,10,9,0.97));
  overflow-y: auto; padding: 16px;
  touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}

.panel {
  text-align: center; color: #fff; max-width: 560px; width: 100%;
  background: var(--panel); border: 2px solid rgba(0,221,148,0.35);
  border-radius: 8px; padding: clamp(18px, 4vh, 36px) clamp(16px, 4vw, 40px);
  box-shadow: 0 0 60px rgba(0, 221, 148, 0.12);
}
.panel.small { max-width: 320px; }

.panel .logo { width: min(220px, 50%); margin-bottom: 4px; }

/* baseline alignment keeps the two title words locked together */
.logo-row { display: flex; align-items: baseline; justify-content: center; gap: 15px; margin-bottom: 2px; }
.logo-row .logo { margin-bottom: 0; width: 200px; }
.logo-word,
.logo-gay {
  font-size: 80px; font-weight: 700; color: var(--green);
  letter-spacing: 0; line-height: 1;
  text-shadow: 0 0 18px rgba(0,221,148,0.35);
}
@media (max-width: 600px) {
  .logo-row .logo { width: 45%; }
  .logo-word,
  .logo-gay { font-size: 15vw; }
}

.panel h1 {
  font-family: "Kalshi Sans Condensed", "Kalshi Sans", "Trebuchet MS", sans-serif;
  font-size: clamp(26px, 6vw, 46px); font-weight: 700; letter-spacing: 1px;
  line-height: 1.2; color: var(--green); text-shadow: 0 0 24px rgba(0,221,148,0.45);
  margin-bottom: 4px;
}
.panel h2 { font-size: clamp(28px, 6vw, 44px); font-weight: 900; letter-spacing: 4px; color: var(--green); }

.tagline { color: #cfe8de; font-size: clamp(13px, 2.5vw, 16px); margin-bottom: 8px; }
.disclaimer {
  color: #9fc4b5; font-size: clamp(11px, 2vw, 13px); font-weight: 600;
  line-height: 1.35; margin: 0 auto 14px; max-width: 420px;
}

.menu-stats {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 0 16px;
}
.menu-stats span {
  padding: 6px 10px; border-radius: 8px; color: #cfe8de; font-size: 12px;
  font-weight: 800; letter-spacing: 1px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
}
.menu-stats strong { color: var(--gold); font-variant-numeric: tabular-nums; }

.controls-hint { font-size: clamp(12px, 2.4vw, 15px); color: #cfe8de; margin-bottom: 18px; }
body.is-mobile .desktop-only { display: none; }
body:not(.is-mobile) .mobile-only { display: none; }

.big-btn {
  font-family: inherit; font-size: clamp(18px, 3.6vw, 24px); font-weight: 900; letter-spacing: 2px;
  color: var(--dark); background: var(--green); border: none; border-radius: 8px;
  padding: 14px 38px; cursor: pointer; transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 24px rgba(0,221,148,0.4);
}
.big-btn:hover { transform: scale(1.04); box-shadow: 0 6px 32px rgba(0,221,148,0.6); }
.big-btn:active { transform: scale(0.97); }

.best-line { margin-top: 14px; color: #9fc4b5; font-size: 14px; font-weight: 600; }
.best-line span { color: var(--gold); }

.ghost-btn {
  margin-top: 12px; font-family: inherit; font-size: clamp(13px, 2.6vw, 16px); font-weight: 800;
  letter-spacing: 1px; color: var(--green); background: transparent;
  border: 2px solid rgba(0,221,148,0.45); border-radius: 8px; padding: 10px 26px; cursor: pointer;
  transition: background 0.1s, transform 0.1s;
}
.ghost-btn:hover { background: rgba(0,221,148,0.12); transform: scale(1.03); }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.pause-readout {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0;
}
.pause-readout div {
  padding: 9px 6px; border-radius: 8px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
}
.pause-readout span {
  display: block; color: #fff; font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.pause-readout label {
  display: block; margin-top: 4px; color: #9fc4b5; font-size: 10px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase;
}

/* Achievements — all 18 badges as squares, no scrolling */
.panel.wide { max-width: 860px; }
.ach-progress { color: #9fc4b5; font-size: 14px; font-weight: 700; letter-spacing: 1px; margin: 6px 0 14px; }
#badge-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 18px;
}
.badge-card {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; overflow: hidden; padding: 4px 5px;
  background: rgba(0,221,148,0.07); border: 1px solid rgba(0,221,148,0.35);
  border-radius: 8px;
}
.badge-card .b-icon { font-size: clamp(18px, 2.6vw, 30px); line-height: 1.15; }
.badge-card .b-name { font-weight: 800; font-size: clamp(9px, 1.1vw, 12px); color: #fff; margin: 4px 0 3px; line-height: 1.15; }
.badge-card .b-desc { font-size: clamp(8px, 0.95vw, 10.5px); color: #9fc4b5; line-height: 1.3; }
.badge-card.locked {
  filter: grayscale(1); opacity: 0.45;
  border-color: rgba(255,255,255,0.18); background: rgba(255,255,255,0.04);
}
@media (max-width: 700px) {
  #badge-grid { grid-template-columns: repeat(3, 1fr); }
  .badge-card .b-name { font-size: 11px; }
  .badge-card .b-desc { font-size: 9.5px; }
  #run-info { grid-template-columns: 1fr; gap: 4px; }
  #run-info div { min-width: 78px; padding: 5px 7px; }
  #run-info strong { font-size: 14px; }
  #combo-readout { top: max(58px, calc(env(safe-area-inset-top) + 52px)); min-width: 76px; padding: 6px 10px; }
  #combo-readout strong { font-size: 16px; }
}

/* End-of-run badges */
.run-badges {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
  margin: 4px 0 8px;
}
.rb-title { width: 100%; color: var(--gold); font-weight: 900; letter-spacing: 2px; font-size: 14px; }
.rb-chip {
  background: rgba(255,210,74,0.12); border: 1px solid var(--gold); color: #fff;
  border-radius: 16px; padding: 4px 12px; font-size: 13px; font-weight: 700;
}

/* Game over */
.rank { font-size: clamp(15px, 3vw, 19px); font-weight: 800; color: var(--gold); letter-spacing: 3px; margin-top: 10px; }
.final-score {
  font-size: clamp(48px, 11vw, 84px); font-weight: 900; color: var(--green);
  text-shadow: 0 0 30px rgba(0,221,148,0.5); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.new-best { color: var(--gold); font-weight: 900; font-size: 20px; letter-spacing: 2px; animation: pulse2 0.8s infinite; margin: 4px 0; }
@keyframes pulse2 { 50% { opacity: 0.4; } }

.stats { display: flex; justify-content: center; gap: clamp(14px, 4vw, 34px); margin: 18px 0; }
.stats div { display: flex; flex-direction: column; }
.stats span { font-size: clamp(20px, 4.5vw, 30px); font-weight: 800; color: #fff; }
.stats label { font-size: 11px; color: #9fc4b5; text-transform: uppercase; letter-spacing: 1px; }

@media (max-height: 480px) {
  .panel { padding: 12px 20px; }
  .panel .logo { width: 120px; }
}

@media (max-height: 480px) and (orientation: landscape) {
  body.is-mobile #gameover.overlay {
    align-items: flex-start;
    padding:
      max(8px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  body.is-mobile #gameover .panel {
    max-width: min(820px, 100%);
    padding: 10px 14px;
    display: grid;
    grid-template-columns: minmax(190px, 0.82fr) minmax(300px, 1.18fr);
    grid-template-areas:
      "title stats"
      "rank stats"
      "score badges"
      "newbest badges"
      "best replay"
      "best secondary";
    column-gap: 14px;
    row-gap: 4px;
    align-items: center;
  }

  body.is-mobile #gameover h2 {
    grid-area: title;
    font-size: 25px;
    line-height: 1;
    letter-spacing: 0;
  }

  body.is-mobile #gameover .rank {
    grid-area: rank;
    margin-top: 0;
    font-size: 14px;
    line-height: 1.1;
    letter-spacing: 0;
  }

  body.is-mobile #gameover .final-score {
    grid-area: score;
    font-size: 52px;
    line-height: 0.98;
  }

  body.is-mobile #gameover .new-best {
    grid-area: newbest;
    margin: 0;
    font-size: 15px;
    line-height: 1.1;
    letter-spacing: 0;
  }

  body.is-mobile #gameover .stats {
    grid-area: stats;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
  }

  body.is-mobile #gameover .stats div {
    min-width: 0;
  }

  body.is-mobile #gameover .stats span {
    font-size: 19px;
    line-height: 1.05;
  }

  body.is-mobile #gameover .stats label {
    font-size: 9px;
    line-height: 1.15;
    letter-spacing: 0;
  }

  body.is-mobile #gameover .run-badges {
    grid-area: badges;
    gap: 5px;
    margin: 0;
    align-self: center;
  }

  body.is-mobile #gameover .rb-title {
    font-size: 11px;
    line-height: 1.15;
    letter-spacing: 0;
  }

  body.is-mobile #gameover .rb-chip {
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 11px;
    line-height: 1.2;
  }

  body.is-mobile #gameover .best-line {
    grid-area: best;
    margin-top: 0;
    font-size: 12px;
    align-self: center;
  }

  body.is-mobile #gameover #restart-btn {
    grid-area: replay;
    justify-self: center;
    padding: 10px 28px;
    font-size: 18px;
    line-height: 1;
  }

  body.is-mobile #gameover .gameover-secondary {
    grid-area: secondary;
    justify-self: center;
  }

  body.is-mobile #gameover #ach-btn-over {
    margin-top: 2px;
    padding: 8px 18px;
    font-size: 12px;
    line-height: 1;
  }
}
