@font-face {
  font-family: "Noto Sans Khmer";
  src: url("khmer-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant";
  src: url("display-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #02110f;
  color: #f6efe2;
}

body {
  display: flex;
  justify-content: center;
  font-family: "Noto Sans Khmer", "Cormorant", Palatino, serif;
  font-size: 16px;
  line-height: 1.55;
}

button, input { font-family: inherit; }

.shell {
  width: 100%;
  max-width: 560px;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(120% 42% at 50% -8%, rgba(0, 77, 65, 0.9), transparent 58%),
    radial-gradient(70% 36% at 100% 100%, rgba(62, 64, 149, 0.38), transparent 52%),
    radial-gradient(60% 28% at 0% 78%, rgba(150, 57, 102, 0.28), transparent 50%),
    #041513;
  box-shadow: 0 0 0 1px rgba(250, 168, 49, 0.12);
}

.shell.playing .mast,
.shell.playing .pier-nav { display: none; }

.mast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 2px;
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mono {
  width: 22px;
  height: 34px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 4px;
  flex: none;
}

.mono i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff1cc, #faa831 42%, #ed3237 78%);
  box-shadow: 0 0 6px rgba(250, 168, 49, 0.75);
}

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

.brand-kicker,
.eyebrow {
  margin: 0;
  color: #faa831;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: lowercase;
}

.brand-name {
  margin: 0;
  font-family: "Cormorant", Palatino, serif;
  font-size: 22px;
  line-height: 1;
  color: #fff8ea;
}

.sound {
  flex: none;
  border: 1px solid rgba(250, 168, 49, 0.55);
  background: rgba(8, 28, 24, 0.72);
  color: #faa831;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  font-weight: 600;
  font-size: 13px;
}

.pier-nav {
  flex: none;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  max-width: 100%;
}

.pier-nav::-webkit-scrollbar { display: none; }

.pier-nav ol {
  list-style: none;
  display: flex;
  width: max-content;
  min-width: 100%;
  margin: 0;
  padding: 6px 8px 8px;
  gap: 0;
}

.pier-nav a {
  position: relative;
  flex: 1 0 auto;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0 6px 2px;
  color: #d9cbb8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.pier-nav a::before {
  content: "";
  position: absolute;
  top: 6px;
  right: 50%;
  left: -50%;
  height: 2px;
  background: linear-gradient(90deg, rgba(250, 168, 49, 0.05), rgba(250, 168, 49, 0.85));
}

.pier-nav li:first-child a::before { display: none; }

.post {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #faa831;
  background: #06221e;
  box-shadow: inset 0 0 0 2px #021614;
  position: relative;
  z-index: 1;
}

.pier-nav a.active { color: #faa831; }

.pier-nav a.active .post {
  background: radial-gradient(circle at 40% 40%, #fff6dd, #faa831 46%, #ed3237);
  box-shadow: 0 0 10px #faa831;
}

.stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  overscroll-behavior: none;
}

.stage.locked {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 12px 22px;
}

.hero {
  position: relative;
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  min-height: 168px;
  background: #004d41;
  box-shadow: 0 0 0 1px rgba(250, 168, 49, 0.45);
}

.hero img,
.story img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.hero img { height: min(42dvh, 340px); }

.hero figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 36px 14px 12px;
  background: linear-gradient(transparent, rgba(2, 16, 14, 0.94));
}

h1, h2, p { overflow-wrap: break-word; }

.hero h1,
.page-head h1,
.panel h2 {
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
}

.hero h1 { font-size: clamp(32px, 10vw, 52px); }

.page-head { padding-top: 4px; }

.page-head h1 { font-size: clamp(26px, 7vw, 36px); }

.page-head p,
.lead,
.fine,
.story p,
.step p,
.route-copy p {
  margin: 0;
  color: #eadfce;
}

.lead { font-size: 1.02rem; }

.stat-row {
  display: flex;
  gap: 8px;
}

.stat {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 8px 4px 10px;
  border-radius: 14px;
  background:
    linear-gradient(#0c2420, #0c2420) padding-box,
    linear-gradient(160deg, #faa831, #ed3237 55%, #3e4095) border-box;
  border: 1px solid transparent;
}

.stat b {
  display: block;
  font-family: "Cormorant", Palatino, serif;
  font-size: clamp(26px, 8vw, 36px);
  line-height: 1;
  color: #faa831;
}

.stat span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: #eadfce;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gold-btn,
.ghost-btn,
.route-card,
.ledger-row,
.sound,
.pause,
.moor {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.gold-btn,
.ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.35;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
}

.gold-btn {
  color: #2a1604;
  border: 0;
  background:
    radial-gradient(120% 90% at 18% 0%, #ffe7b8, transparent 52%),
    linear-gradient(180deg, #ffe1a3, #faa831 42%, #d86a22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 8px 16px rgba(0, 0, 0, 0.28), 0 0 0 1px #7a3b12;
}

.ghost-btn {
  color: #faa831;
  background: rgba(6, 24, 22, 0.4);
  border: 1px solid rgba(250, 168, 49, 0.55);
}

.gold-btn:active,
.ghost-btn:active,
.moor:active { transform: translateY(1px); }

.feature,
.route-card,
.step,
.panel,
.story {
  background:
    linear-gradient(#0c2420, #0c2420) padding-box,
    linear-gradient(145deg, rgba(250, 168, 49, 0.95), rgba(237, 50, 55, 0.7) 42%, rgba(62, 64, 149, 0.9)) border-box;
  border: 1px solid transparent;
  border-radius: 16px;
}

.feature {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.feature img,
.step img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: radial-gradient(circle, rgba(250, 168, 49, 0.16), transparent 70%);
}

.feature h2,
.step h2,
.story h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  line-height: 1.3;
}

.route-list,
.timeline,
.stories,
.ledger-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.route-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  text-align: left;
  text-decoration: none;
  color: inherit;
  font: inherit;
}

.route-card.is-locked { opacity: 0.5; }

.route-no {
  font-size: 1.45rem;
  line-height: 1;
  color: #faa831;
  width: 1.8rem;
}

.route-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: none;
}

.meta {
  color: #faa831;
  font-size: 12px;
  font-weight: 600;
}

.pips { display: inline-flex; gap: 4px; }

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #1b3330;
  box-shadow: inset 0 0 0 1px rgba(250, 168, 49, 0.6);
}

.pip.on {
  background: radial-gradient(circle at 35% 35%, #fff3d2, #faa831 55%, #d86a22);
}

.step {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  align-items: center;
}

.step-no {
  font-family: "Cormorant", Palatino, serif;
  color: #faa831;
  font-size: 13px;
}

.story { padding: 12px; }

.story img {
  height: 180px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.story-kicker {
  margin: 0 0 4px;
  color: #f46d34;
  font-size: 13px;
  font-weight: 600;
}

.play {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.hud {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 4px;
}

.pause {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  border: 1px solid rgba(250, 168, 49, 0.55);
  background: #0c2420;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.pause i {
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: #faa831;
  display: block;
}

.hud-main { flex: 1; min-width: 0; }

.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hull, .seats { display: flex; gap: 3px; flex: none; }

.heart, .pip-seat {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.heart {
  background: #2a1214;
  box-shadow: inset 0 0 0 1px rgba(237, 50, 55, 0.85);
}

.heart.on { background: #ed3237; }

.pip-seat {
  background: #10211e;
  box-shadow: inset 0 0 0 1px rgba(250, 168, 49, 0.7);
}

.num {
  margin-left: auto;
  font-family: "Cormorant", Palatino, serif;
  font-size: 28px;
  line-height: 1;
  color: #fff6e4;
  font-variant-numeric: tabular-nums;
}

.track {
  margin-top: 4px;
  height: 6px;
  border-radius: 99px;
  background: #14312c;
  overflow: hidden;
}

.track span,
.silt span {
  display: block;
  height: 100%;
  width: 0;
}

.track span { background: linear-gradient(90deg, #ed3237, #faa831); }

.goal {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.3;
  color: #faa831;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.silt {
  flex: none;
  height: 3px;
  margin: 0 10px;
  border-radius: 99px;
  overflow: hidden;
  background: transparent;
}

.silt span { background: #e6d2a8; }
.silt.warn span { background: #ed3237; }

.field {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 6px 10px;
  border-radius: 16px;
  overflow: hidden;
  background: #031816;
  box-shadow:
    0 0 0 1px rgba(250, 168, 49, 0.9),
    0 0 0 5px #06241f,
    0 0 0 6px rgba(237, 50, 55, 0.55);
}

.field.hurt { box-shadow: 0 0 0 2px #ed3237, 0 0 0 6px #3a1014; }

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: #031816;
}

.toast {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  margin: 0;
  text-align: center;
  color: #fff6e4;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
  z-index: 2;
  font-size: 14px;
  line-height: 1.35;
}

.veil {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(2, 14, 12, 0.72);
}

.veil[hidden] { display: none; }

.panel {
  width: min(100%, 360px);
  max-height: 100%;
  overflow: auto;
  padding: 16px;
}

.panel h2 { font-size: 1.45rem; margin-bottom: 6px; }

.panel .actions { margin-top: 12px; }

.score-block {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0;
}

.score-block .num { font-size: 42px; margin: 0; }

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin: 0;
}

.facts div { min-width: 0; }

.facts dt {
  margin: 0;
  font-size: 12px;
  color: #c9bba6;
}

.facts dd {
  margin: 0;
  font-weight: 600;
}

.moor-bar {
  flex: none;
  display: flex;
  justify-content: center;
  padding: 6px 12px 10px;
}

.moor {
  width: min(100%, 440px);
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  color: #2a1604;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 18% 0%, #ffe7b8, transparent 52%),
    linear-gradient(180deg, #ffe1a3, #faa831 42%, #d86a22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 8px 16px rgba(0, 0, 0, 0.28);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.15;
}

.moor-kicker {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.78;
}

.moor.armed {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 0 0 2px #ed3237, 0 0 18px rgba(250, 168, 49, 0.85);
}

.ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 10px 2px;
  border-bottom: 1px solid rgba(250, 168, 49, 0.2);
}

.ledger-row.is-locked { opacity: 0.48; }

.ledger-score {
  font-family: "Cormorant", Palatino, serif;
  font-size: 28px;
  line-height: 1;
  color: #faa831;
}

.user-select, .play, .mast, .pier-nav { user-select: none; -webkit-user-select: none; }

button:focus-visible,
a:focus-visible {
  outline: 2px solid #faa831;
  outline-offset: 2px;
}

@media (min-width: 400px) {
  html { font-size: 17px; }
}

@media (min-width: 480px) {
  html { font-size: 18px; }
  .hero img { height: min(46dvh, 420px); }
}

@media (max-height: 560px) {
  .hero img { height: 168px; }
  .moor { min-height: 46px; }
  .mast { padding-top: 4px; }
  .story img { height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  .moor.armed { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 0 0 2px #ed3237; }
}
