:root {
  color-scheme: dark;
  --bg: #05070f;
  --surface: rgba(18, 24, 39, 0.9);
  --surface-strong: rgba(24, 32, 56, 0.98);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8f1ff;
  --muted: #97a4c6;
  --accent: #6de6ff;
  --accent-strong: #4ec5ff;
  --danger: #ff5c7a;
  --green: #7cffb7;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(55, 114, 255, 0.18), transparent 40%),
              radial-gradient(circle at bottom right, rgba(108, 230, 255, 0.12), transparent 25%),
              var(--bg);
  color: var(--text);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.app-shell {
  width: min(1200px, 100%);
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 32px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 32px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3vw, 3rem);
  letter-spacing: -0.05em;
}

.brand p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.meter-card,
.controls-card,
.settings-card,
.help-card {
  margin-top: 24px;
  padding: 22px;
  border-radius: 28px;
  background: rgba(10, 16, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.meter {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.meter span {
  color: var(--muted);
}

.meter strong {
  font-size: 1.85rem;
  color: var(--accent);
}

.btn {
  width: 100%;
  border: none;
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  color: #05070f;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 18px 40px rgba(77, 219, 255, 0.18);
}

.btn--secondary {
  margin-top: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-row label,
.setting-row span {
  color: var(--muted);
  font-size: 0.95rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.help-card h2 {
  margin: 0 0 10px;
}

.help-card p {
  margin: 0;
  line-height: 1.75;
  color: var(--muted);
}

.game-window {
  display: grid;
  gap: 18px;
}

.display-frame {
  position: relative;
  border-radius: 36px;
  overflow: hidden;
  background: radial-gradient(circle at top, rgba(39, 62, 113, 0.3), transparent 30%),
              linear-gradient(135deg, rgba(10, 16, 30, 0.95), rgba(10, 16, 30, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03), 0 24px 60px rgba(0, 0, 0, 0.28);
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.banner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  body {
    padding: 18px;
  }
  .panel {
    padding: 22px;
  }
}

@media (max-width: 768px) {
  html, body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
  }

  body {
    padding: 0;
    align-items: stretch;
    display: flex;
    flex-direction: column;
  }

  .app-shell {
    width: 100%;
    height: 100vh;
    grid-template-columns: 1fr;
    gap: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
  }

  .panel {
    border: none;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    padding: 0;
  }

  .panel--left {
    order: -1;
    flex: 0 0 auto;
    max-height: none;
    padding: 12px;
    margin: 0;
    border-radius: 0;
    border: none;
    background: rgba(18, 24, 39, 0.95);
    overflow: visible;
  }

  .brand {
    display: none;
  }

  .meter-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
  }

  .meter {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    padding: 8px 12px;
    background: rgba(10, 16, 30, 0.9);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
  }

  .meter span {
    font-size: 0.85rem;
  }

  .meter strong {
    font-size: 1.3rem;
  }

  .controls-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
  }

  .btn {
    padding: 12px 12px;
    font-size: 0.9rem;
    border-radius: 10px;
    margin: 0 !important;
  }

  .settings-card,
  .help-card {
    display: none;
  }

  .panel--right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0;
  }

  .game-window {
    flex: 1;
    gap: 0;
    display: flex;
    flex-direction: column;
    padding: 12px;
    margin: 0;
  }

  .display-frame {
    flex: 1;
    position: relative;
    border-radius: 16px;
    min-height: auto;
    margin: 0;
    padding: 0;
  }

  canvas {
    width: 100%;
    height: 100%;
    display: block;
  }

  .banner {
    order: 1;
    height: 40px;
    font-size: 0.85rem;
    padding: 0 12px;
    margin-top: 8px;
    border-radius: 12px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0;
  }

  .panel--left {
    padding: 10px;
  }

  .brand h1 {
    font-size: 1.2rem;
  }

  .meter-card {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .meter {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .meter strong {
    font-size: 1.2rem;
  }

  .btn {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .game-window {
    padding: 10px;
  }

  .banner {
    height: 36px;
    font-size: 0.8rem;
  }
}
