:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --border: #1e1e30;
  --accent-on: #00e5ff;
  --accent-off: #ff3d71;
  --text-primary: #e0e0e0;
  --text-dim: #404055;
  --green: #00e096;
  --red: #ff3d71;
  --yellow: #ffaa00;
  --font: 'Courier New', Courier, monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === STATUS BAR === */
#status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#status-left, #status-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#game-title {
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}

#github-link {
  color: var(--text-dim);
  transition: color 0.2s;
  display: flex;
  align-items: center;
}
#github-link:hover {
  color: var(--text-primary);
}

#game-hud {
  display: none;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9rem;
}
#game-hud.visible { display: flex; }

#game-score {
  color: var(--accent-on);
  letter-spacing: 0.1em;
}
#game-lives {
  display: flex;
  gap: 0.25rem;
  font-size: 1.1rem;
}
.life-heart { color: var(--red); transition: opacity 0.3s; }
.life-heart.lost { opacity: 0.15; }
.life-heart.flash { animation: heartFlash 0.4s ease-out; }
@keyframes heartFlash {
  0% { transform: scale(1.4); color: #fff; }
  100% { transform: scale(1); }
}
#level-display {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

#about-btn {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: bold;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#about-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-dim);
}

#sound-toggle {
  font-family: var(--font);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
#sound-toggle:hover { border-color: var(--text-dim); }
#sound-toggle.active {
  color: var(--accent-on);
  border-color: var(--accent-on);
}

#connection-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

#status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
#status-dot.connected    { background: var(--green); box-shadow: 0 0 8px var(--green); }
#status-dot.disconnected { background: var(--red); }
#status-dot.pending      { background: var(--yellow); animation: pulse 1s infinite; }
#status-dot.error        { background: var(--red); }

#status-text {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* === MAIN CONTENT === */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  overflow-y: auto;
  position: relative;
}

#main-content.playing {
  overflow: hidden;
  padding: 0;
  align-items: stretch;
}
#main-content.playing #history-label,
#main-content.playing #note-history,
#main-content.playing #error-message {
  display: none !important;
}

#history-label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

#note-history {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  max-width: 400px;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  animation: slideIn 0.15s ease-out;
}

.history-note {
  font-size: 1.1rem;
  font-weight: bold;
  min-width: 3.5rem;
}
.history-entry.on .history-note  { color: var(--accent-on); }
.history-entry.off .history-note { color: var(--accent-off); }

.history-type {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-weight: bold;
}
.history-entry.on .history-type {
  background: rgba(0, 229, 255, 0.15);
  color: var(--accent-on);
}
.history-entry.off .history-type {
  background: rgba(255, 61, 113, 0.15);
  color: var(--accent-off);
}

.history-velocity {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-left: auto;
}

.history-time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* === GAME FIELD === */
#game-field {
  display: none;
  position: relative;
  flex: 1;
  overflow: hidden;
}
#main-content.playing #game-field { display: block; }

/* === TARGETS === */
.target {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.2rem 0.3rem;
  background: #ffffff;
  border: 1px solid #cccccc;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  will-change: transform;
  transition: border-color 0.12s, box-shadow 0.12s;
  line-height: 0;
}
.target svg {
  display: block;
}
.target.highlighted {
  border-color: #00b8d4;
  box-shadow: 0 0 14px rgba(0, 184, 212, 0.5);
}
.target.destroying {
  animation: targetHit 0.3s ease-out forwards;
}
@keyframes targetHit {
  0%   { opacity: 1; transform: var(--pos) scale(1); }
  40%  { opacity: 1; transform: var(--pos) scale(1.2); }
  100% { opacity: 0; transform: var(--pos) scale(0.6); }
}

