:root {
  --bg-color: #0a0a0a;
  --panel-color: #1a1a1a;
  --accent-color: #f1c40f;
  --text-color: #ffffff;
  --text-muted: #888888;
  --border-color: #333333;
  --btn-bg: #3498db;
}

[data-theme="light"] {
  --bg-color: #f0f4f8;
  --panel-color: #ffffff;
  --accent-color: #f1c40f;
  --text-color: #2c3e50;
  --text-muted: #6b7a90;
  --border-color: #ddd;
  --btn-bg: #3498db;
}

body {
  background: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  font-family: 'Courier New', Courier, monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

.topbar {
  width: 100%;
  max-width: 400px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 0 10px;
  box-sizing: border-box;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel-color);
  color: var(--accent-color);
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
}

.smallbtn {
  text-decoration: none;
  background: var(--btn-bg);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.header {
  margin-top: 10px;
  text-align: center;
}

.score-board {
  font-size: 24px;
  color: var(--accent-color);
  margin: 10px 0;
}

#game-container {
  position: relative;
  border: 4px solid #2980b9;
  box-shadow: 0 0 20px rgba(41, 128, 185, 0.5);
  border-radius: 10px;
}

canvas {
  display: block;
  background: black;
  border-radius: 6px;
  touch-action: none;
}

.controls {
  display: grid;
  grid-template-areas: ". up ." "left center right" ". down .";
  gap: 10px;
  margin-top: 20px;
}

.btn {
  width: 50px;
  height: 50px;
  background: var(--panel-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.btn:active {
  background: var(--border-color);
}

/* 게임오버 모달 */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: var(--panel-color);
  border: 2px solid var(--accent-color);
  border-radius: 16px;
  padding: 24px 32px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 0 30px rgba(241, 196, 15, 0.3);
}

.modal-title {
  font-size: 28px;
  color: var(--accent-color);
  margin: 0 0 10px 0;
}

.modal-score {
  font-size: 20px;
  color: var(--text-color);
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s;
}

.modal-btn.primary {
  background: var(--btn-bg);
  color: white;
}

.modal-btn.primary:hover {
  background: #2980b9;
}

.modal-btn.secondary {
  background: var(--border-color);
  color: var(--text-color);
}

.modal-btn.secondary:hover {
  background: var(--text-muted);
}

@media (min-width: 600px) {
  .controls {
    display: none;
  }
}

.instructions {
  margin-top: 15px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 리더보드 스타일 */
#leaderboard {
  width: 340px;
  background: var(--panel-color);
  margin-top: 20px;
  padding: 15px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

#leaderboard h3 {
  margin-top: 0;
  color: var(--btn-bg);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.score-row:last-child {
  border-bottom: none;
}

.rank {
  color: var(--text-muted);
  margin-right: 10px;
}

.muted {
  color: var(--text-muted);
  text-align: center;
  padding: 10px 0;
  font-size: 13px;
}