@font-face {
  font-family: 'Orbitron';
  src: url('../assets/fonts/Orbitron-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Orbitron';
  src: url('../assets/fonts/Orbitron-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/fonts/Rajdhani-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/fonts/Rajdhani-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #04060f;
  --panel: rgba(10, 16, 30, 0.82);
  --panel-border: rgba(120, 180, 255, 0.25);
  --text: #d9ecff;
  --muted: #8ea8c7;
  --good: #61f2a3;
  --warn: #ffd166;
  --bad: #ff6b6b;
  --accent: #66c7ff;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: radial-gradient(circle at center, #091222 0%, #04060f 70%);
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-size: 22px;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: pre-line;
}

#rightPanel {
  position: fixed;
  top: 12px;
  right: 12px;
  max-width: 360px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-size: 20px;
  line-height: 1.2;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  color: var(--muted);
}

#message {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  min-width: 360px;
  max-width: calc(100vw - 48px);
  padding: 10px 14px;
  text-align: center;
  background: rgba(8, 14, 24, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

#exitHint {
  position: fixed;
  left: 50%;
  bottom: 82px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(8, 14, 24, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}

#overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 8, 0.82);
  backdrop-filter: blur(4px);
}

#overlayCard {
  width: min(560px, calc(100vw - 40px));
  padding: 24px;
  border-radius: 16px;
  background: rgba(8, 14, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

#overlayCard h1 {
  margin: 0 0 12px;
  font-size: 30px;
  color: var(--accent);
}

#overlayCard p {
  margin: 8px 0;
  color: var(--text);
}

#overlayCard button {
  margin-top: 18px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #13213a;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

#audioControls {
  position: fixed;
  left: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  z-index: 40;
}

#audioControls button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: #13213a;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#audioControls input[type="range"] {
  width: 130px;
  cursor: pointer;
  font-size: 18px;
  accent-color: var(--accent);
}

#startScreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 4, 8, 0.72);
  backdrop-filter: blur(4px);
  z-index: 100;
}

#startCard {
  position: relative;
  width: min(720px, calc(100vw - 48px));
  padding: 34px 32px 74px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(10,16,30,0.9), rgba(8,14,24,0.96));
  border: 1px solid var(--panel-border);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255,255,255,0.03);
  overflow: hidden;
}

#startCard::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(102,199,255,0.07), transparent 22%);
  pointer-events: none;
}

#startTitle {
  margin: 0 0 8px;
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(34px, 6vw, 62px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #eef8ff;
}

#startSubtitle {
  margin: 0 0 30px;
  text-align: center;
  color: var(--muted);
  font-size: clamp(18px, 2.4vw, 24px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#startBtn {
  display: block;
  margin: 18px auto 16px;
  min-width: 280px;
  padding: 16px 26px;
  border: 1px solid rgba(143, 232, 255, 0.35);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 38, 62, 0.98), rgba(13, 27, 46, 0.98));
  color: #eef8ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

#startBtn:hover {
  border-color: rgba(143, 232, 255, 0.55);
}

#startSoundRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text);
  font-size: 24px;
}

#startSoundLabel {
  color: var(--muted);
  letter-spacing: 0.04em;
}

#startSoundToggle {
  min-width: 120px;
  padding: 10px 18px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  background: rgba(19, 33, 58, 0.92);
  color: var(--good);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#startSoundToggle.off {
  color: var(--warn);
}

#startFooter {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

#startHintsBtn {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  color: var(--muted);
  font: inherit;
  font-size: 18px;
  opacity: 0.55;
  cursor: default;
}

#startVersion {
  color: rgba(217,236,255,0.72);
  font-family: 'Orbitron', sans-serif;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@keyframes startPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.78; }
}

.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

#startHintsBtn {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: rgba(19, 33, 58, 0.92);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
  opacity: 1;
}

#startHintsBtn:hover {
  border-color: rgba(143, 232, 255, 0.35);
}

#highscoreOverlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 4, 8, 0.82);
  backdrop-filter: blur(4px);
  z-index: 130;
}

#highscoreCard {
  width: min(720px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border-radius: 18px;
  background: rgba(8, 14, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

#highscoreTitle {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: 'Orbitron', sans-serif;
  font-size: 30px;
  text-align: center;
}

#highscoreStatus {
  margin: 0 0 18px;
  color: var(--muted);
  text-align: center;
  font-size: 20px;
}

#highscoreList {
  margin-top: 10px;
}

.highscoreEmpty {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}

.highscoreTable {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
}

.highscoreRow {
  display: grid;
  grid-template-columns: 90px 1fr 110px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.highscoreRow:last-child {
  border-bottom: none;
}

.highscoreHead {
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-weight: 700;
}

.highscoreRank {
  color: var(--accent);
  font-weight: 700;
}

.highscoreName {
  color: var(--text);
  word-break: break-word;
}

.highscoreTime {
  color: var(--good);
  text-align: right;
  font-family: 'Orbitron', sans-serif;
}

#highscoreEntryArea {
  display: none;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

#highscoreNameLabel {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 18px;
}

#highscoreNameInput {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(19, 33, 58, 0.92);
  color: var(--text);
  font: inherit;
  font-size: 20px;
  outline: none;
}

#highscoreNameInput:focus {
  border-color: rgba(143, 232, 255, 0.45);
}

#highscoreEntryHint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 16px;
}

#highscoreEntryActions,
#highscoreActions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

#highscoreSaveBtn,
#highscoreSkipBtn,
#highscoreCloseBtn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #13213a;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

#highscoreSaveBtn:hover,
#highscoreSkipBtn:hover,
#highscoreCloseBtn:hover {
  border-color: rgba(143, 232, 255, 0.35);
}

#eventOverlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  z-index: 160;
}

#eventOverlay.active {
  display: flex;
}

#eventCanvas {
  width: 100vw;
  height: 100vh;
  display: block;
  background: #050913;
}