:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a28;
  --border: #2a2a40;
  --accent: #00f5d4;
  --accent2: #ff6b6b;
  --accent3: #ffd93d;
  --text: #e8e8f0;
  --text-dim: #666680;
  --shadow: rgba(0,245,212,0.15);
  --I: #00f5d4;
  --O: #ffd93d;
  --T: #c77dff;
  --S: #06d6a0;
  --Z: #ff6b6b;
  --J: #4cc9f0;
  --L: #ff9f1c;
  --ghost: rgba(255,255,255,0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Space Mono', monospace;
  color: var(--text);
  touch-action: none;
}

#root {
  width: 100%;
  height: 100%;
}

.app-root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#home-screen {
  background: var(--bg);
  gap: 0;
}

.logo-area {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  font-family: 'Bebas Neue', cursive;
  font-size: 88px;
  letter-spacing: 8px;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent) 0%, #9b5de5 60%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 30px var(--shadow));
}

.logo-sub {
  font-size: 11px;
  letter-spacing: 6px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 4px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(10, 20px);
  grid-template-rows: repeat(6, 20px);
  gap: 1px;
  margin-bottom: 40px;
  opacity: 0.6;
}

.preview-cell {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  background: var(--surface2);
}

.preview-cell.filled {
  animation: pulse-cell 3s ease-in-out infinite;
}

@keyframes pulse-cell {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.4; }
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.btn {
  padding: 16px 24px;
  border: none;
  border-radius: 12px;
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.15s;
}

.btn:active::after {
  opacity: 0.1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #00b8a9 100%);
  color: var(--bg);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-accent {
  background: linear-gradient(135deg, #9b5de5 0%, #c77dff 100%);
  color: white;
}

#game-screen {
  background: var(--bg);
  padding: 0;
  flex-direction: column;
  justify-content: flex-start;
}

.game-header {
  width: 100%;
  max-width: 360px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

.header-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 18px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.header-btn:active {
  opacity: 0.7;
  transform: scale(0.95);
}

.mode-badge-wide {
  width: auto !important;
  padding: 0 10px;
  font-size: 10px;
  letter-spacing: 1px;
}

.level-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.level-badge span {
  color: var(--accent);
  font-weight: 700;
}

.game-area {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 0 12px;
  min-height: 0;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 72px;
  flex-shrink: 0;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}

.panel-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.panel-value {
  font-family: 'Bebas Neue', cursive;
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
}

.panel-value-score {
  font-size: 20px;
}

.panel-value-timer {
  font-size: 22px;
}

.canvas-wrap {
  position: relative;
  flex-shrink: 0;
}

#game-canvas {
  display: block;
  border-radius: 4px;
  image-rendering: pixelated;
}

.lock-flash {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s;
}

.clear-flash {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  pointer-events: none;
  overflow: hidden;
}

.controls {
  width: 100%;
  max-width: 360px;
  padding: 8px 16px 16px;
  flex-shrink: 0;
}

.ctrl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ctrl-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.1s;
  flex: 1;
}

.ctrl-btn:active {
  background: var(--border);
  transform: scale(0.95);
}

.ctrl-btn-arrow {
  font-size: 24px;
}

.ctrl-btn.hard-drop {
  background: linear-gradient(135deg, var(--accent) 0%, #00b8a9 100%);
  color: var(--bg);
  font-weight: 700;
  font-size: 13px;
  font-family: 'Space Mono', monospace;
  letter-spacing: 1px;
}

.ctrl-btn.rotate-btn {
  background: linear-gradient(135deg, #9b5de5 0%, #7b2d8b 100%);
  font-size: 22px;
}

.ctrl-btn.hold-btn {
  font-size: 12px;
  font-family: 'Space Mono', monospace;
  letter-spacing: 1px;
  color: var(--accent3);
}

#score-screen {
  background: var(--bg);
  gap: 24px;
  text-align: center;
}

.score-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 64px;
  letter-spacing: 4px;
}

.score-title.game-over {
  color: var(--accent2);
}

.score-title.victory {
  color: var(--accent3);
}

.final-score {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.final-score-label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.final-score-value {
  font-family: 'Bebas Neue', cursive;
  font-size: 72px;
  line-height: 1;
  color: var(--accent);
}

.final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.stat-chip-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-chip-value {
  font-family: 'Bebas Neue', cursive;
  font-size: 28px;
  color: var(--text);
}

.score-menu-buttons {
  width: 100%;
  max-width: 280px;
}

#pause-screen {
  background: rgba(10, 10, 15, 0.95);
  gap: 24px;
  z-index: 50;
}

.pause-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 72px;
  letter-spacing: 6px;
  color: var(--accent);
}

.notif {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  pointer-events: none;
  font-family: 'Bebas Neue', cursive;
  font-size: 48px;
  letter-spacing: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.notif-visible {
  opacity: 1;
}

#mode-screen {
  background: var(--bg);
  gap: 24px;
}

.mode-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 48px;
  letter-spacing: 4px;
  color: var(--text);
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.mode-card:active {
  transform: scale(0.98);
  opacity: 0.8;
}

.mode-card-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.mode-card-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 24px;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.mode-card-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

.mode-card.marathon {
  border-color: rgba(0, 245, 212, 0.3);
}

.mode-card.marathon .mode-card-title {
  color: var(--accent);
}

.mode-card.sprint {
  border-color: rgba(255, 107, 107, 0.3);
}

.mode-card.sprint .mode-card-title {
  color: var(--accent2);
}

.mode-card.ultra {
  border-color: rgba(255, 217, 61, 0.3);
}

.mode-card.ultra .mode-card-title {
  color: var(--accent3);
}

.mode-back-btn {
  width: 100%;
  max-width: 300px;
  margin-top: 8px;
}

/* High Scores Modal */
.scores-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.92);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.scores-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.scores-title {
  font-family: 'Bebas Neue', cursive;
  font-size: 36px;
  letter-spacing: 3px;
  color: var(--accent3);
  margin-bottom: 24px;
}

.scores-loading {
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px 0;
}

.scores-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.scores-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.scores-mode {
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.scores-val {
  font-family: 'Bebas Neue', cursive;
  font-size: 28px;
  color: var(--accent);
}

.scores-close {
  width: 100%;
}