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

html, body {
  width: 100%; height: 100%;
  min-height: 100dvh;
  background: #0a0e18;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Screens ─────────────────────────────────────────────── */

.screen {
  display: none;
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  text-align: center;
}
.screen.active { display: flex; }

/* ── Title screen ────────────────────────────────────────── */

.title-icon { font-size: 3.5rem; margin-bottom: 4px; }

#screen-title h1 {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 5px;
  color: #f5c400;
  text-shadow: 0 0 24px rgba(245,196,0,0.5), 0 2px 0 #8a6e00;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.9rem;
  color: #607080;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.rules-box {
  background: #111827;
  border: 1px solid #1e2d3d;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 24px;
  text-align: left;
  max-width: 400px;
  width: 100%;
}

.rules-box h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #506070;
  margin-bottom: 10px;
}

.rules-box ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rules-box li {
  font-size: 0.9rem;
  color: #8899aa;
  padding-left: 14px;
  position: relative;
  line-height: 1.4;
}

.rules-box li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: #354555;
}

.rules-box .td  { color: #f5c400; font-weight: bold; }
.rules-box .fg  { color: #4aaa66; font-weight: bold; }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  padding: 13px 40px;
  font-size: 1.05rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 1px;
}
.btn:hover  { transform: scale(1.04); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #c8830a, #f5c400);
  color: #0a0e18;
}
.btn-primary:hover { background: linear-gradient(135deg, #d89510, #ffe040); }

.btn-secondary {
  background: #1e2d3d;
  color: #8899aa;
  border: 1px solid #2a3d50;
}
.btn-secondary:hover { background: #253545; color: #aabbc8; }

.hidden { display: none !important; }

/* ── Game screen layout ──────────────────────────────────── */

#screen-game {
  justify-content: flex-start;
  gap: 0;
  padding: 0;
}

/* ── Scoreboard ──────────────────────────────────────────── */

#scoreboard {
  width: 100%;
  background: #07090f;
  border-bottom: 2px solid #1a2535;
  display: flex;
  align-items: stretch;
  padding: 10px 16px;
  gap: 0;
  flex-shrink: 0;
}

.score-team {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.team-label {
  font-size: 0.7rem;
  font-weight: bold;
  letter-spacing: 3px;
  color: #506070;
  text-transform: uppercase;
}

.team-total {
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#score-you .team-total  { color: #f5c400; }
#score-cpu .team-total  { color: #4488ff; }

.quarter-scores {
  display: flex;
  gap: 4px;
}

.qs {
  font-size: 0.7rem;
  color: #304050;
  background: #111827;
  border-radius: 3px;
  padding: 1px 5px;
  min-width: 22px;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s, background 0.3s;
}

.qs.done { color: #607080; background: #151f2c; }
.qs.active { color: #8899aa; background: #1a2535; }

.score-middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  gap: 2px;
}

.quarter-label {
  font-size: 1.1rem;
  font-weight: bold;
  color: #f5c400;
  letter-spacing: 2px;
}

.play-count {
  font-size: 0.65rem;
  color: #354555;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── Field area ──────────────────────────────────────────── */

#field {
  flex: 1;
  width: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent calc(10% - 1px),
      rgba(255,255,255,0.03) calc(10% - 1px),
      rgba(255,255,255,0.03) 10%
    ),
    linear-gradient(180deg, #0f1f10 0%, #0a1a0b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 200px;
}

/* Subtle yard line hash marks */
#field::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 39px,
    rgba(255,255,255,0.025) 39px,
    rgba(255,255,255,0.025) 40px
  );
  pointer-events: none;
}

#field-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px;
  position: relative;
  z-index: 1;
  width: 100%;
}

/* ── Reveal area ─────────────────────────────────────────── */

#reveal-area {
  display: flex;
  align-items: center;
  gap: 20px;
}

.reveal-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.reveal-label {
  font-size: 0.65rem;
  font-weight: bold;
  letter-spacing: 3px;
  color: #405060;
  text-transform: uppercase;
}

.reveal-fingers {
  width: 90px;
  height: 90px;
  background: #0d1a0e;
  border: 2px solid #1e3522;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  font-weight: 900;
  color: #304540;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.reveal-fingers.revealed-you {
  border-color: #a08000;
  color: #f5c400;
  background: #1a1500;
  box-shadow: 0 0 20px rgba(245,196,0,0.15);
}

.reveal-fingers.revealed-cpu {
  border-color: #1a3d88;
  color: #4488ff;
  background: #080d1a;
  box-shadow: 0 0 20px rgba(68,136,255,0.15);
}

.reveal-fingers.td-winner {
  animation: tdPulse 0.5s ease-out 2;
}

@keyframes tdPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.reveal-vs {
  font-size: 1rem;
  font-weight: bold;
  color: #253545;
  letter-spacing: 2px;
}

/* ── Result message ──────────────────────────────────────── */

#result-msg {
  font-size: 1.2rem;
  font-weight: bold;
  min-height: 1.6em;
  letter-spacing: 1px;
  text-align: center;
  transition: opacity 0.2s;
}

