:root {
  --ink: #1c1410;
  --parchment: #f3e6d0;
  --parchment-deep: #e8d4b0;
  --saffron: #c45c26;
  --marigold: #d4a017;
  --lotus: #b84a6e;
  --jungle: #2f5d3a;
  --sky: #7eb8c9;
  --temple: #8b3a2a;
  --gold: #c9a227;
  --veil: rgba(18, 10, 6, 0.72);
  --panel: rgba(243, 230, 208, 0.94);
  --shadow: rgba(40, 20, 10, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, #3a2218 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, #1a3a2e 0%, transparent 45%),
    linear-gradient(165deg, #1a120c 0%, #2a1810 40%, #0f1a16 100%);
  color: var(--parchment);
  font-family: "Cormorant Garamond", Georgia, serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

#app {
  width: min(100%, 1040px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.brand .om {
  font-family: "Tiro Devanagari Hindi", serif;
  font-size: 1.85rem;
  color: var(--marigold);
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--parchment);
}

#hud {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.hud-item {
  min-width: 4.5rem;
  padding: 0.35rem 0.7rem;
  background: linear-gradient(180deg, rgba(243, 230, 208, 0.12), rgba(243, 230, 208, 0.05));
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 2px;
}

.hud-item .label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(243, 230, 208, 0.55);
}

.hud-item span:last-child {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--marigold);
}

.hud-item.secret span:last-child {
  color: rgba(243, 230, 208, 0.45);
  letter-spacing: 0.2em;
}

#stage-wrap {
  position: relative;
  border: 2px solid rgba(201, 162, 39, 0.55);
  box-shadow:
    0 0 0 1px rgba(139, 58, 42, 0.35),
    0 22px 56px var(--shadow),
    inset 0 0 0 1px rgba(255, 236, 200, 0.08);
  background: #0a1210;
  overflow: hidden;
  border-radius: 2px;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  /* Smooth illustration scaling — not pixel art */
  image-rendering: auto;
  image-rendering: high-quality;
  -ms-interpolation-mode: bicubic;
  vertical-align: middle;
  background: #102028;
}

#stage-wrap::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(12, 6, 2, 0.22) 100%);
  opacity: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.85rem;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(212, 160, 23, 0.15), transparent 55%),
    var(--veil);
  backdrop-filter: blur(2px);
}

.overlay.choice-fullscreen {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background: #0a0806;
  backdrop-filter: none;
}

.overlay.visible {
  display: flex;
}

.panel {
  width: min(100%, 460px);
  padding: 1.75rem 1.85rem 1.6rem;
  background:
    linear-gradient(145deg, rgba(255, 248, 235, 0.98), rgba(232, 212, 176, 0.96));
  color: var(--ink);
  border: 1px solid rgba(139, 58, 42, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.panel.hidden {
  display: none;
}

/* Title — lotus + Begin only */
body.title-screen #topbar,
body.title-screen #footer {
  visibility: hidden;
  pointer-events: none;
}

body.title-screen .overlay {
  background:
    radial-gradient(ellipse at 50% 42%, rgba(40, 90, 100, 0.35), transparent 55%),
    radial-gradient(ellipse at 50% 50%, #1a1010 0%, #070505 70%);
  backdrop-filter: none;
}

.panel.panel-title {
  width: auto;
  max-width: none;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  color: #fff8ef;
}

.title-lotus-btn {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.title-lotus {
  display: block;
  width: min(42vw, 280px);
  height: auto;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.45));
  animation: titleLotusFloat 3.6s ease-in-out infinite;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.title-begin {
  font-family: "Cormorant Garamond", "Tiro Devanagari Hindi", serif;
  font-size: clamp(1.6rem, 4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #f6e7c8;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.title-lotus-btn:hover .title-lotus,
.title-lotus-btn:focus-visible .title-lotus {
  transform: scale(1.04);
  filter: drop-shadow(0 14px 34px rgba(255, 180, 210, 0.28));
}

.title-lotus-btn:hover .title-begin,
.title-lotus-btn:focus-visible .title-begin {
  color: #fff8ef;
}

.title-lotus-btn:focus-visible {
  outline: none;
}

@keyframes titleLotusFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-family: "Tiro Devanagari Hindi", "Cormorant Garamond", serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--temple);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 2.35rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

.lede {
  margin: 0 0 1.25rem;
  font-size: 1.08rem;
  line-height: 1.45;
  color: rgba(28, 20, 16, 0.82);
}

.hint {
  margin: 1rem 0 0;
  font-size: 0.92rem;
  color: rgba(28, 20, 16, 0.55);
}

.level-select {
  margin: 1.1rem 0 0;
  text-align: left;
}

.level-select-label {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(28, 20, 16, 0.5);
}

.level-select-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
}

.level-select-grid .btn-level {
  appearance: none;
  border: 1px solid rgba(139, 58, 42, 0.35);
  background: rgba(255, 255, 255, 0.4);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.15;
  padding: 0.45rem 0.35rem;
  cursor: pointer;
  border-radius: 2px;
  text-align: center;
}

.level-select-grid .btn-level:hover {
  background: rgba(255, 248, 235, 0.9);
  border-color: var(--saffron);
}

.level-select-grid .btn-level small {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(28, 20, 16, 0.55);
}

.level-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.level-nav .btn-nav {
  appearance: none;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(243, 230, 208, 0.08);
  color: rgba(243, 230, 208, 0.85);
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
}

.level-nav .btn-nav:hover {
  color: var(--marigold);
  border-color: var(--marigold);
}

#level-jump {
  appearance: none;
  max-width: 11rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(18, 10, 6, 0.55);
  color: var(--parchment);
  font: inherit;
  font-size: 0.82rem;
  border-radius: 2px;
  cursor: pointer;
}

#level-jump:hover,
#level-jump:focus {
  border-color: var(--marigold);
  outline: none;
}

