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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Sora', system-ui, sans-serif;
  background: radial-gradient(ellipse at 50% 15%, #1a1040 0%, #0a0a14 55%, #050508 100%);
  color: #e8e8f0;
}

#scale-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-stage {
  transform-origin: center center;
  will-change: transform;
}

#game-root {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1.25rem;
  padding: 1rem;
  flex-shrink: 0;
}

.panel {
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-shrink: 0;
}

.panel h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #00e5ff, #7b5cff, #ff6b8a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mode-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.65rem;
  padding: 0.55rem 0.65rem;
}

.mode-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.45rem;
}

.mode-toggle {
  display: flex;
  gap: 0.35rem;
}

.mode-btn {
  flex: 1;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.45rem 0.35rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mode-btn.active {
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.25), rgba(123, 92, 255, 0.25));
  border-color: rgba(0, 229, 255, 0.45);
  color: #fff;
}

.stat-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.65rem;
  padding: 0.65rem 0.75rem;
}

.stat-block.small-meta .stat-value {
  font-size: 1.1rem;
}

.stat-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.stat-value.player { color: #00e5ff; }
.stat-value.opponent { color: #ff6b8a; }

.info-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.65rem;
  padding: 0.75rem;
}

.info-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 0.5rem;
}

.speed-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.speed-fill {
  height: 100%;
  width: 20%;
  border-radius: inherit;
  background: linear-gradient(90deg, #00e5ff, #ff6b8a);
  transition: width 0.2s ease;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.5);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.player { background: #00e5ff; box-shadow: 0 0 8px #00e5ff; }
.dot.opponent { background: #ff6b8a; box-shadow: 0 0 8px #ff6b8a; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #e8e8f0;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.btn:hover { background: rgba(255, 255, 255, 0.12); }

.btn-primary {
  background: linear-gradient(90deg, #00e5ff, #7b5cff);
  border-color: transparent;
  color: #0a0a14;
  font-weight: 700;
}

.btn-primary:hover { transform: scale(1.02); }

.controls-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.65rem;
  padding: 0.65rem 0.75rem;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.control-who {
  font-size: 0.62rem;
  font-weight: 700;
  min-width: 4.5rem;
}

.control-who.player { color: #00e5ff; }
.control-who.opponent { color: #ff6b8a; }

.key-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65rem;
  height: 1.65rem;
  padding: 0 0.35rem;
  border-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: system-ui, sans-serif;
}

.cpu-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 0.35rem;
  background: rgba(255, 107, 138, 0.15);
  border: 1px solid rgba(255, 107, 138, 0.35);
  color: #ff9ab0;
}

.cpu-badge.hidden,
.key-chip.hidden { display: none; }

.controls-extra {
  font-size: 0.65rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 0.15rem;
}

.board-frame {
  flex-shrink: 0;
  border: 3px solid rgba(0, 229, 255, 0.35);
  border-radius: 0.5rem;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.12);
  line-height: 0;
}

.board-wrap {
  position: relative;
  width: 700px;
  height: 420px;
  overflow: hidden;
  border-radius: 0.35rem;
  background: #080810;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}

#board {
  display: block;
  width: 700px;
  height: 420px;
  outline: none;
}

#board:focus {
  box-shadow: inset 0 0 0 2px rgba(0, 229, 255, 0.25);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(5, 5, 12, 0.82);
  backdrop-filter: blur(4px);
  border-radius: 0.35rem;
}

.overlay.hidden { display: none; }

.overlay h2 {
  font-size: 1.5rem;
  color: #00e5ff;
}

#win-overlay h2.win { color: #00e5ff; }
#win-overlay h2.lose { color: #ff6b8a; }

#win-overlay h2 {
  margin-bottom: 0.65rem;
}

.overlay p {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  max-width: 85%;
  line-height: 1.45;
}