:root{
  --bg: #090d16;
  --ink: #f8fafc;
  --ink-muted: #94a3b8;
  --accent: #f59e0b;
  --accent-blue: #38bdf8;
  --border: #1e293b;
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at center, #0f172a 0%, #020617 100%);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
}

#stage{
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
}

.masthead{
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
  justify-content: center;
}

.masthead .title{
  font-family: 'Press Start 2P', 'IBM Plex Mono', monospace;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.masthead .tag{
  font-size: 0.75rem;
  color: var(--accent-blue);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Main Game & Leaderboard Layout Container */
#game-layout{
  display: flex;
  gap: 1.25rem;
  align-items: stretch;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 100%;
}

#canvas-wrapper{
  position: relative;
  display: inline-block;
}

canvas#game{
  display: block;
  image-rendering: auto;
  background: #020617;
  border: 2px solid #334155;
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.15);
}

/* Leaderboard Panel (Right Side of Canvas) */
#leaderboard-panel{
  width: 250px;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #334155;
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 12px rgba(245, 158, 11, 0.1);
  padding: 0.9rem 0.8rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.leaderboard-header{
  text-align: center;
  border-bottom: 1px solid #334155;
  padding-bottom: 0.5rem;
  margin-bottom: 0.6rem;
}

.leaderboard-header h3{
  margin: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.leaderboard-header .sub{
  font-size: 0.65rem;
  color: var(--accent-blue);
  letter-spacing: 0.06em;
}

#leaderboard-list{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.leaderboard-item{
  display: flex;
  align-items: center;
  font-size: 0.72rem;
  padding: 0.3rem 0.4rem;
  background: rgba(30, 41, 59, 0.5);
  border-radius: 4px;
  border-left: 2px solid #475569;
}

.leaderboard-item:nth-child(1){ border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.leaderboard-item:nth-child(2){ border-left-color: #94a3b8; background: rgba(148, 163, 184, 0.1); }
.leaderboard-item:nth-child(3){ border-left-color: #d97724; background: rgba(217, 119, 36, 0.1); }

.rank-num{
  font-weight: bold;
  width: 22px;
  color: var(--accent);
  font-size: 0.68rem;
}

.pilot-name{
  flex: 1;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 0.4rem;
}

.pilot-score{
  font-weight: bold;
  color: #4ade80;
  font-size: 0.72rem;
}

.empty-item, .loading-item{
  font-size: 0.7rem;
  color: var(--ink-muted);
  text-align: center;
  padding: 1rem 0;
}

/* High Score Name Entry Modal Overlay */
#highscore-overlay{
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 6px;
  transition: opacity 0.2s ease;
}

#highscore-overlay.hidden{
  display: none;
}

.highscore-card{
  background: #0f172a;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  text-align: center;
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.35);
  width: 85%;
  max-width: 310px;
}

.highscore-card h3{
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85rem;
  color: var(--accent);
  margin: 0 0 0.5rem 0;
}

#highscore-score-val{
  font-size: 0.9rem;
  font-weight: bold;
  color: #4ade80;
  margin-bottom: 0.9rem;
}

#highscore-form{
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#player-name-input{
  background: #020617;
  border: 1px solid #334155;
  border-radius: 4px;
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  padding: 0.5rem 0.6rem;
  text-align: center;
  outline: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#player-name-input:focus{
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

#submit-score-btn{
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 4px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: bold;
  transition: transform 0.1s ease, background 0.15s ease;
}

#submit-score-btn:hover{
  background: #fbbf24;
  transform: scale(1.02);
}

.statusbar{
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

#gamepad-status.connected{ color: var(--accent); }
#message-status{ color: var(--accent); min-height: 1em; }