.result-td-you   { color: #f5c400; text-shadow: 0 0 12px rgba(245,196,0,0.5); }
.result-td-cpu   { color: #4488ff; text-shadow: 0 0 12px rgba(68,136,255,0.5); }
.result-fg-you   { color: #4aaa66; }
.result-fg-cpu   { color: #cc6644; }
.result-tie      { color: #607080; }

/* ── Controls ────────────────────────────────────────────── */

#controls {
  flex-shrink: 0;
  width: 100%;
  background: #07090f;
  border-top: 2px solid #1a2535;
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#choose-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: #405060;
}

#finger-btns {
  display: flex;
  gap: 14px;
}

.finger-btn {
  width: 80px;
  height: 80px;
  background: #0f1c2a;
  border: 2px solid #1e3040;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.15s;
}

.finger-btn:hover {
  background: #162235;
  border-color: #2a4560;
  transform: translateY(-2px);
}

.finger-btn:active {
  transform: translateY(0) scale(0.96);
}

.finger-btn:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none;
}

.finger-num {
  font-size: 1.8rem;
  font-weight: 900;
  color: #c8d8e8;
  line-height: 1;
}

.finger-hint {
  font-size: 0.6rem;
  color: #304050;
  letter-spacing: 1px;
}

/* ── Overlay screens (quarter end, game over) ────────────── */

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 30px 24px;
  max-width: 400px;
  width: 100%;
}

.overlay-content h1 {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 3px;
}

.overlay-content h2 {
  font-size: 1.5rem;
  color: #8899aa;
  letter-spacing: 2px;
}

#gameover-icon { font-size: 4rem; }

#gameover-title { color: #f5c400; }
#gameover-title.cpu-win { color: #4488ff; }
#gameover-title.tie-game { color: #607080; }

.final-score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 1.1rem;
}

.final-score-row .team { width: 60px; text-align: center; }
.final-score-row .score { font-size: 2.2rem; font-weight: 900; }
.final-score-row .you-score  { color: #f5c400; }
.final-score-row .cpu-score  { color: #4488ff; }
.final-score-row .sep { color: #304050; font-size: 1.5rem; }

.quarter-end-icon { font-size: 3rem; }

.qsum-table {
  display: grid;
  grid-template-columns: auto repeat(4, 1fr) auto;
  gap: 2px 8px;
  font-size: 0.85rem;
  color: #607080;
  margin-top: 4px;
}
.qsum-table .qsum-header { color: #405060; font-size: 0.7rem; letter-spacing: 1px; }
.qsum-table .qsum-you { color: #c8a800; }
.qsum-table .qsum-cpu { color: #3366cc; }
.qsum-table .qsum-total { color: #8899aa; font-weight: bold; }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-height: 600px) {
  .reveal-fingers { width: 72px; height: 72px; font-size: 2.2rem; }
  .finger-btn { width: 68px; height: 68px; }
  .finger-num { font-size: 1.5rem; }
  #field { min-height: 140px; }
  #screen-title h1 { font-size: 2.2rem; }
  .title-icon { font-size: 2.5rem; }
}
