/* Base reset and layout */
html, body {
  height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  color: #0b1324;
  background: #0a0f1f;
  overflow: hidden;
}

/* Fullscreen background canvas */
#ca-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  image-rendering: pixelated;
}

/* Grid overlay canvas (for WebGPU version) */
#grid-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  pointer-events: none;
}

.btn {
    display: none;
    position: absolute;
    top: 8px;
    left: 8px;
    padding-left: 8px;
    padding-right: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
    background-color: white;
    z-index: 2;
    text-align: center;
    align-items: center;
    border-radius: 4px;
    cursor: pointer;
}

.door {
    position: fixed;
    left: 50vw;
    top: 50vh;
    transform: translate(-50%, -50%);
    max-width: 200px;
    z-index: 2;
    cursor: grabbing;
}

.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
    transform: translate(-50%, -50%);
    backface-visibility: hidden;
    perspective: 1000px;
}

@keyframes shake {

    10%,
    90% {
        transform: translate(-52%, -53%);
    }

    20%,
    80% {
        transform: translate(-48%, -49%);
    }

    30%,
    50%,
    70% {
        transform: translate(-56%, -52%);
    }

    40%,
    60% {
        transform: translate(-48%, -49%);
    }
}

/* Foreground content */
.content {
  position: relative;
  display: none;
  place-items: start center;
  min-height: 100vh;
  padding: 2rem;
  z-index: 1;
  pointer-events: none;
}

.content h1 {
  margin: 0 0 0.5rem 0;
  font-size: clamp(1.75rem, 1.2rem + 2vw, 3rem);
  color: #e6edf7;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.content p {
  max-width: 60ch;
  margin: 0;
  line-height: 1.6;
  color: #b8c5e1;
}

.controls {
  margin-top: 1.25rem;
  width: min(720px, 92vw);
  max-height: 70vh;
  background: rgba(6, 10, 24, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  backdrop-filter: blur(10px);
  padding: 1rem 1.25rem;
  pointer-events: auto;
  overflow-y: auto;
}

.controls form {
  display: grid;
  gap: 1rem;
}

.controls fieldset {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.75rem 1rem 1rem 1rem;
}

.controls legend {
  color: #e6edf7;
  padding: 0 0.5rem;
  font-weight: 600;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.control-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.controls label {
  color: #b8c5e1;
}

.controls input[type="range"] {
  width: 320px;
}

.controls output {
  min-width: 3ch;
  text-align: right;
  color: #e6edf7;
}

.controls button {
  color: #0b1324;
  background: #6bdcff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.controls button[aria-pressed="true"] {
  background: #ffc46b;
}

.controls input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #6bdcff;
}

.sources-list {
  list-style: none;
  margin: 0.5rem 0 0 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.sources-list li {
  color: #b8c5e1;
  font-size: 0.9rem;
}

/* Subtle vignette to improve contrast over bright cells */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 120% at 50% 0%, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0.35) 70%, rgba(0,0,0,0.6) 100%);
  z-index: 2;
}

/* JRPG-style text box */
.textbox {
  position: fixed;
  left: 50%;
  top: calc(50% + 140px);
  transform: translateX(-50%);
  width: min(500px, 90vw);
  min-height: 80px;
  background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
  border: 3px solid #4a4a6a;
  border-radius: 8px;
  box-shadow:
    0 0 0 2px #0a0a12,
    0 4px 20px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: 16px 20px;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.textbox.visible {
  opacity: 1;
  visibility: visible;
}

.textbox-inner {
  border: 1px solid #3a3a5a;
  border-radius: 4px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
}

.textbox-text {
  font-family: 'Courier New', monospace;
  font-size: 16px;
  line-height: 1.6;
  color: #e0e0ff;
  text-shadow: 0 0 10px rgba(100, 100, 255, 0.3);
  min-height: 1.6em;
}

.textbox-text .cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: #e0e0ff;
  margin-left: 2px;
  animation: blink 0.8s infinite;
  vertical-align: middle;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.textbox-continue {
  position: absolute;
  bottom: 8px;
  right: 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #8080a0;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Corner decorations for JRPG box */
.textbox::before,
.textbox::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #6a6a9a;
}

.textbox::before {
  top: 4px;
  left: 4px;
  border-right: none;
  border-bottom: none;
}

.textbox::after {
  top: 4px;
  right: 4px;
  border-left: none;
  border-bottom: none;
}

.textbox-corners::before,
.textbox-corners::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #6a6a9a;
}

.textbox-corners::before {
  bottom: 4px;
  left: 4px;
  border-right: none;
  border-top: none;
}

.textbox-corners::after {
  bottom: 4px;
  right: 4px;
  border-left: none;
  border-top: none;
}

