@font-face { font-family: 'system-pixel'; src: local('Menlo'); }

:root {
  --orange: #e8762c;
  --dark: #181512;
  --bone: #f2ead8;
  --green: #3ec26a;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #111;
  font-family: 'Courier New', ui-monospace, monospace;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

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

#scorebug {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch;
  background: rgba(16, 14, 12, 0.88);
  border: 3px solid #000;
  box-shadow: 0 4px 0 rgba(0,0,0,0.5);
  border-radius: 6px;
  overflow: hidden;
  color: var(--bone);
  font-weight: bold;
}
.sb-team { display: flex; align-items: center; gap: 8px; padding: 6px 14px; }
.sb-home { background: rgba(232,118,44,0.25); border-right: 2px solid #000; }
.sb-away { background: rgba(60,110,200,0.25); border-left: 2px solid #000; }
.sb-name { font-size: 13px; letter-spacing: 1px; opacity: 0.9; }
.sb-score { font-size: 26px; min-width: 34px; text-align: center; }
.sb-mid {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2px 14px; background: rgba(0,0,0,0.5);
}
#scorebug.game-point {
  border-color: #ff4747;
  box-shadow: 0 4px 0 rgba(0,0,0,0.5), 0 0 18px rgba(255,71,71,0.45);
  animation: pulse 0.5s infinite alternate;
}
#scorebug.game-point #shotclock { color: #ff8a5e; }

#shotclock { font-size: 20px; color: #ffd23e; line-height: 1; }
#shotclock.low { color: #ff4747; animation: pulse 0.5s infinite alternate; }
#gameclock-label { font-size: 9px; opacity: 0.7; letter-spacing: 0.5px; margin-top: 2px; white-space: nowrap; }

@media (max-width: 640px) {
  .sb-team { padding: 4px 8px; gap: 5px; }
  .sb-name { font-size: 10px; }
  .sb-score { font-size: 19px; min-width: 24px; }
  .sb-mid { padding: 2px 8px; }
  #shotclock { font-size: 15px; }
  #gameclock-label { font-size: 7px; }
  #controls-hint { display: none; }
}
@keyframes pulse { from { opacity: 1; } to { opacity: 0.55; } }

#possession-arrow {
  position: absolute; top: 66px; left: 50%; transform: translateX(-50%);
  color: var(--orange); font-size: 14px; transition: color 0.2s;
  text-shadow: 0 2px 0 #000;
}
#possession-arrow.away { color: #5d8fe8; }

#message-chip {
  position: absolute; top: 24%; left: 50%; transform: translateX(-50%);
  font-size: clamp(18px, 4vw, 34px);
  font-weight: bold; color: #fff; letter-spacing: 2px;
  text-shadow: 3px 3px 0 #000, -1px -1px 0 #000;
  animation: chip-pop 0.35s ease-out;
  white-space: nowrap;
}
#message-chip.good { color: #7dff8a; }
#message-chip.bad { color: #ff6b5e; }
#message-chip.fire { color: #ffb32e; }
@keyframes chip-pop {
  0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
  60% { transform: translateX(-50%) scale(1.15); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

#streak-chip {
  position: absolute; top: 96px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, #ff9d2e, #e8572c);
  color: #fff; font-weight: bold; font-size: 14px;
  padding: 4px 14px; border-radius: 4px; border: 2px solid #000;
  box-shadow: 0 3px 0 rgba(0,0,0,0.5);
  letter-spacing: 1px;
  animation: pulse 0.4s infinite alternate;
}

#controls-hint {
  position: absolute; bottom: 10px; left: 12px;
  display: flex; gap: 14px; flex-wrap: wrap;
  color: rgba(242, 234, 216, 0.75);
  font-size: 11px;
  text-shadow: 1px 1px 0 #000;
  max-width: 60%;
}
#controls-hint b { color: #ffd23e; }

