:root {
  --bg: #101827;
  --bg2: #1f2b55;
  --card: rgba(255, 255, 255, 0.12);
  --card-strong: rgba(255, 255, 255, 0.18);
  --line: rgba(255, 255, 255, 0.22);
  --text: #f8fbff;
  --muted: #cbd8ef;
  --accent: #76e4f7;
  --accent2: #ffd166;
  --good: #8ef0a1;
  --bad: #ff8fa3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(118, 228, 247, 0.35), transparent 36rem),
    radial-gradient(circle at bottom right, rgba(255, 209, 102, 0.18), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg2));
}

button, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
button:hover { transform: translateY(-1px); background: rgba(255,255,255,.22); }
button.primary {
  color: #102033;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  font-weight: 800;
}

.app-shell {
  width: min(1420px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 22px;
  display: grid;
  gap: 16px;
}
.glass {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--card);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
  backdrop-filter: blur(16px);
}
.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .76rem;
  font-weight: 800;
}
h1, h2 { margin: 0; line-height: 1.08; }
h1 { font-size: clamp(1.55rem, 3vw, 2.8rem); }
h2 { font-size: 1.2rem; }
.status-pill {
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .7rem 1rem;
  background: rgba(0,0,0,.18);
  color: var(--muted);
}
.status-pill.ready { color: var(--good); }
.status-pill.error { color: var(--bad); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 16px;
  min-height: 560px;
}
.viewer-card {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  background:
    linear-gradient(rgba(8, 14, 26, 0.18), rgba(8, 14, 26, 0.26)),
    url('./public/images/background.png') center center / cover no-repeat;
}
#stage {
  width: 100%;
  height: 100%;
  display: block;
  min-height: 560px;
}
.viewer-toolbar {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.speech-bubble {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(520px, 80%);
  padding: 12px 16px;
  border-radius: 20px 20px 20px 6px;
  background: white;
  color: #172036;
  font-weight: 800;
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.docs-panel {
  padding: 18px;
  overflow: auto;
  max-height: 650px;
}
.hint { color: var(--muted); margin: 8px 0 14px; }
kbd {
  padding: 2px 6px;
  border-radius: 7px;
  background: rgba(255,255,255,.16);
  border: 1px solid var(--line);
}
.function-grid { display: grid; gap: 10px; }
.function-card {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 18px;
  background: rgba(0,0,0,.16);
  padding: 12px;
}
.function-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--accent2);
}
.function-card code {
  display: block;
  white-space: nowrap;
  overflow-x: auto;
  color: #e9fbff;
  background: rgba(0,0,0,.26);
  border-radius: 12px;
  padding: 8px;
  margin-top: 8px;
}
.function-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.function-card button { margin-top: 8px; padding: .42rem .72rem; font-size: .85rem; }

.code-panel { padding: 16px; }
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
#codeInput {
  width: 100%;
  min-height: 168px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  color: #eef9ff;
  background: rgba(4, 9, 20, .72);
  outline: none;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 1rem;
  line-height: 1.55;
}
#codeInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(118,228,247,.18); }
.console {
  min-height: 44px;
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 16px;
  background: rgba(0,0,0,.25);
  color: var(--muted);
  font-family: "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
}
.console.ok { color: var(--good); }
.console.error { color: var(--bad); }

@media (max-width: 980px) {
  .game-layout { grid-template-columns: 1fr; }
  .docs-panel { max-height: none; }
  .hero-panel { align-items: flex-start; flex-direction: column; }
  .status-pill { white-space: normal; }
}
