:root {
  --bg: #05060f;
  --accent: #7de2ff;
  --gold: #ffd166;
  --green: #3df07a;
  --text: #e8ecff;
}

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

html, body {
  height: 100%;
  background: #02030a;
  color: var(--text);
  font-family: "Courier New", monospace;
  overflow: hidden;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* HUD ----------------------------------------------------------------------*/
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 22px;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(125, 226, 255, 0.5);
  font-size: 20px;
  letter-spacing: 1px;
}

#hud .hud-center { text-align: center; }
#hud .hud-right { text-align: right; }

.hud-label {
  display: block;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent);
  opacity: 0.7;
  margin-bottom: 2px;
}

#hud-lives { color: #ff5f7e; text-shadow: 0 0 8px rgba(255,95,126,0.6); }
#hud-score { color: var(--gold); }

.hud-best {
  display: block;
  font-size: 14px;
  margin-top: 4px;
  opacity: 0.85;
}
.hud-best .hud-label { display: inline; margin: 0; }
#hud-best { color: var(--accent); }

.new-high {
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.7);
  animation: pop 0.5s ease-out, pulse 1.4s ease-in-out infinite;
}
.new-high.hidden { display: none; }

.combo {
  display: block;
  font-size: 13px;
  color: var(--green);
  margin-top: 4px;
  min-height: 16px;
}

/* Wave banner --------------------------------------------------------------*/
#wave-banner {
  position: absolute;
  top: 38%; left: 0; right: 0;
  text-align: center;
  font-size: 52px;
  font-weight: bold;
  letter-spacing: 8px;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 209, 102, 0.7);
  pointer-events: none;
}

#wave-banner.flash { animation: pop 0.4s ease-out; }
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  40% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Overlays -----------------------------------------------------------------*/
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(5,6,15,0.78), rgba(2,3,10,0.95));
  padding: 24px;
  gap: 18px;
}

.overlay.hidden, .hidden { display: none; }

h1 {
  font-size: 64px;
  letter-spacing: 6px;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(125, 226, 255, 0.6);
}
h1 span { color: var(--gold); display: block; font-size: 40px; letter-spacing: 14px; }

h2 {
  font-size: 48px;
  letter-spacing: 6px;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 209, 102, 0.6);
}

.tagline { max-width: 560px; line-height: 1.5; opacity: 0.85; }

.btn {
  margin-top: 6px;
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 3px;
  padding: 12px 26px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  text-shadow: 0 0 8px rgba(125, 226, 255, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}
.btn:hover { background: var(--accent); color: #02030a; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(125, 226, 255, 0); }
  50% { box-shadow: 0 0 18px rgba(125, 226, 255, 0.45); }
}

/* Difficulty selector ------------------------------------------------------*/
.difficulty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.difficulty .hud-label { opacity: 0.8; }

.diff-options {
  display: flex;
  gap: 10px;
}

.diff-btn {
  background: transparent;
  border: 2px solid rgba(125, 226, 255, 0.4);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.diff-btn:hover { border-color: var(--accent); }
.diff-btn.selected {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 209, 102, 0.12);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.3);
  text-shadow: 0 0 8px rgba(255, 209, 102, 0.5);
}

.diff-hint {
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.5;
}

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(125, 226, 255, 0.4);
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-secondary:hover { border-color: var(--accent); background: rgba(125,226,255,0.08); }
.btn-secondary.off { color: #8a93b5; border-color: rgba(138, 147, 181, 0.4); }

/* Pause-screen controls ----------------------------------------------------*/
.pause-controls {
  display: flex;
  gap: 48px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
  margin: 8px 0;
}
.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Make difficulty buttons and the guide toggle share the same size, so the
   two control groups line up in position and height on the pause menu. */
.pause-controls .diff-btn,
.pause-controls #pause-guide-toggle {
  height: 40px;
  min-width: 96px;
  padding: 0 18px;
  font-size: 15px;
  letter-spacing: 2px;
  border-width: 2px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Modal ---------------------------------------------------------------------*/
.modal {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 3, 10, 0.82);
  backdrop-filter: blur(3px);
}
.modal.hidden { display: none; }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: #0a0d1c;
  border: 1px solid rgba(125, 226, 255, 0.25);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.15s ease;
}
.modal-close:hover { opacity: 1; color: var(--accent); }

.modal-title {
  font-size: 30px;
  letter-spacing: 5px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(125, 226, 255, 0.5);
}

.modal-text {
  max-width: 600px;
  line-height: 1.6;
  opacity: 0.85;
  text-align: center;
  font-size: 14px;
}
.modal-text.small { font-size: 12px; opacity: 0.65; }
.modal-text b { color: var(--gold); }

/* Reference keyboard inside the modal sits in normal flow (not docked). */
.kb-reference {
  position: static;
  transform: none;
}

/* Finger guide / on-screen keyboard ----------------------------------------*/
#keyboard-guide {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  user-select: none;
}
#keyboard-guide.hidden { display: none; }

.kb-hint {
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--text);
  opacity: 0.9;
  min-height: 18px;
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
}
.kb-hint b { font-size: 16px; }

.kb-board {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  background: rgba(8, 10, 22, 0.78);
  border: 1px solid rgba(125, 226, 255, 0.18);
  border-radius: 10px;
  backdrop-filter: blur(2px);
}

.kb-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.kb-key {
  position: relative;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: var(--text);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  /* Finger color shown as a bottom accent bar. */
  border-bottom: 3px solid var(--finger);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
  transition: background 0.1s ease, box-shadow 0.1s ease, transform 0.1s ease;
}

/* Home-row keys are tinted with their finger color so resting position is clear. */
.kb-key.home {
  background: color-mix(in srgb, var(--finger) 22%, transparent);
  box-shadow: inset 0 0 0 1px var(--finger);
}

/* Tactile bumps on F and J. */
.kb-key.bump::after {
  content: '';
  position: absolute;
  bottom: 6px;
  width: 10px;
  height: 2px;
  border-radius: 2px;
  background: var(--finger);
}

.kb-space {
  width: 220px;
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.8;
}

/* Candidate keys: first letters of ships currently in play. */
.kb-key.candidate {
  background: color-mix(in srgb, var(--finger) 30%, transparent);
  box-shadow: inset 0 0 0 1px var(--finger), 0 0 8px color-mix(in srgb, var(--finger) 50%, transparent);
}

/* The single next key to press when locked on a word. */
.kb-key.next {
  background: var(--finger);
  color: #05060f;
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 0 18px var(--finger), 0 0 6px var(--finger);
  animation: keyPulse 0.7s ease-in-out infinite;
}
@keyframes keyPulse {
  0%, 100% { box-shadow: 0 0 14px var(--finger); }
  50% { box-shadow: 0 0 26px var(--finger); }
}

.kb-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.75;
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
}
.kb-legend span { display: inline-flex; align-items: center; gap: 5px; }
.kb-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.hints {
  list-style: none;
  margin-top: 10px;
  max-width: 600px;
  font-size: 13px;
  line-height: 1.9;
  opacity: 0.7;
}
.hints b { color: var(--gold); }
