:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #070b12;
  color: #eef4ff;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { margin: 0; overflow: hidden; background: #070b12; }
button, input, textarea, select { font: inherit; }
button, a, select, input, textarea { -webkit-tap-highlight-color: transparent; }
button, .hud-button, select, input, textarea { border: 1px solid rgba(112, 143, 184, .34); border-radius: 12px; }
button, .hud-button { min-height: 44px; padding: 9px 12px; background: rgba(11, 18, 31, .88); color: #edf4ff; cursor: pointer; text-decoration: none; }
button:hover, button:focus-visible, .hud-button:hover, .hud-button:focus-visible { border-color: #75bdff; outline: none; }
button:disabled { opacity: .35; cursor: not-allowed; }

.game-shell, .stage-wrap, #noteverse-canvas { width: 100%; height: 100%; }
.game-shell { min-height: 100vh; min-height: 100dvh; }
.stage-wrap { position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden; background: #070b12; }
#noteverse-canvas { display: block; touch-action: none; }

.hud { position: absolute; z-index: 4; display: flex; align-items: center; gap: 9px; pointer-events: auto; }
.hud-brand { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); }
.hud-tools { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
.brand { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid rgba(255, 230, 151, .38); border-radius: 50%; background: rgba(8, 13, 23, .62); color: #fff1a8; font-size: .78rem; font-weight: 900; text-decoration: none; backdrop-filter: blur(12px); }
.hud-brand strong { display: block; font-size: 1rem; letter-spacing: -.02em; text-shadow: 0 1px 12px #000; }
.eyebrow { display: block; margin: 0 0 2px; color: #98aac3; font-size: .65rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.space-chip select { max-width: 145px; min-height: 44px; padding: 8px 30px 8px 11px; background: rgba(8, 13, 23, .72); color: #eef4ff; backdrop-filter: blur(12px); }
.hud-button { display: grid; place-items: center; min-width: 44px; padding-inline: 10px; backdrop-filter: blur(12px); }

.sync-status, .stage-hint, .item-count, .sun-hint { position: absolute; z-index: 3; margin: 0; border: 1px solid rgba(127, 154, 190, .16); border-radius: 999px; background: rgba(6, 10, 18, .56); color: #98aac3; font-size: .7rem; backdrop-filter: blur(10px); pointer-events: none; }
.stage-hint { left: 50%; top: max(15px, env(safe-area-inset-top)); max-width: 44vw; padding: 7px 10px; transform: translateX(-50%); text-align: center; }
.sync-status { left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); max-width: 46vw; padding: 6px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-count { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); padding: 6px 9px; }
.sun-hint { left: 50%; top: 56%; padding: 6px 10px; transform: translate(-50%, -50%); color: #ffe9a1; animation: breathe 2.4s ease-in-out infinite; }
.sun-hint[hidden] { display: none; }
.flight-exit { position: absolute; z-index: 5; left: 50%; top: max(60px, calc(env(safe-area-inset-top) + 52px)); min-height: 38px; padding: 7px 12px; transform: translateX(-50%); border-radius: 999px; border-color: rgba(117, 189, 255, .48); background: rgba(8, 17, 30, .82); color: #cce8ff; backdrop-filter: blur(12px); }
.flight-exit[hidden] { display: none; }

.empty-state { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; padding: 28px; text-align: center; pointer-events: none; }
.empty-state span { font-size: 2.5rem; color: #fff0a0; }
.empty-state h2 { margin: 8px 0 4px; }
.empty-state p { margin: 0; color: #92a2ba; }
.empty-state[hidden] { display: none; }

.panel { position: absolute; z-index: 6; width: min(390px, calc(100% - 24px)); padding: 15px; border: 1px solid rgba(130, 161, 202, .26); border-radius: 20px; background: rgba(8, 13, 23, .86); box-shadow: 0 18px 60px rgba(0, 0, 0, .35); backdrop-filter: blur(18px); }
.panel[hidden] { display: none; }
.sun-menu { left: 50%; bottom: max(58px, calc(env(safe-area-inset-bottom) + 52px)); transform: translateX(-50%); }
.editor { right: max(12px, env(safe-area-inset-right)); top: 50%; max-height: calc(100% - 130px); overflow: auto; transform: translateY(-50%); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 1.2rem; }
.panel-head-actions { display: flex; align-items: center; gap: 7px; }
.icon-button { min-width: 38px; min-height: 38px; padding: 4px; border-radius: 50%; font-size: 1.3rem; line-height: 1; }
.type-chip { padding: 5px 8px; border: 1px solid rgba(112, 143, 184, .3); border-radius: 999px; color: #a8bad4; font-size: .7rem; text-transform: capitalize; }

.solar-composer { display: flex; gap: 8px; }
.solar-composer input { min-width: 0; flex: 1; min-height: 48px; padding: 11px 12px; background: rgba(4, 9, 17, .82); color: #eef4ff; outline: none; }
.solar-composer button { font-weight: 800; border-color: rgba(255, 214, 109, .38); color: #fff0b2; }
.solar-actions { margin-top: 9px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.solar-actions button { padding-inline: 8px; font-size: .8rem; }
.panel-note { margin: 10px 2px 0; color: #8799b3; font-size: .72rem; line-height: 1.35; }

.field { display: grid; gap: 5px; margin-bottom: 10px; }
.field span, .depth-controls > span { color: #94a7c1; font-size: .72rem; font-weight: 700; }
.field input, .field textarea { width: 100%; padding: 10px 11px; background: rgba(4, 9, 17, .82); color: #edf4ff; outline: none; }
.field textarea { min-height: 112px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: #67b7ff; }
.depth-controls { margin: 12px 0; }
.depth-controls > div { margin-top: 6px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.depth-controls button { min-width: 0; padding-inline: 5px; font-size: .75rem; }
.danger { width: 100%; min-height: 40px; border-color: rgba(180, 73, 91, .46); color: #ffb9c0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes breathe { 0%, 100% { opacity: .56; } 50% { opacity: 1; } }

@media (max-width: 720px) {
  .hud-brand > div { display: none; }
  .stage-hint { top: auto; bottom: max(48px, calc(env(safe-area-inset-bottom) + 42px)); max-width: 72vw; }
  .sync-status { display: none; }
  .sun-hint { top: 58%; }
  .editor { left: 50%; right: auto; top: auto; bottom: max(54px, calc(env(safe-area-inset-bottom) + 48px)); max-height: 58%; transform: translateX(-50%); }
  .sun-menu { bottom: max(54px, calc(env(safe-area-inset-bottom) + 48px)); }
  .panel { width: min(440px, calc(100% - 18px)); padding: 13px; border-radius: 18px; }
  .depth-controls > div { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 460px) {
  .hud-brand { top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); }
  .hud-tools { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); gap: 6px; }
  .brand { width: 42px; height: 42px; }
  .space-chip select { max-width: 120px; min-height: 42px; font-size: .8rem; }
  .hud-button { min-width: 42px; min-height: 42px; }
  .stage-hint { font-size: .64rem; }
  .solar-composer { flex-direction: column; }
  .solar-actions { grid-template-columns: 1fr 1fr; }
  .solar-actions button:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .sun-hint { animation: none; }
}
