:root {
  --ink: #243041;
  --paper: #fff7dd;
  --panel: #fff3c2;
  --green: #83d65c;
  --blue: #5aa9ff;
  --red: #ef5d62;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: #6bbf59;
  color: var(--ink);
  font-family: ui-rounded, "Trebuchet MS", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

#game {
  position: fixed;
  inset: 0;
}

.hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto minmax(160px, 260px);
  gap: 10px;
  align-items: start;
  pointer-events: none;
}

.hud > div {
  border: 4px solid #243041;
  background: var(--paper);
  box-shadow: 0 5px 0 rgba(36, 48, 65, 0.3);
  padding: 8px 10px;
}

.hud strong {
  display: block;
  font-size: 18px;
}

.lives {
  color: var(--red);
  font-size: 26px;
  letter-spacing: 2px;
  white-space: nowrap;
}

.roster {
  max-height: 190px;
  overflow: hidden;
  font-size: 13px;
}

.roster-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 2px solid rgba(36, 48, 65, 0.1);
  padding: 2px 0;
}

.panel {
  position: fixed;
  z-index: 10;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100vw - 28px));
  transform: translate(-50%, -50%);
  border: 5px solid #243041;
  background: var(--panel);
  box-shadow: 0 8px 0 rgba(36, 48, 65, 0.35);
  padding: 18px;
  text-align: center;
}

.hidden {
  display: none;
}

.name-panel h1 {
  margin: 0 0 8px;
  font-size: 36px;
}

.name-panel p {
  margin: 0 0 16px;
}

.name-panel input {
  width: 100%;
  min-height: 54px;
  border: 4px solid #243041;
  background: #fffefa;
  padding: 8px 12px;
  font-size: 24px;
  text-align: center;
}

.name-panel button {
  width: 100%;
  min-height: 58px;
  margin-top: 12px;
  border: 4px solid #243041;
  background: var(--blue);
  color: white;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 5px 0 #243041;
}

.challenge-panel {
  width: min(680px, calc(100vw - 24px));
}

.battle-title {
  font-size: 28px;
  font-weight: 900;
}

.battle-meta {
  min-height: 24px;
  margin: 4px 0 10px;
  font-size: 15px;
}

.question {
  margin: 10px auto 14px;
  width: fit-content;
  min-width: 260px;
  border: 4px solid #243041;
  background: #fffefa;
  padding: 14px 22px;
  font-size: clamp(38px, 8vw, 72px);
  font-weight: 900;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(62px, 1fr));
  gap: 10px;
}

.number-pad button {
  min-height: 64px;
  border: 4px solid #243041;
  background: #ffffff;
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(36, 48, 65, 0.35);
}

.number-pad button:active,
.name-panel button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(36, 48, 65, 0.35);
}

.battle-feedback {
  min-height: 28px;
  margin-top: 12px;
  font-weight: 800;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border: 4px solid #243041;
  background: #fffefa;
  padding: 10px 14px;
  box-shadow: 0 5px 0 rgba(36, 48, 65, 0.3);
  font-weight: 800;
}

@media (max-width: 720px) {
  .hud {
    grid-template-columns: 1fr auto;
  }

  .roster {
    grid-column: 1 / -1;
    max-height: 94px;
  }

  .number-pad {
    grid-template-columns: repeat(3, minmax(68px, 1fr));
  }
}
