:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: rgba(12, 16, 24, 0.88);
  --ink: #f3efe6;
  --muted: #b7b0a3;
  --accent: #ff7a28;
  --line: rgba(255, 255, 255, 0.14);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

#app {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at center, #171b26 0%, #07080c 70%);
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background: #000;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 24px 80px rgba(0, 0, 0, 0.55);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  touch-action: none;
}

#hud {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(8px, 1.6vw, 16px);
}

#topBar,
#bottomBar {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.badge,
.prompt,
.help,
.flag {
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: clamp(12px, 1.5vw, 14px);
  line-height: 1.35;
}

.badge strong {
  color: var(--accent);
  letter-spacing: 0.04em;
}

.flag[data-on="true"] {
  border-color: rgba(255, 122, 40, 0.55);
  color: #ffe1c8;
}

.prompt {
  align-self: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.prompt.visible {
  opacity: 1;
  transform: translateY(0);
}

.help {
  color: var(--muted);
  max-width: 42ch;
}

#dialogue {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  bottom: clamp(12px, 3vh, 28px);
  transform: translateX(-50%);
  width: min(920px, calc(100% - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 14px;
  display: none;
}

#dialogue.open {
  display: block;
}

#dialogue .speaker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

#dialogue .line {
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.45;
  min-height: 2.9em;
}

#dialogue .hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

#touchPad {
  pointer-events: auto;
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 132px;
  height: 132px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.35);
  display: none;
  touch-action: none;
}

#touchKnob {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: rgba(255, 122, 40, 0.85);
  left: 39px;
  top: 39px;
}

body.show-touch #touchPad {
  display: block;
}

#titleSplash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 12, 0.72);
  text-align: center;
  padding: 24px;
}

#titleSplash h1 {
  font-size: clamp(22px, 4vw, 34px);
  margin-bottom: 8px;
}

#titleSplash p {
  color: var(--muted);
  max-width: 46ch;
  margin: 0 auto 18px;
  line-height: 1.45;
}

#titleSplash button,
#dialogue button {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(255, 122, 40, 0.55);
  background: linear-gradient(180deg, #ff8d45, #e25d12);
  color: #1a0d05;
  font-weight: 700;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
}

#titleSplash.hidden {
  display: none;
}

@media (max-width: 900px), (pointer: coarse) {
  body {
    /* landscape-first cue; pad remains available */
  }
  body.show-touch #touchPad {
    display: block;
  }
}
