:root {
  --bg: #0f1115;
  --card-bg: #181a20;
  --card-border: #2d313a;
  --panel-bg: #121419;
  
  --grey-lightest: #f1f5f9;
  --grey-light: #cbd5e1;
  --grey-mid: #94a3b8;
  --grey-dark: #64748b;
  --grey-darker: #334155;
  --grey-button: #272a33;
  --grey-button-hover: #373b47;
  
  --text: #f8fafc;
  --muted: #94a3b8;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  background-color: var(--bg);
  background-image: 
    radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.03) 0%, transparent 60%),
    radial-gradient(circle at 50% 90%, rgba(255, 255, 255, 0.02) 0%, transparent 60%);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  -webkit-font-smoothing: antialiased;
}

.game-wrapper {
  width: 100%;
  max-width: 460px;
  display: flex;
  justify-content: center;
}

.game-container {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.85);
}

/* Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.game-brand {
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 4px;
  letter-spacing: -0.2px;
}

.brand-dar { color: #ffffff; }
.brand-kit { color: var(--grey-light); }
.brand-divider { color: rgba(255, 255, 255, 0.2); font-weight: 400; margin: 0 2px; }
.brand-game { color: var(--grey-mid); font-weight: 600; font-size: 13px; }

.header-tools {
  display: flex;
  gap: 6px;
}

.tool-btn {
  background: var(--grey-button);
  border: 1px solid var(--card-border);
  color: var(--grey-light);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: var(--grey-button-hover);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.tool-btn.active {
  background: #373b47;
  border-color: #64748b;
  color: #fff;
}

/* Score Strip */
.score-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.score-pill {
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.score-pill.highlight {
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, var(--panel-bg) 100%);
}

.pill-label {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.6px;
}

.pill-value {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.score-pill.highlight .pill-value {
  color: var(--grey-lightest);
}

/* Canvas Viewport */
.canvas-box {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #090a0d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  display: block;
  width: 100%;
  max-width: 448px;
  height: auto;
  aspect-ratio: 28 / 31;
  image-rendering: pixelated;
}

.crt-scanlines {
  display: none;
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(0,0,0,0) 50%, rgba(0,0,0,0.3) 50%);
  background-size: 100% 4px;
}

.crt-glow {
  display: none;
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.12);
}

.crt-active .crt-scanlines,
.crt-active .crt-glow {
  display: block;
}

/* Overlays */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 16, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  padding: 16px;
}

.game-overlay.hidden,
.simple-modal.hidden {
  display: none !important;
}

.simple-modal {
  background: #1e222b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  width: 100%;
  max-width: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.8);
}

.simple-modal h2 {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.2px;
}

.sub-text {
  font-size: 12px;
  color: var(--muted);
}

.final-score-line {
  font-size: 14px;
  color: #fff;
}

.final-score-line strong {
  color: var(--grey-lightest);
}

.high-badge {
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 700;
}

kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 11px;
}

.btn-main {
  width: 100%;
  background: #333845;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-main:hover {
  background: #474e60;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-main:active {
  transform: translateY(1px);
}

/* Footer */
.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  font-size: 12px;
}

.footer-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-tag {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
}

.lives-container {
  display: flex;
  gap: 4px;
  align-items: center;
}

.fruit-history {
  display: flex;
  gap: 4px;
  align-items: center;
}

.life-icon, .fruit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* Mobile D-Pad */
.mobile-dpad {
  display: none;
  justify-content: center;
  padding-top: 4px;
}

@media (max-width: 768px), (pointer: coarse) {
  .mobile-dpad {
    display: flex;
  }
}

.dpad-grid {
  position: relative;
  width: 136px;
  height: 136px;
}

.dpad-btn {
  position: absolute;
  width: 42px;
  height: 42px;
  background: #242833;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dpad-btn:active, .dpad-btn.pressed {
  background: #474e60;
  border-color: #94a3b8;
  color: #fff;
}

.dpad-btn.up { top: 0; left: 47px; }
.dpad-btn.down { bottom: 0; left: 47px; }
.dpad-btn.left { top: 47px; left: 0; }
.dpad-btn.right { top: 47px; right: 0; }

.dpad-mid {
  position: absolute;
  top: 47px;
  left: 47px;
  width: 42px;
  height: 42px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
}
