/* ─── Reset ─────────────────────────────────────────────── */

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

/* ─── Page ───────────────────────────────────────────────── */

body {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Space Grotesk', sans-serif;
  user-select: none;
  -webkit-user-select: none;
  padding: 24px 20px;
}

/* ─── Screen management ──────────────────────────────────── */

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ─── Global counter ─────────────────────────────────────── */

#global-counter {
  position: fixed;
  top: 16px;
  right: 20px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #888;
}

/* ─── Home screen ────────────────────────────────────────── */

h1 {
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#home-subtitle {
  font-size: clamp(14px, 3vw, 16px);
  color: #666;
  text-align: center;
}

#mode-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

#mode-descriptions {
  font-size: clamp(13px, 2.5vw, 15px);
  color: #666;
  line-height: 1.9;
  text-align: center;
}

/* ─── Challenge lobby ────────────────────────────────────── */

#challenge-lobby-box {
  border: 2px solid #000;
  width: min(560px, 100%);
  padding: clamp(32px, 6vw, 56px) clamp(24px, 5vw, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

#challenge-lobby-box h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#lobby-status {
  font-size: clamp(14px, 3vw, 15px);
  color: #555;
  min-height: 22px;
}

#lobby-link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  border: 1px solid #ddd;
  padding: 12px 16px;
  width: 100%;
  background: #fafafa;
}

#lobby-link-text {
  font-size: 12px;
  color: #444;
  word-break: break-all;
}

#lobby-copy-confirm {
  font-size: 13px;
  color: #28a745;
  letter-spacing: 0.04em;
}

/* ─── Game box ───────────────────────────────────────────── */

#game-box {
  border: 2px solid #000;
  width: min(580px, 100%);
  min-height: min(480px, 72vh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(32px, 6vw, 60px) clamp(24px, 5vw, 52px);
  gap: 24px;
  transition: background 0.1s;
  cursor: default;
  touch-action: manipulation;
}

#game-box.active {
  background: #ff3b30;
  cursor: pointer;
}

/* ─── Round indicator ────────────────────────────────────── */

#round-indicator {
  font-size: clamp(13px, 2.5vw, 14px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #777;
  min-height: 20px;
}

/* ─── Target time display ────────────────────────────────── */

#target-section {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#target-label {
  font-size: clamp(12px, 2.5vw, 14px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #777;
}

#target-display {
  font-size: clamp(40px, 12vw, 64px);
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* ─── Countdown ──────────────────────────────────────────── */

#countdown {
  font-size: clamp(72px, 22vw, 120px);
  font-weight: 700;
  min-height: clamp(90px, 18vw, 150px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Status message ─────────────────────────────────────── */

#message {
  font-size: clamp(14px, 2.5vw, 16px);
  text-align: center;
  color: #444;
  line-height: 1.7;
  min-height: 22px;
}

/* ─── Round result ───────────────────────────────────────── */

#result-block {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

#result-block.show {
  display: flex;
}

#result-title {
  font-size: clamp(12px, 2.5vw, 14px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #777;
}

#result-your-time {
  font-size: clamp(36px, 11vw, 56px);
  font-weight: 700;
}

#result-diff {
  font-size: clamp(15px, 3vw, 18px);
  font-weight: 600;
}

#result-diff.good { color: #28a745; }
#result-diff.ok   { color: #fd7e14; }
#result-diff.bad  { color: #dc3545; }

/* ─── In-game buttons ────────────────────────────────────── */

#game-buttons {
  display: none;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

#game-buttons.show {
  display: flex;
}

/* ─── Shared button style ────────────────────────────────── */

button {
  padding: 16px 36px;
  background: #000;
  color: #fff;
  border: 2px solid transparent;
  font-family: 'Courier New', monospace; /* intentionally monospace — distinct from body text */
  font-size: clamp(13px, 2.5vw, 14px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-width: 130px;
}

button:hover {
  background: #222;
}

button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

button.secondary {
  background: #fff;
  color: #000;
  border: 2px solid #000;
}

button.secondary:hover {
  background: #f5f5f5;
}

/* ─── Tap hint ───────────────────────────────────────────── */

#click-hint {
  display: none;
  font-size: clamp(13px, 2.5vw, 15px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
  text-align: center;
}

/* ─── Waiting overlay ────────────────────────────────────── */

#waiting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #444;
}

/* ─── Daily results ──────────────────────────────────────── */

#results-box {
  border: 2px solid #000;
  width: min(580px, 100%);
  padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

#results-box h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#rounds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(13px, 3vw, 15px);
}

#rounds-table th,
#rounds-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid #eee;
}

#rounds-table th {
  font-size: clamp(11px, 2.5vw, 13px);
  text-transform: uppercase;
  color: #888;
  padding-bottom: 12px;
}

#total-score-block {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-top: 2px solid #000;
  padding-top: 20px;
}

#total-label {
  font-size: clamp(13px, 2.5vw, 15px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #444;
}

#total-value {
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 700;
}

/* ─── Challenge results ──────────────────────────────────── */

#challenge-results-box {
  border: 2px solid #000;
  width: min(600px, 100%);
  padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

#challenge-winner-text {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}

#challenge-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(12px, 2.8vw, 14px);
}

#challenge-table th,
#challenge-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid #eee;
}

#challenge-table th {
  font-size: clamp(11px, 2.5vw, 13px);
  text-transform: uppercase;
  color: #888;
  padding-bottom: 12px;
}

#challenge-totals-block {
  width: 100%;
  border-top: 2px solid #000;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: clamp(13px, 2.5vw, 15px);
  color: #444;
  letter-spacing: 0.04em;
}

.total-row span:last-child {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 700;
  color: #000;
}

#challenge-result-buttons,
#results-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Share button only makes sense on mobile */
#lobby-share-btn {
  display: none;
}

@media (max-width: 767px) {
  #lobby-share-btn {
    display: block;
  }
}

/* ─── Desktop overrides (768px+) ─────────────────────────── */

@media (min-width: 768px) {
  h1 { font-size: 48px; }

  #home-subtitle    { font-size: 18px; }
  #mode-descriptions { font-size: 16px; }

  #game-box {
    width: 680px;
    min-height: 560px;
    padding: 64px 60px;
    gap: 32px;
  }

  #target-display   { font-size: 72px; }
  #countdown        { font-size: 140px; min-height: 176px; }
  #result-your-time { font-size: 64px; }
  #result-diff      { font-size: 20px; }
  #message          { font-size: 17px; }
  #click-hint       { font-size: 16px; }
  #round-indicator  { font-size: 15px; }

  button {
    padding: 18px 44px;
    font-size: 15px;
    min-width: 150px;
  }

  #results-box,
  #challenge-results-box,
  #challenge-lobby-box {
    width: 660px;
    padding: 56px 52px;
    gap: 32px;
  }

  #results-box h2,
  #challenge-results-box h2,
  #challenge-lobby-box h2 { font-size: 24px; }

  #rounds-table,
  #challenge-table { font-size: 16px; }

  #rounds-table th,
  #challenge-table th { font-size: 13px; }

  #rounds-table th,
  #rounds-table td,
  #challenge-table th,
  #challenge-table td { padding: 14px 10px; }

  #total-value          { font-size: 36px; }
  #challenge-winner-text { font-size: 32px; }
  .total-row            { font-size: 16px; }
  .total-row span:last-child { font-size: 32px; }
}