#shot-meter {
  position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%);
  width: 160px; height: 14px;
  background: rgba(0,0,0,0.7);
  border: 2px solid #000; border-radius: 3px;
  overflow: hidden;
}
#shot-meter-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, #ffd23e, #e8762c);
}
#shot-meter-perfect {
  position: absolute; top: 0; bottom: 0; left: 68%; width: 10%;
  background: rgba(125, 255, 138, 0.55);
  border-left: 1px solid #7dff8a; border-right: 1px solid #7dff8a;
}

#clear-notice {
  position: absolute; top: 130px; left: 50%; transform: translateX(-50%);
  color: #ffd23e; font-weight: bold; font-size: 15px; letter-spacing: 2px;
  text-shadow: 2px 2px 0 #000;
  animation: pulse 0.5s infinite alternate;
}

#mute-btn {
  position: absolute; top: 10px; right: 12px;
  pointer-events: auto;
  background: rgba(16,14,12,0.8); border: 2px solid #000; border-radius: 6px;
  color: var(--bone); font-size: 16px; padding: 5px 9px; cursor: pointer;
}

/* ---------- Start screen ---------- */
#start-screen, #gameover-screen {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(10,8,6,0.18) 0%, rgba(10,8,6,0.52) 100%);
}
.start-inner, .go-inner { text-align: center; color: var(--bone); padding: 20px; }

.game-title {
  font-size: clamp(34px, 8vw, 72px);
  letter-spacing: 4px;
  color: var(--bone);
  text-shadow: 4px 4px 0 #000, 8px 8px 0 rgba(232,118,44,0.4);
  margin-bottom: 6px;
}
.game-title span { color: var(--orange); }

.start-sub {
  font-size: clamp(12px, 2.2vw, 17px);
  color: #ffd23e; letter-spacing: 2px; margin-bottom: 26px;
  text-shadow: 2px 2px 0 #000;
}

.start-controls {
  display: inline-flex; flex-direction: column; gap: 7px;
  background: rgba(0,0,0,0.55);
  border: 3px solid #000; border-radius: 8px;
  box-shadow: 0 5px 0 rgba(0,0,0,0.45);
  padding: 14px 22px;
  font-size: clamp(11px, 1.8vw, 14px);
  margin-bottom: 28px;
  text-align: left;
}

kbd {
  display: inline-block;
  background: #2c2824; color: #ffd23e;
  border: 1px solid #000; border-bottom-width: 3px;
  border-radius: 4px;
  padding: 1px 7px; margin: 0 1px;
  font-family: inherit; font-size: 0.92em; font-weight: bold;
}

.start-press { font-size: clamp(14px, 2.6vw, 20px); letter-spacing: 2px; color: #fff; text-shadow: 2px 2px 0 #000; }
.blink { animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.start-foot { margin-top: 18px; font-size: 11px; opacity: 0.55; letter-spacing: 1px; }

/* ---------- Check overlay ---------- */
#check-overlay {
  position: absolute; inset: 0; z-index: 8; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
#check-text {
  font-size: clamp(26px, 6vw, 52px);
  font-weight: bold; color: #fff; letter-spacing: 4px;
  text-shadow: 4px 4px 0 #000;
  animation: chip-pop 0.3s ease-out;
}

/* ---------- Game over ---------- */
#go-result {
  font-size: clamp(34px, 7vw, 64px); font-weight: bold; letter-spacing: 4px;
  color: #7dff8a; text-shadow: 4px 4px 0 #000;
}
#go-result.loss { color: #ff6b5e; }
#go-score { font-size: clamp(22px, 4.5vw, 40px); color: var(--bone); margin: 8px 0 20px; text-shadow: 3px 3px 0 #000; }
#go-stats {
  display: inline-block;
  background: rgba(0,0,0,0.55); border: 3px solid #000; border-radius: 8px;
  padding: 12px 20px; font-size: clamp(11px, 1.8vw, 14px);
  margin-bottom: 26px; text-align: left; line-height: 1.75; color: var(--bone);
  white-space: pre;
}
#go-stats b { color: #ffd23e; }

@media (max-width: 640px) {
  #controls-hint { display: none; }
  .sb-score { font-size: 20px; min-width: 26px; }
  .sb-team { padding: 4px 8px; }
  #shotclock { font-size: 15px; }
}
