:root {
  color-scheme: dark;
  --panel: rgba(16, 18, 23, 0.78);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text: #f7f2e8;
  --muted: #b7c1c7;
  --accent: #ef6f2e;
  --accent-strong: #ff8d3d;
  --court: #b9824a;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #11151a;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 560px;
  background: #11151a;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 18px;
  width: min(360px, calc(100vw - 36px));
  padding: 16px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
  transition: opacity 180ms ease;
}

.game-shell.is-choosing .hud {
  opacity: 0.26;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.score-row div {
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.score-row strong {
  display: block;
  margin-top: 2px;
  font-size: 1.55rem;
  line-height: 1;
}

#score.bump {
  animation: score-bump 320ms ease;
}

#timer.urgent {
  color: #ff5340;
  animation: timer-pulse 1s ease-in-out infinite;
}

#streak.on-fire {
  color: var(--accent-strong);
  text-shadow: 0 0 12px rgba(255, 120, 40, 0.75);
}

#streak.on-fire::after {
  content: " 🔥";
  font-size: 0.9em;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr 52px;
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.13);
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.is-active {
  color: #15100c;
  background: var(--accent-strong);
  border-color: rgba(255, 255, 255, 0.24);
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.35;
}

.leaderboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.leaderboard div {
  min-width: 0;
  padding: 9px 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.leaderboard ol {
  min-height: 72px;
  margin: 7px 0 0;
  padding-left: 1.15rem;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
}

.leaderboard li {
  padding-left: 2px;
}

.leaderboard .empty-score {
  color: var(--muted);
  list-style: none;
  margin-left: -1.15rem;
}

.camera-panel {
  position: absolute;
  z-index: 2;
  right: 18px;
  bottom: 18px;
  width: min(220px, calc(100vw - 36px));
  overflow: hidden;
  color: var(--text);
  background: rgba(16, 18, 23, 0.74);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
}

.camera-panel[hidden] {
  display: none;
}

#cameraPreview {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #0a0d10;
  transform: scaleX(-1);
}

.camera-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px 10px;
}

.camera-status strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.82rem;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brick-banner {
  position: absolute;
  z-index: 3;
  top: 42%;
  left: 50%;
  pointer-events: none;
  color: #ff2f26;
  font-size: clamp(4rem, 13vw, 9rem);
  font-weight: 1000;
  letter-spacing: 0;
  line-height: 1;
  opacity: 0;
  text-shadow:
    0 4px 0 #3a0705,
    0 0 18px rgba(255, 47, 38, 0.62),
    0 0 42px rgba(0, 0, 0, 0.72);
  transform: translate(-50%, -50%) scale(0.82) rotate(-5deg);
}

.brick-banner.is-active {
  animation: brick-pop 880ms cubic-bezier(0.17, 0.84, 0.28, 1) both;
}

.game-shell.shake #game {
  animation: shake-hit 360ms ease;
}

.popup-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.score-popup {
  position: absolute;
  color: #ffd166;
  font-size: clamp(1.7rem, 4.5vw, 2.7rem);
  font-weight: 1000;
  line-height: 1;
  white-space: nowrap;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.55),
    0 0 18px rgba(255, 209, 102, 0.55);
  transform: translate(-50%, -50%);
  animation: popup-float 950ms ease-out forwards;
}

.score-popup.fire {
  color: #ff7031;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.55),
    0 0 22px rgba(255, 90, 20, 0.8);
}

.mode-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: start center;
  padding: 18px;
  color: var(--text);
  background: rgba(8, 10, 13, 0.16);
}

.mode-overlay[hidden] {
  display: none;
}

.mode-dialog {
  width: min(340px, 100%);
  margin-top: 18px;
  padding: 14px;
  background: rgba(16, 18, 23, 0.76);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

.mode-dialog h1 {
  margin: 4px 0 12px;
  font-size: 1.45rem;
  line-height: 1;
  letter-spacing: 0;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.start-scores {
  display: grid;
  gap: 10px;
}

.start-scores[hidden] {
  display: none;
}

.start-scores div {
  padding: 9px 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.start-scores ol {
  min-height: 52px;
  margin: 7px 0 0;
  padding-left: 1.15rem;
  font-size: 0.86rem;
  line-height: 1.45;
}

.start-scores .empty-score {
  color: var(--muted);
  list-style: none;
  margin-left: -1.15rem;
}

.name-entry {
  display: block;
  margin: 0 0 14px;
}

.name-entry input {
  width: 100%;
  min-height: 42px;
  margin-top: 7px;
  padding: 8px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
}

.score-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@keyframes score-bump {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.35);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes timer-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.45;
  }
}

@keyframes shake-hit {
  0%,
  100% {
    transform: translate(0, 0);
  }

  20% {
    transform: translate(-9px, 4px);
  }

  40% {
    transform: translate(8px, -5px);
  }

  60% {
    transform: translate(-6px, 3px);
  }

  80% {
    transform: translate(4px, -2px);
  }
}

@keyframes popup-float {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.6);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -170%) scale(1);
  }
}

@keyframes brick-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.55) rotate(-10deg);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.16) rotate(4deg);
  }

  34% {
    transform: translate(-50%, -50%) scale(0.98) rotate(-3deg);
  }

  72% {
    opacity: 1;
    transform: translate(-50%, -54%) scale(1.03) rotate(1deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -70%) scale(0.92) rotate(0deg);
  }
}

@media (max-width: 700px) {
  .game-shell {
    min-height: 620px;
  }

  .hud {
    top: 14px;
    bottom: auto;
    left: 14px;
    width: calc(100vw - 28px);
    padding: 13px;
  }

  .score-row {
    gap: 7px;
    margin-bottom: 10px;
  }

  .score-row div {
    padding: 8px;
  }

  .score-row strong {
    font-size: 1.28rem;
  }

  .leaderboard {
    margin-top: 10px;
  }

  .leaderboard ol {
    min-height: 58px;
    font-size: 0.76rem;
  }

  .camera-panel {
    right: 14px;
    bottom: 14px;
    width: min(138px, calc(100vw - 28px));
  }

  .camera-status {
    padding: 7px 8px 8px;
  }

  .camera-status strong {
    font-size: 0.74rem;
  }
}
