:root {
  --ink: #140818;
  --panel: #241433;
  --panel-2: #301848;
  --emerald: #1fa971;
  --emerald-deep: #0c6b45;
  --amethyst: #8d4dff;
  --gold: #e8c56b;
  --gold-deep: #a9782a;
  --cream: #f8e7c4;
  --muted: #cbb89a;
  --line: rgba(232, 197, 107, 0.38);
  --cloth: #0e3b2e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--cream);
  font-family: "Noto Sans Devanagari", "Nirmala UI", "Mangal", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button, input { font: inherit; color: inherit; }

button { touch-action: manipulation; }

img { display: block; max-width: 100%; }

.shell {
  width: min(100%, 560px);
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% -10%, rgba(143, 77, 255, 0.28), transparent 42%),
    radial-gradient(circle at 100% 80%, rgba(31, 169, 113, 0.16), transparent 36%),
    var(--ink);
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
  min-width: 0;
}

.brand-gem {
  width: 16px;
  height: 16px;
  flex: none;
  background: radial-gradient(circle at 35% 30%, #d9ffe9, var(--emerald) 46%, var(--emerald-deep));
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0 38%);
}

.brand-copy { min-width: 0; flex: 1; }

.brand-copy strong,
.brand-copy em {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-copy strong { font-size: 14px; letter-spacing: 0.02em; }

.brand-copy em {
  font-style: normal;
  color: var(--gold);
  font-size: 12px;
}

.seal-count {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--gold);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.view {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.page {
  display: grid;
  gap: 12px;
  padding: 4px 12px 18px;
  min-width: 0;
}

.page-head h1,
.hero-copy h1,
.order-card h2,
.city-copy h2,
.people h2,
.catalog h2,
.rank-list h2,
.notice h2,
.stall-band h2 {
  margin: 0;
  line-height: 1.2;
}

.page-head h1,
.hero-copy h1 { font-size: clamp(28px, 8vw, 44px); }

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead, .page-head p, .story, .coach, .city-copy p, .people p, .notice p, .stall-band p, .steps span, .rank-list span {
  margin: 0;
  color: var(--muted);
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: #1a0c28;
}

.hero img,
.wide-shot,
.city-card img,
.stall-band img,
.people img {
  width: 100%;
  object-fit: cover;
}

.hero img { height: clamp(148px, 30vh, 260px); }

.awning {
  height: 12px;
  background: repeating-linear-gradient(90deg, var(--emerald) 0 16px, var(--gold) 16px 24px, #6d35d6 24px 40px);
  background-size: 40px 12px;
  animation: sway 5s linear infinite;
}

.hero-copy { padding: 12px; }

.cta, .ghost, .actions button, .text-link {
  border-radius: 14px;
  min-height: 44px;
}

.cta, .ghost, .text-link, .actions button, .ticket, .lamp, .level-chip, .gem-btn {
  cursor: pointer;
}

.cta {
  width: 100%;
  border: 0;
  background: linear-gradient(180deg, #2fe39a, var(--emerald-deep));
  color: #04140d;
  font-weight: 700;
  padding: 0 14px;
}

.ghost, .text-link {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cream);
  padding: 0 12px;
}

.text-link { width: auto; }

.seal-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mini {
  min-width: 0;
  padding: 10px 8px;
  border-radius: 16px;
  background: rgba(36, 20, 51, 0.92);
  border: 1px solid var(--line);
}

.mini b, .mini span { display: block; }

.mini b { color: var(--gold); font-size: 13px; }

.mini span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }

.stall-band, .city-card, .order-card, .tray, .tickets, .notice, .catalog, .rank-list, .steps li, .people article {
  min-width: 0;
  background: linear-gradient(180deg, rgba(232, 197, 107, 0.08), transparent 30%), var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.stall-band { display: grid; gap: 10px; padding: 10px; }

.stall-band img { height: 132px; border-radius: 14px; }

.stall-band div { display: grid; gap: 8px; align-content: center; }

.lantern-row {
  display: flex;
  justify-content: space-between;
  padding: 0 18px;
}

.lantern-row i {
  width: 12px;
  height: 28px;
  border-radius: 8px 8px 4px 4px;
  background: radial-gradient(circle at 50% 30%, #fff4c8, var(--gold) 40%, #7a4a12);
  animation: flicker 2.4s ease-in-out infinite;
}

.lantern-row i:nth-child(2) { animation-delay: .4s; background: radial-gradient(circle at 50% 30%, #e8fff4, var(--emerald), #064e32); }
.lantern-row i:nth-child(3) { animation-delay: .8s; background: radial-gradient(circle at 50% 30%, #f3e8ff, var(--amethyst), #3a1578); }
.lantern-row i:nth-child(4) { animation-delay: 1.1s; }

.level-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, var(--ink), rgba(20, 8, 24, 0.92) 70%, transparent);
}

.level-row::-webkit-scrollbar { display: none; }

.level-chip {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #1a1028;
  color: var(--cream);
}

.level-chip.is-current { background: var(--emerald-deep); color: #effff7; border-color: var(--emerald); }

.level-chip.is-done { box-shadow: inset 0 0 0 2px var(--gold); }

.level-chip:disabled { opacity: 0.35; }

.order-card, .tray, .tickets, .notice, .catalog, .rank-list { padding: 12px; }

.order-top, .ticket-line, .token-row, .split, .seal-actions, .city-copy, .people article {
  display: grid;
  gap: 8px;
}

.order-top { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }

.move-pill {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--cloth);
  color: #d9ffe9;
  font-size: 12px;
  white-space: nowrap;
}

.story { font-size: 14px; }

.split { grid-template-columns: 1fr; }

.split div { min-width: 0; display: grid; gap: 6px; }

.split span, .tray h3, .tickets h3 {
  color: var(--gold);
  font-size: 12px;
  margin: 0;
}

.coach {
  padding-top: 2px;
  font-size: 13px;
}

.token-row, .ticket-line, .catalog ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.token, .catalog-item, .empty-tray {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 12px;
  line-height: 1.25;
}

.catalog ul { margin: 8px 0 0; padding: 0; list-style: none; }

.catalog-item { list-style: none; }

.token i, .catalog-item i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  display: block;
}

.token-emerald i { background: #1fa971; }
.token-amethyst i { background: #8d4dff; }
.token-sapphire i { background: #3e7cff; }
.token-ruby i { background: #d4536a; }
.token-silk i { background: #f2d7a2; }
.token-lotus i { background: #f3a7c8; }
.token-ink i { background: #6d5a98; }
.token-ash i { background: #b7b1a8; }
.token-coin i { background: #e8c56b; }

.lamp-row { display: grid; gap: 8px; }

.lamp {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  text-align: left;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #1b102c;
  min-width: 0;
}

.lamp strong, .lamp em {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lamp em {
  grid-column: 2;
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.flame {
  width: 14px;
  height: 22px;
  border-radius: 8px 8px 5px 5px;
  background: radial-gradient(circle at 50% 30%, #fff6d0, var(--gold) 45%, #8a3d12);
  animation: flicker 1.8s ease-in-out infinite;
}

.lamp.is-locked { opacity: 0.7; }
.lamp.is-locked .flame { animation: none; filter: grayscale(0.4); }

.tickets { display: grid; gap: 8px; }

.ticket {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: left;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--cloth);
  color: #e7fff4;
}

.ticket b { font-size: 14px; }

.ticket .flow { color: var(--gold); padding: 0 2px; }

.ticket:disabled { opacity: 0.45; }

.ticket.is-ready { border-color: rgba(31, 169, 113, 0.8); box-shadow: inset 0 0 0 1px rgba(31, 169, 113, 0.35); }

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(20, 8, 24, 0), var(--ink) 30%);
}

.actions button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  min-width: 0;
  padding: 8px 4px;
}

.actions button:disabled { opacity: 0.4; }

.deliver { grid-column: 1 / -1; background: #3a2a12; color: var(--gold); }

.deliver.is-live {
  background: linear-gradient(180deg, #2fe39a, var(--emerald-deep));
  color: #04140d;
  border-color: transparent;
  opacity: 1;
}

.seal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 2, 14, 0.74);
}

.seal-card {
  width: min(100%, 420px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0%, rgba(232, 197, 107, 0.2), transparent 46%),
    #2a1244;
  border: 1px solid var(--gold);
}

.seal-actions { grid-template-columns: 1fr; }

.city-card { overflow: hidden; }

.city-card img { height: 148px; }

.city-copy { padding: 12px; }

.meta, .lock-note { margin: 0; color: var(--gold); font-size: 13px; }

.city-card.is-locked img { filter: saturate(0.4) brightness(0.7); }

.wide-shot { height: clamp(140px, 26vh, 220px); border-radius: 18px; }

.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }

.steps li { display: grid; gap: 4px; padding: 10px 12px; }

.people { display: grid; gap: 10px; }

.people article { overflow: hidden; }

.people img { height: 190px; }

.people .text-only { padding: 12px; }

.people article div { display: grid; gap: 6px; padding: 0 12px 12px; }

.rank-list { display: grid; gap: 8px; }

.rank-list p {
  margin: 0;
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.rank-list p.is-reached { outline: 1px solid var(--emerald); }

.rank-list b { color: var(--cream); }

.notice p { font-size: 14px; }

.rail {
  flex: none;
  padding: 4px 10px calc(8px + env(safe-area-inset-bottom));
  background:
    linear-gradient(var(--gold), var(--gold)) 12px 0 / calc(100% - 24px) 1px no-repeat,
    linear-gradient(180deg, rgba(20, 8, 24, 0.2), #100714 24%);
}

.rail-ribbon {
  margin: 6px 0 8px;
  text-align: center;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.rail-gems {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.gem-btn {
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  padding: 0;
  background: #123;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.28);
}

.gem-btn.is-active {
  transform: translateY(-4px);
  box-shadow: 0 0 0 2px var(--gold), 0 8px 0 rgba(0, 0, 0, 0.28);
}

.gem-round {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e7fff4, var(--emerald) 42%, #064e32);
}

.gem-hex {
  width: 56px;
  height: 58px;
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  background: radial-gradient(circle at 35% 30%, #fff1c4, #e8c56b 36%, #1fa971 70%, #064e32);
}

.gem-diamond {
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: radial-gradient(circle at 35% 30%, #e7f0ff, #3e7cff 45%, #16388c);
}

.gem-coin {
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 8px, rgba(90, 58, 12, 0.55) 9px 10px, transparent 11px),
    radial-gradient(circle at 35% 30%, #fff6d4, var(--gold) 46%, #8a5a12);
}

.gem-shield {
  clip-path: polygon(50% 0, 100% 18%, 84% 100%, 16% 100%, 0 18%);
  background: radial-gradient(circle at 35% 28%, #f4e9ff, var(--amethyst) 48%, #3a1578);
}

.people article.text-only,
.people article.text-only div { padding: 12px; }

@media (min-width: 400px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .split { grid-template-columns: 1fr 1fr; }
  .stall-band { grid-template-columns: 148px minmax(0, 1fr); align-items: center; }
  .stall-band img { height: 120px; }
  .people article:not(.text-only) {
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: center;
  }
  .people article:not(.text-only) img { height: 112px; }
  .people article:not(.text-only) div { padding: 12px 12px 12px 0; }
  .lamp-row { grid-template-columns: 1fr 1fr; }
}

@media (max-height: 680px) {
  .hero img { height: 132px; }
  .wide-shot, .city-card img { height: 120px; }
  .people img { height: 140px; }
}

@keyframes sway {
  from { background-position: 0 0; }
  to { background-position: 40px 0; }
}

@keyframes flicker {
  0%, 100% { transform: scaleY(1); opacity: 1; }
  50% { transform: scaleY(0.86); opacity: 0.8; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