.btn {
  appearance: none;
  border: 1px solid rgba(139, 58, 42, 0.45);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.65rem 1.15rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.75);
  transform: translateY(-1px);
}

.btn.primary {
  background: linear-gradient(180deg, #d4783a, var(--saffron));
  border-color: #8b3a2a;
  color: #fff8ef;
}

.btn.primary:hover {
  background: linear-gradient(180deg, #e0894a, #d46830);
}

.choice-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.15rem;
}

.panel.panel-choice:not(.hidden) {
  width: 100%;
  height: 100%;
  max-height: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  background: #0c0a08;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.choice-stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(40, 24, 12, 0.5), #050403 75%);
}

.choice-scene {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.choice-scene[hidden] {
  display: none !important;
}

.choice-stage-fallback {
  color: rgba(243, 230, 208, 0.55);
  font-size: 1.2rem;
  letter-spacing: 0.06em;
}

.choice-ui {
  flex: 0 0 auto;
  max-height: 46%;
  overflow-y: auto;
  padding: 0.75rem 1rem 0.9rem;
  background:
    linear-gradient(180deg, rgba(255, 248, 235, 0.98), rgba(232, 212, 176, 0.96));
  color: var(--ink);
  border-top: 1px solid rgba(139, 58, 42, 0.35);
}

.panel-choice .eyebrow {
  margin-bottom: 0.15rem;
  font-size: 0.78rem;
}

.panel-choice h2 {
  margin: 0 0 0.3rem;
  font-size: 1.25rem;
  line-height: 1.15;
}

.panel-choice .choice-prompt {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.35;
  max-height: 4.2em;
  overflow-y: auto;
}

.choice-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: left;
  white-space: normal;
  line-height: 1.25;
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.5);
}

.choice-btn.primary,
.choice-btn:nth-child(2) {
  /* Keep both paths visually equal — no “correct” styling */
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(139, 58, 42, 0.45);
  color: var(--ink);
}

.choice-tag {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.65;
  font-weight: 600;
}

.choice-label {
  font-weight: 600;
}

.choice-tally {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.choice-tally .chip {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.12rem 0.4rem;
  border-radius: 2px;
  background: rgba(28, 20, 16, 0.08);
  border: 1px solid rgba(139, 58, 42, 0.25);
  color: var(--ink);
}

.choice-tally .chip.gain {
  background: rgba(47, 93, 58, 0.12);
  border-color: rgba(47, 93, 58, 0.35);
}

.choice-tally .chip.loss {
  background: rgba(139, 58, 42, 0.1);
  border-color: rgba(139, 58, 42, 0.35);
}

.karma-reveal {
  margin: 0 0 1.1rem;
  padding: 0.75rem;
  background: rgba(47, 93, 58, 0.1);
  border: 1px dashed rgba(47, 93, 58, 0.35);
  font-size: 1rem;
  line-height: 1.4;
}

#footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.95rem;
  color: rgba(243, 230, 208, 0.55);
}

#footer .sep {
  opacity: 0.4;
}

#level-name {
  color: var(--marigold);
  font-weight: 600;
}

.btn-mute {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(201, 162, 39, 0.45);
  color: rgba(243, 230, 208, 0.75);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  border-radius: 2px;
}

.btn-mute:hover {
  color: var(--marigold);
  border-color: var(--marigold);
}

.btn-mute[aria-pressed="true"] {
  opacity: 0.55;
}

@media (max-width: 640px) {
  body {
    padding: 0.65rem;
  }

  .panel h2 {
    font-size: 1.85rem;
  }

  .brand h1 {
    font-size: 1.35rem;
  }
}
