:root {
  --bg: #0f172a;
  --bg-2: #111827;
  --card: #1e293b;
  --card-2: #273449;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #818cf8;
  --win: #22c55e;
  --lose: #ef4444;
  --tie: #eab308;
  --radius: 18px;
}

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% -10%, #312e81 0%, var(--bg) 55%) fixed, var(--bg);
  line-height: 1.5;
  padding: 0 16px;
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.game {
  width: 100%;
  max-width: 640px;
  padding: clamp(28px, 6vw, 56px) 0 24px;
  display: grid;
  gap: 24px;
}

/* Header */
.game-header {
  text-align: center;
}

.title {
  font-size: clamp(1.9rem, 7vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #c7d2fe, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--muted);
  margin-top: 6px;
}

/* Scoreboard */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.score {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}

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

.score-value {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 800;
}

.score-player .score-value {
  color: var(--win);
}

.score-computer .score-value {
  color: var(--lose);
}

.score-ties .score-value {
  color: var(--tie);
}

/* Choices */
.choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: clamp(14px, 4vw, 22px) 8px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
}

.choice:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--card-2);
}

.choice:active {
  transform: translateY(0) scale(0.97);
}

.choice-emoji {
  font-size: clamp(2.2rem, 10vw, 3.4rem);
  line-height: 1.1;
}

.choice-name {
  font-weight: 600;
}

kbd {
  position: absolute;
  top: 8px;
  right: 10px;
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 5px;
}

/* Arena */
.arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
}

.pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.pick-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.pick-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.result {
  font-size: clamp(1.1rem, 4.5vw, 1.6rem);
  font-weight: 800;
  text-align: center;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  margin: 12px 0;
}

.result.is-win {
  color: var(--win);
  background: rgba(34, 197, 94, 0.12);
}

.result.is-lose {
  color: var(--lose);
  background: rgba(239, 68, 68, 0.12);
}

.result.is-tie {
  color: var(--tie);
  background: rgba(234, 179, 8, 0.12);
}

.result.pop {
  animation: pop 0.3s ease-out;
}

@keyframes pop {
  from {
    transform: scale(0.8);
    opacity: 0.4;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* History */
.history {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.history h2 {
  font-size: 1.1rem;
}

.reset {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s;
}

.reset:hover {
  border-color: var(--lose);
  color: var(--lose);
}

.history-list {
  list-style: none;
  display: grid;
  gap: 6px;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  border-left: 4px solid var(--border);
  font-size: 0.95rem;
}

.history-item.is-win {
  border-left-color: var(--win);
}

.history-item.is-lose {
  border-left-color: var(--lose);
}

.history-item.is-tie {
  border-left-color: var(--tie);
}

.h-round {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.vs {
  color: var(--muted);
  font-size: 0.8em;
  margin: 0 4px;
}

.h-result {
  font-weight: 700;
  white-space: nowrap;
}

.is-win .h-result {
  color: var(--win);
}

.is-lose .h-result {
  color: var(--lose);
}

.is-tie .h-result {
  color: var(--tie);
}

.history-empty {
  color: var(--muted);
  text-align: center;
  padding: 8px;
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 20px 0 28px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Phones */
@media (max-width: 480px) {
  .arena {
    grid-template-columns: 1fr 1fr;
  }

  .result {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 4px 0 0;
  }

  .history-item {
    grid-template-columns: auto 1fr;
  }

  .h-result {
    grid-column: 2;
  }

  kbd {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
