:root {
  color-scheme: dark;
  --bg-top: #08131d;
  --bg-mid: #0f2431;
  --bg-bottom: #102e3c;
  --ink: #e9fdff;
  --panel: rgba(10, 23, 33, 0.82);
  --stroke: rgba(127, 237, 255, 0.35);
  --accent: #78f4ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Chakra Petch", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 20%, rgba(105, 181, 255, 0.2) 0%, transparent 32%),
    radial-gradient(circle at 84% 18%, rgba(0, 200, 176, 0.22) 0%, transparent 30%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bottom) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 95%, rgba(130, 255, 255, 0.08) 100%),
    repeating-linear-gradient(
      90deg,
      rgba(168, 250, 255, 0.05) 0 1px,
      transparent 1px 56px
    );
  mix-blend-mode: screen;
  animation: drift 14s linear infinite;
}

#app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.desktop-only-shell {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.desktop-only-card {
  width: min(620px, 100%);
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(10, 24, 34, 0.86);
  box-shadow:
    0 22px 58px rgba(0, 0, 0, 0.45),
    inset 0 0 30px rgba(121, 245, 255, 0.14);
  padding: 34px 28px;
  text-align: center;
}

#app.desktop-only-mode {
  width: 100%;
  min-height: 100dvh;
  padding: 0;
  place-items: stretch;
}

.desktop-only-card h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 7vw, 3.2rem);
  color: #d8feff;
  text-shadow: 0 0 20px rgba(120, 244, 255, 0.42);
}

.desktop-only-card p {
  margin: 0;
  font-size: clamp(1rem, 4.2vw, 1.28rem);
  line-height: 1.4;
}

.desktop-only-hint {
  margin-top: 10px !important;
  color: #88d8e6;
}

.game-shell {
  width: min(1280px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}

.game-shell.hud-hidden {
  grid-template-columns: 1fr;
  width: min(900px, 100%);
}

.game-shell.hud-hidden .hud-root {
  display: none;
}

.game-shell.editor-layout,
.game-shell.hud-hidden.editor-layout {
  grid-template-columns: minmax(0, 3fr) minmax(320px, 1fr);
  width: min(1320px, 100%);
}

.game-root {
  position: relative;
  width: min(94vw, 832px);
  aspect-ratio: 13 / 9;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  overflow: hidden;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 0 35px rgba(121, 245, 255, 0.11);
  background: #040b11;
}

.game-root canvas {
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}

.editor-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid rgba(120, 238, 255, 0.44);
  background: rgba(6, 20, 31, 0.92);
  backdrop-filter: blur(8px);
  box-shadow:
    0 18px 46px rgba(0, 0, 0, 0.44),
    inset 0 0 24px rgba(116, 247, 255, 0.1);
  padding: 12px;
}

.editor-root {
  min-width: 320px;
  align-self: stretch;
}

.editor-panel.is-docked {
  position: static;
  top: auto;
  right: auto;
  width: 100%;
  max-height: none;
}

.editor-panel h3 {
  margin: 0 0 10px;
  font-size: 1.04rem;
  color: #d5fbff;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.editor-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: #8ed1df;
}

.editor-grid label:nth-child(2) {
  grid-column: 1 / -1;
}

.editor-grid input,
.editor-grid select {
  width: 100%;
  min-height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(127, 237, 255, 0.34);
  background: rgba(11, 31, 45, 0.92);
  color: #dbfbff;
  font-family: inherit;
  font-size: 0.83rem;
  padding: 5px 8px;
}

.editor-actions {
  margin-top: 11px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.editor-actions button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(126, 236, 255, 0.42);
  background: linear-gradient(180deg, rgba(17, 47, 65, 0.95) 0%, rgba(11, 31, 44, 0.95) 100%);
  color: #d5fbff;
  font-family: inherit;
  font-size: 0.83rem;
  cursor: pointer;
}

.editor-actions button:hover {
  border-color: rgba(160, 244, 255, 0.78);
  box-shadow: 0 0 14px rgba(122, 240, 255, 0.22);
}

.editor-export-status {
  min-height: 18px;
  margin-top: 8px;
  color: #99e3ef;
  font-size: 0.76rem;
}

.editor-export-output {
  margin-top: 6px;
  width: 100%;
  min-height: 120px;
  max-height: 230px;
  display: none;
  border-radius: 8px;
  border: 1px solid rgba(126, 236, 255, 0.34);
  background: rgba(8, 22, 33, 0.95);
  color: #d8fbff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.74rem;
  line-height: 1.35;
  resize: vertical;
  padding: 8px;
}

.editor-export-output.is-visible {
  display: block;
}

.editor-tip {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: #80bcc8;
  line-height: 1.35;
}

.hud-root {
  display: grid;
  gap: 12px;
}

.hud-root.is-hidden {
  display: none;
}

.hud {
  display: grid;
  gap: 12px;
}

.hud-card {
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(6px);
  padding: 12px 14px;
  box-shadow: inset 0 0 25px rgba(121, 245, 255, 0.08);
}

.hud-card h2,
.hud-card h3,
.hud-card p {
  margin: 0;
}

.hud-card h2 {
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

.hud-card h3 {
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--accent);
}

.hud-card p {
  margin-bottom: 5px;
  line-height: 1.3;
  font-size: 0.94rem;
}

.hud-card p:last-child {
  margin-bottom: 0;
}

.hud-device-controls {
  display: none;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(120, 238, 255, 0.24);
}

.hud-device-controls.is-visible {
  display: block;
}

.hud-lighting-toggle {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.95rem;
  color: #bff8ff;
}

.hud-lighting-checkbox {
  width: 17px;
  height: 17px;
  accent-color: #79f4ff;
}

@media (max-width: 980px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .game-root {
    width: min(95vw, 832px);
  }
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(56px);
  }
}