.target.missed {
  animation: targetMiss 0.3s ease-in forwards;
  border-color: var(--red) !important;
  box-shadow: 0 0 10px rgba(255, 61, 113, 0.4) !important;
}
@keyframes targetMiss {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* === INPUT BUFFER === */
#input-buffer-display {
  display: none;
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 1.2rem;
  background: rgba(10, 10, 15, 0.88);
  border: 1px solid var(--border);
  border-radius: 24px;
  min-width: 180px;
  min-height: 44px;
  justify-content: center;
  z-index: 10;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#main-content.playing #input-buffer-display { display: flex; }

#input-buffer-display.miss {
  border-color: var(--red);
  box-shadow: 0 0 16px rgba(255, 61, 113, 0.5);
}
.buffer-note {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--accent-on);
  text-shadow: 0 0 6px var(--accent-on);
}
.buffer-sep {
  color: #252535;
  margin: 0 0.1em;
}
.buffer-empty {
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  font-style: italic;
}

/* === SCREENS (start / game over) === */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  background: rgba(10, 10, 15, 0.93);
  z-index: 20;
  text-align: center;
  padding: 2rem;
}
.screen-title {
  font-size: 2.2rem;
  font-weight: bold;
  letter-spacing: 0.2em;
  color: var(--accent-on);
  text-shadow: 0 0 20px var(--accent-on);
}
.screen-subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  max-width: 400px;
  line-height: 1.7;
}
.screen-prompt {
  font-size: 0.85rem;
  color: var(--yellow);
  letter-spacing: 0.15em;
  animation: pulse 1.5s infinite;
  margin-top: 0.5rem;
}
#gameover-screen .screen-title { color: var(--red); text-shadow: 0 0 20px var(--red); }
#final-score-label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}
#final-score {
  font-size: 2.8rem;
  font-weight: bold;
  color: var(--text-primary);
}

/* === ACTIVE NOTES PANEL === */
#active-notes-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: rgba(12, 12, 20, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  min-width: 180px;
  z-index: 30;
}
#active-notes-panel.compact {
  padding: 0.4rem 0.6rem;
  min-width: 0;
  opacity: 0.7;
}
#active-notes-panel.compact #panel-label { font-size: 0.55rem; margin-bottom: 0.3rem; }
#active-notes-panel.compact .active-note { font-size: 0.85rem; padding: 0.2rem 0.5rem; }
#active-notes-panel.compact .placeholder-text { font-size: 0.7rem; }

#panel-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

#active-notes-container {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.active-note {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--accent-on);
  border-radius: 6px;
  background: rgba(0, 229, 255, 0.1);
  color: var(--accent-on);
  font-size: 1.3rem;
  font-weight: bold;
  animation: noteGlow 0.8s ease-in-out infinite alternate;
}

.placeholder-text {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

/* === ERROR MESSAGE === */
#error-message {
  display: none;
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  max-width: 500px;
}
#error-message h2 {
  color: var(--red);
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}
#error-message p {
  font-size: 0.85rem;
  line-height: 1.6;
}

/* === ABOUT MODAL === */
#about-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.85);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
#about-overlay.hidden { display: none; }

#about-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem 2.5rem;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  color: var(--text-primary);
}
#about-modal h1 {
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  color: var(--accent-on);
  margin-bottom: 1rem;
}
#about-modal h2 {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-top: 1.2rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}
#about-modal p {
  font-size: 0.85rem;
  line-height: 1.7;
  color: #b0b0c0;
}
#about-modal ul {
  list-style: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.8;
  color: #b0b0c0;
}
#about-modal ul li::before {
  content: '\2022';
  color: var(--accent-on);
  margin-right: 0.5em;
}
#piano-diagram {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 0.5rem auto 0;
}
#about-close {
  display: block;
  margin: 1.5rem auto 0;
  font-family: var(--font);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  padding: 0.5rem 2rem;
  border: 1px solid var(--accent-on);
  border-radius: 6px;
  background: rgba(0, 229, 255, 0.1);
  color: var(--accent-on);
  cursor: pointer;
  transition: background 0.2s;
}
#about-close:hover {
  background: rgba(0, 229, 255, 0.2);
}
/* === ANIMATIONS === */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes noteGlow {
  from { box-shadow: 0 0 4px var(--accent-on); }
  to   { box-shadow: 0 0 14px var(--accent-on), 0 0 28px rgba(0, 229, 255, 0.3); }
}
