:root {
  color-scheme: light;
  --ink: #101418;
  --muted: #68717c;
  --line: #d9dde3;
  --paper: #ffffff;
  --page: #f5f7fa;
  --coral: #e95d45;
  --teal: #118879;
  --gold: #f0b429;
  --green: #2f9e44;
  --blue: #2f6fed;
  --shadow: 0 18px 60px rgba(16, 20, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(233, 93, 69, 0.10), transparent 30%),
    linear-gradient(315deg, rgba(17, 136, 121, 0.12), transparent 34%),
    var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 24px;
  font-weight: 820;
}

.brand img {
  width: 38px;
  height: 38px;
}

.player-box {
  display: grid;
  grid-template-columns: auto minmax(120px, 180px);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.player-box input,
.baseball-input input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.player-box input:focus,
.baseball-input input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 136, 121, 0.15);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.game-panel,
.scoreboard {
  border: 1px solid rgba(16, 20, 24, 0.10);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.game-panel {
  display: none;
  min-height: 620px;
  padding: 22px;
}

.game-panel.active {
  display: block;
}

.scoreboard {
  min-height: 620px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  font-size: 42px;
}

h2 {
  font-size: 24px;
}

.metric {
  min-width: 98px;
  border-radius: 8px;
  background: #101418;
  color: #fff;
  padding: 10px 12px;
  text-align: right;
}

.metric span {
  display: block;
  min-height: 34px;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  word-break: break-word;
}

.metric small {
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
  font-weight: 800;
}

.reaction-pad {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 398px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #2f6fed, #118879);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.reaction-pad.waiting {
  background: linear-gradient(135deg, #f0b429, #e95d45);
}

.reaction-pad.ready {
  background: linear-gradient(135deg, #2f9e44, #118879);
}

.reaction-pad.too-soon {
  background: linear-gradient(135deg, #101418, #68717c);
}

.reaction-pad span {
  display: block;
  font-size: clamp(40px, 8vw, 92px);
  font-weight: 950;
  line-height: 1;
}

.reaction-pad small {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 800;
  opacity: 0.82;
}

.action-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.primary,
.ghost,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 850;
}

.primary {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  padding: 0 16px;
}

.primary:disabled {
  border-color: #c5cad1;
  background: #c5cad1;
  color: #fff;
  cursor: not-allowed;
}

.ghost {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 0 16px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.baseball-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.baseball-input input {
  min-height: 56px;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
}

.guess-list {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.guess-item {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.guess-code {
  font-size: 20px;
  font-weight: 900;
}

.guess-result {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.guess-turn {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
}

.memory-card {
  aspect-ratio: 1;
  min-height: 72px;
  border: 1px solid rgba(16, 20, 24, 0.14);
  border-radius: 8px;
  background: #101418;
  color: transparent;
  font-size: clamp(28px, 6vw, 52px);
  font-weight: 950;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.memory-card.open,
.memory-card.matched {
  background: #fff;
  color: var(--ink);
  transform: translateY(-2px);
}

.memory-card.matched {
  border-color: rgba(47, 158, 68, 0.6);
  background: rgba(47, 158, 68, 0.10);
}

.scores {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.score-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.score-rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(47, 111, 237, 0.10);
  color: var(--blue);
  font-weight: 900;
}

.score-name {
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-value {
  font-size: 20px;
  font-weight: 950;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  transform: translateY(120px);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-weight: 800;
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 880px) {
  .shell {
    width: min(100vw - 20px, 680px);
    padding-top: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .player-box {
    grid-template-columns: auto 1fr;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-panel,
  .scoreboard {
    min-height: auto;
  }

  h1 {
    font-size: 34px;
  }

  .reaction-pad {
    min-height: 310px;
  }
}

@media (max-width: 520px) {
  .tabs {
    gap: 6px;
  }

  .tab {
    min-height: 40px;
    font-size: 14px;
  }

  .game-panel,
  .scoreboard {
    padding: 14px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metric {
    width: 100%;
    text-align: left;
  }

  .baseball-input {
    grid-template-columns: 1fr;
  }

  .guess-item,
  .score-row {
    grid-template-columns: 1fr;
  }

  .memory-board {
    gap: 7px;
  }

  .memory-card {
    min-height: 58px;
  }

  .action-row {
    flex-direction: column;
  }
}
