*,
*::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% 0%, #1e3a5f 0%, #0f141c 55%, #080a10 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: 150px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-shrink: 0;
}

.panel h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #ff9922, #ffe600, #00e5ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.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 { flex: 1; }

.stat-row {
  display: flex;
  gap: 0.5rem;
}

.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.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.stat-value.lives {
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: #ffe600;
}

.stat-value.speed { color: #ff9922; font-size: 1.1rem; }
.stat-value.accent { color: #00e5ff; }

.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;
  text-align: center;
}

.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.35rem;
}

.info-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffe600;
}

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

.traffic-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;
}

.traffic-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.traffic-list::-webkit-scrollbar { width: 4px; }
.traffic-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.traffic-list li {
  font-size: 0.62rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(255, 255, 255, 0.6);
}

.car-swatch {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.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, #ff9922, #ffe600);
  border-color: transparent;
  color: #1a1000;
  font-weight: 700;
}

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

.controls-hint {
  font-size: 0.72rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.5);
}

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

.board-wrap {
  position: relative;
  width: 480px;
  height: 640px;
  overflow: hidden;
  border-radius: 0.35rem;
  background: #1e3a5f;
}

body.compact-layout #game-root {
  gap: 0.5rem;
  padding: 0.5rem;
}

body.compact-layout .panel-left,
body.compact-layout .panel-right {
  display: none;
}

body.compact-layout .board-frame {
  border-width: 2px;
}

#board {
  display: block;
  width: 480px;
  height: 640px;
  outline: none;
}

#board:focus {
  box-shadow: inset 0 0 0 2px rgba(255, 153, 34, 0.35);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(15, 10, 35, 0.55);
  backdrop-filter: blur(2px);
  border-radius: 0.35rem;
  z-index: 2;
}

#start-overlay h2 {
  text-shadow: 0 0 24px rgba(255, 230, 0, 0.45);
}

.overlay.hidden { display: none; }

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

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

#end-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;
}