:root {
  color-scheme: dark;
  --bg: #101014;
  --ink: #f7efe7;
  --muted: #b8aaa0;
  --line: rgba(255, 255, 255, 0.14);
  --panel: rgba(18, 18, 24, 0.78);
  --panel-strong: rgba(27, 27, 35, 0.92);
  --accent: #e8bd6d;
  --accent-2: #8fc7b4;
  --danger: #e78d88;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(16, 16, 20, 0.15), rgba(16, 16, 20, 0.72)),
    #101014;
  box-shadow: var(--shadow);
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
}

.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
}

.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(12, 12, 17, 0.24), rgba(12, 12, 17, 0.72) 52%, rgba(12, 12, 17, 0.95)),
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.12), transparent 34%);
}

.bg-menu::before {
  background-image:
    linear-gradient(140deg, rgba(28, 25, 29, 0.15), rgba(18, 18, 23, 0.7)),
    url("/assets/bedroom.png");
}

.bg-bedroom::before,
.bg-wake::before {
  background-image: url("/assets/bedroom.png");
}

.bg-bedroom-night::before {
  background-image: url("/assets/bedroom-night.png");
}

.bg-cafe::before {
  background-image: url("/assets/cafe.png");
}

.bg-campus::before {
  background-image: url("/assets/campus.png");
}

.bg-mirror::before {
  background-image: url("/assets/mirror.png");
}

.loading-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 14px;
  text-align: center;
  color: var(--muted);
}

.brand-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 44px;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.24);
}

.top-row,
.menu-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

.title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 48px;
  line-height: 0.95;
  letter-spacing: 0;
}

.subtitle {
  margin: 10px 0 0;
  max-width: 300px;
  color: var(--muted);
  line-height: 1.5;
}

.energy-pill,
.mini-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 10, 14, 0.58);
  white-space: nowrap;
}

.menu-main {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.primary-button,
.secondary-button,
.choice-button,
.icon-button {
  min-height: 50px;
  border-radius: 8px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-button {
  background: linear-gradient(135deg, #d9a94f, #f0d394);
  color: #21170e;
  font-weight: 800;
}

.secondary-button {
  color: var(--ink);
}

.primary-button:active,
.secondary-button:active,
.choice-button:active,
.icon-button:active {
  transform: scale(0.985);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.menu-footer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  backdrop-filter: blur(18px);
}

.character-builder {
  margin-top: auto;
  display: grid;
  gap: 12px;
  max-height: calc(100dvh - 124px);
  overflow: auto;
  padding-bottom: 2px;
}

.character-preview {
  position: relative;
  min-height: 310px;
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: end center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.28)),
    rgba(18, 18, 24, 0.72);
}

.character-preview::before {
  content: "";
  position: absolute;
  inset: auto 18% 0;
  height: 34%;
  border-radius: 50% 50% 0 0;
  background: rgba(232, 189, 109, 0.13);
  filter: blur(24px);
}

.character-preview::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 18px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--style-swatch, rgba(255, 255, 255, 0.16));
}

.character-preview img {
  position: relative;
  z-index: 1;
  width: min(56vw, 235px);
  max-height: 300px;
  object-fit: contain;
  object-position: bottom center;
  filter: var(--heroine-filter, none) drop-shadow(0 20px 34px rgba(0, 0, 0, 0.62));
}

.appearance-tags {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.appearance-tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(9, 9, 13, 0.68);
  color: var(--ink);
  font-size: 12px;
}

.hair-light {
  --heroine-filter: brightness(1.08) saturate(0.88) sepia(0.18);
}

.hair-red {
  --heroine-filter: sepia(0.28) saturate(1.18) hue-rotate(-12deg);
}

.hair-short img {
  transform: scale(0.97);
}

.outfit-collected {
  --style-swatch: #667957;
}

.outfit-casual {
  --style-swatch: #77706a;
}

.outfit-bright {
  --style-swatch: linear-gradient(135deg, #e95f72, #e8bd6d);
}

.outfit-bright img {
  filter: var(--heroine-filter, none) saturate(1.28) brightness(1.06) drop-shadow(0 20px 34px rgba(0, 0, 0, 0.62));
}

.outfit-closed {
  --style-swatch: #1e2430;
}

.outfit-closed img {
  filter: var(--heroine-filter, none) brightness(0.82) saturate(0.9) drop-shadow(0 20px 34px rgba(0, 0, 0, 0.62));
}

.makeup-none img {
  opacity: 0.92;
}

.makeup-eyes img {
  filter: var(--heroine-filter, none) contrast(1.12) saturate(1.05) drop-shadow(0 20px 34px rgba(0, 0, 0, 0.62));
}

.makeup-lip img {
  filter: var(--heroine-filter, none) saturate(1.2) hue-rotate(-4deg) drop-shadow(0 20px 34px rgba(0, 0, 0, 0.62));
}

.character-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  padding: 0 12px;
}

.story-layout {
  justify-content: flex-end;
  gap: 14px;
}

.story-header {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.story-card {
  position: relative;
  z-index: 3;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(11, 11, 15, 0.82);
  backdrop-filter: blur(20px);
  padding: 16px;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.character-sprite {
  position: absolute;
  left: 50%;
  bottom: 268px;
  z-index: 1;
  width: min(76vw, 390px);
  max-height: 58vh;
  object-fit: contain;
  object-position: bottom center;
  transform: translateX(-50%);
  filter: drop-shadow(0 22px 36px rgba(0, 0, 0, 0.58));
  pointer-events: none;
  animation: sprite-in 240ms ease both;
}

.character-sprite.is-heroine {
  width: min(66vw, 330px);
}

.character-sprite.is-kirill {
  width: min(70vw, 350px);
}

.character-sprite.is-danya {
  width: min(74vw, 370px);
}

.character-sprite.is-ira {
  width: min(66vw, 330px);
}

@keyframes sprite-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.speaker {
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 9px;
}

.story-text {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.54;
  white-space: pre-wrap;
}

.story-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.choices {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 9px;
}

.choice-button {
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  line-height: 1.25;
}

.choice-button.premium {
  border-color: rgba(232, 189, 109, 0.64);
  background: rgba(73, 55, 25, 0.86);
}

.choice-result {
  position: absolute;
  top: max(64px, calc(env(safe-area-inset-top) + 56px));
  left: 18px;
  right: 18px;
  z-index: 6;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.choice-result.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.choice-result-card {
  border: 1px solid rgba(143, 199, 180, 0.46);
  border-radius: 8px;
  padding: 13px;
  background: rgba(14, 17, 19, 0.9);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
}

.choice-result-card strong {
  display: block;
  line-height: 1.35;
}

.result-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.result-lines span {
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(143, 199, 180, 0.14);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.stat-row {
  display: grid;
  gap: 7px;
}

.stat-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: 50%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.ending-summary {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 12px;
}

.disclaimer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.admin-body {
  background: #151519;
}

.admin-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0;
}

.admin-topbar,
.admin-grid {
  display: grid;
  gap: 16px;
}

.admin-topbar {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.admin-topbar h1 {
  margin: 0;
}

.admin-grid {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.admin-panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.admin-panel h2 {
  margin: 0 0 12px;
}

#storyEditor {
  width: 100%;
  min-height: 72vh;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f0f13;
  color: #f3eee8;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.admin-stats {
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.admin-status {
  margin-top: 14px;
  color: var(--accent-2);
}

@media (max-width: 720px) {
  .admin-grid,
  .admin-topbar {
    grid-template-columns: 1fr;
  }

  .title {
    font-size: 42px;
  }
}
