:root {
  color-scheme: light;
  --bg-top: #1c1734;
  --bg-bottom: #3a2852;
  --panel: rgba(245, 239, 255, 0.92);
  --panel-strong: #fdfaff;
  --border: #aa92dc;
  --text: #2f2148;
  --muted: #6b5f8b;
  --accent: #8d6be8;
  --accent-strong: #6b4fd1;
  --accent-soft: #f0e9ff;
  --choice: #f8f4ff;
  --shadow: rgba(18, 8, 44, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(163, 139, 255, 0.35), transparent 25%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

button {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-card {
  width: min(100%, 820px);
  background: var(--panel);
  border: 1px solid rgba(170, 146, 220, 0.9);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 50px var(--shadow);
  backdrop-filter: blur(12px);
}

.topbar,
.stage,
.hud,
.speaker-row {
  display: flex;
}

.topbar,
.speaker-row {
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #d9c4ff;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.75rem);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.ghost-button,
.choice-button {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: 14px;
  cursor: pointer;
}

.ghost-button {
  padding: 10px 16px;
}

.stage {
  gap: 18px;
  align-items: stretch;
}

.portrait-card,
.dialogue-panel,
.meter,
.ending {
  border: 1px solid rgba(170, 146, 220, 0.9);
  background: var(--panel-strong);
  border-radius: 20px;
}

.portrait-card {
  flex: 1.2;
  padding: 18px;
  overflow: hidden;
}

.portrait {
  margin: 0;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(147, 117, 255, 0.28), transparent 30%),
    linear-gradient(180deg, rgba(14, 13, 44, 0.14), rgba(51, 25, 77, 0.08)),
    linear-gradient(180deg, #1b1a43, #3b2a71 72%, #715cd3 100%);
  box-shadow: inset 0 0 0 1px rgba(200, 190, 255, 0.3);
}

.portrait::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 34%, transparent 70%, rgba(143, 117, 255, 0.12));
  pointer-events: none;
}

.portrait__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.character-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.hud {
  flex: 1;
  flex-direction: column;
  gap: 12px;
}

.meter {
  padding: 16px;
}

.meter span {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.meter strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
}

.dialogue-panel {
  margin-top: 18px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(246, 242, 255, 0.98), rgba(232, 241, 255, 0.96)),
    var(--panel-strong);
  box-shadow:
    inset 0 0 0 2px rgba(186, 173, 236, 0.32),
    inset 0 -10px 18px rgba(150, 190, 255, 0.1);
}

.dialogue-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 34px;
  background: linear-gradient(180deg, rgba(121, 99, 203, 0.14), rgba(121, 99, 203, 0.02));
  border-bottom: 1px solid rgba(134, 114, 218, 0.28);
}

.dialogue-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(180deg, rgba(124, 116, 190, 0.055) 0 1px, transparent 1px 7px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 28%);
  pointer-events: none;
}

.speaker-row {
  position: relative;
  z-index: 1;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(134, 114, 218, 0.2);
}

.speaker-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid rgba(136, 117, 219, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
}

.speaker-chip__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #dff7ff, #81d5ff 55%, #5577f8);
  box-shadow: 0 0 10px rgba(111, 197, 255, 0.9);
}

.scene-tag {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dialogue-text {
  position: relative;
  z-index: 1;
  margin: 12px 0 10px;
  font-size: 1.16rem;
  line-height: 1.6;
  padding: 8px 4px 0;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.55);
}

.result-text {
  position: relative;
  z-index: 1;
  min-height: 1.5em;
  margin: 0;
  color: var(--accent-strong);
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

.choices {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.choice-button {
  width: 100%;
  text-align: left;
  padding: 16px;
  background: var(--choice);
}

.choice-button:hover,
.ghost-button:hover {
  border-color: var(--accent);
}

.choice-button strong {
  display: block;
  margin-bottom: 4px;
}

.choice-button span {
  color: var(--muted);
}

.ending {
  margin-top: 18px;
  padding: 18px;
  background: var(--accent-soft);
}

.ending h2 {
  margin: 0 0 8px;
}

.ending p {
  margin: 0;
  line-height: 1.6;
}

@media (max-width: 720px) {
  .game-card {
    padding: 18px;
  }

  .topbar,
  .stage,
  .character-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud {
    width: 100%;
  }

  .ghost-button {
    width: 100%;
  }
}
