/* BigWin V2 — Layer Stacking & Core Layout */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  font-family: var(--font-ui);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Terminal offscreen canvas ── */
#terminal-canvas {
  display: none;
}

/* ── Layer 0: Boot screen ── */
#boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  transition: opacity 0.8s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#boot-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#boot-screen canvas {
  display: block;
  touch-action: none;
  /* width/height set dynamically by resize() */
}

#boot-screen #crt-overlay {
  position: static;
  inset: auto;
  width: auto;
  height: auto;
  pointer-events: auto;
  cursor: none;
  touch-action: none;
}

/* ── Layer 1: App UI ── */
#app {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Layer 2: CRT overlay ── */
#crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  width: 100vw;
  height: 100vh;
}

/* ── Layer 3: Toasts ── */
#toast-container {
  position: fixed;
  top: var(--sp-4);
  right: var(--sp-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  pointer-events: none;
  max-width: 380px;
  width: 100%;
}

#toast-container .toast {
  pointer-events: auto;
}

/* ── WebGL fallback ── */
#no-webgl {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 18px;
  text-align: center;
  gap: 8px;
  z-index: 300;
}

#no-webgl.hidden {
  display: none;
}

/* ── Scrollbar ── */
#app::-webkit-scrollbar {
  width: 6px;
}

#app::-webkit-scrollbar-track {
  background: transparent;
}

#app::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#app::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Touch device: hide custom cursor ── */
@media (pointer: coarse) {
  #boot-screen #crt-overlay { cursor: default; }
}

/* ── Portrait orientation warning ── */
#portrait-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.portrait-warning-content {
  text-align: center;
  font-family: 'Courier New', 'Lucida Console', monospace;
  color: #00ff41;
}

.portrait-warning-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.portrait-warning-title {
  font-size: 24px;
  margin-bottom: 12px;
  color: #ffd700;
}

.portrait-warning-text {
  font-size: 14px;
  margin-bottom: 32px;
  color: #00aa2a;
}

.portrait-warning-btn {
  background: none;
  border: 1px solid #00ff41;
  color: #00ff41;
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 14px;
  padding: 10px 24px;
  cursor: pointer;
  touch-action: manipulation;
}

.portrait-warning-btn:active {
  background: #00ff41;
  color: #000;
}

@media (max-width: 768px) and (orientation: portrait) {
  #portrait-warning { display: flex; }
}
