:root {
  --gold: #D4AF37;
  --red: #8B1E3F;
  --black: #111111;
  --cream: #F6E7C1;
  --font: "Noto Sans Khmer", "Khmer Sangam MN", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--black);
  color: var(--cream);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { opacity: 0.45; cursor: default; }

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

.phone {
  width: min(100vw, 440px);
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--black) url("bg-dusk.jpg") center/cover no-repeat;
}

.splash {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: var(--black);
}

.splash.off { display: none; }

.splash-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.splash-disk {
  position: relative;
  width: min(58vw, 230px);
  animation: rise 1.5s ease both;
}

.splash-name {
  position: relative;
  margin: 0;
  color: var(--gold);
  font-size: 32px;
  font-weight: 700;
  text-shadow: 0 2px 0 var(--black);
}

@keyframes rise {
  from { transform: scale(0.86); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.onboard, .shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.onboard {
  overflow: auto;
  padding: 22px 16px 28px;
  color: var(--cream);
}

.kicker {
  margin: 0;
  color: var(--gold);
  font-weight: 700;
}

.onboard h2, .block h2, .screen h2 {
  margin: 0 0 8px;
  line-height: 1.4;
}

.chips {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  justify-content: center;
  margin: 16px 0;
}

.chip {
  width: 30%;
  background: var(--black);
  color: var(--cream);
  border: 2px solid var(--red);
  border-radius: 18px;
  padding: 8px 4px 10px;
}

.chip img { width: 72%; margin: 0 auto 4px; }
.chip.sm img { width: 48%; }
.chip.lg img { width: 90%; }

.chip.on {
  background: var(--gold);
  color: var(--black);
  border-color: var(--gold);
}

.leaf {
  width: 100%;
  margin: 12px 0;
  border: 2px solid var(--gold);
  border-radius: 22px;
  background: var(--cream);
  color: var(--black);
  padding: 16px;
  text-align: left;
}

.leaf img {
  width: 92px;
  margin: 0 auto 8px;
}

.btn {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: var(--black);
  font-weight: 700;
  margin-top: 10px;
}

.btn.ghost {
  background: transparent;
  color: var(--cream);
  border: 2px solid var(--gold);
}

.btn.line {
  background: transparent;
  color: var(--black);
  border: 2px solid var(--red);
}

.row {
  display: flex;
  gap: 10px;
}

.row .btn { flex: 1; }

.warn { min-height: 1.6em; color: var(--gold); font-weight: 700; }

.top {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px 6px;
  color: var(--cream);
}

.top img { width: 46px; height: 46px; object-fit: contain; }

.top h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  color: var(--gold);
}

.top h1 b,
.day-badge {
  background: var(--gold);
  color: var(--black);
  border: 2px solid var(--black);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.top h1 b {
  margin-left: 6px;
  padding: 0 8px;
  vertical-align: 3px;
}

.top h1 b[hidden] { display: none !important; }

.top p { margin: 0; font-size: 13px; }

#view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0 10px;
  background: var(--cream);
  color: var(--black);
  border-radius: 22px 22px 12px 12px;
  padding: 12px;
}

#view.dark {
  background: var(--black) url("bg-disk.jpg") center/cover no-repeat;
  color: var(--cream);
  padding: 12px;
}

.block, .screen { display: flex; flex-direction: column; gap: 8px; }

.block-head, .screen-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.block-head img, .screen-head img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.eyebrow { margin: 0; color: var(--red); font-weight: 700; font-size: 13px; }

.card {
  border: 2px solid var(--gold);
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 4px 4px 0 var(--red);
  overflow: hidden;
}

.card-hit, .pin, .back, .choice, .tool, .board, .preset {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.card-hit { display: block; width: 100%; padding: 10px 12px 4px; }

.tag {
  display: inline-block;
  background: var(--red);
  color: var(--cream);
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.7;
}

.card h3, .tape h3, .sheet h3 { margin: 4px 0; line-height: 1.45; }

.card p, .tape p, .sheet p { margin: 0 0 4px; }

.pin, .back {
  margin: 0 12px 10px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 4px 12px;
  min-height: 36px;
  font-weight: 700;
  color: var(--red);
}

.back { margin: 0 0 8px; color: inherit; width: auto; }

.tape {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  border: 2px solid var(--black);
  border-radius: 16px;
  padding: 8px;
  background: var(--cream);
}

.reels { display: flex; gap: 6px; }

.reel {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background:
    radial-gradient(circle at 50% 50%, var(--black) 0 5px, transparent 6px),
    conic-gradient(var(--red), var(--gold), var(--red), var(--gold), var(--red));
}

.shade {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.72);
  z-index: 6;
  display: grid;
  align-items: end;
  justify-items: center;
}

.sheet {
  width: min(100vw, 440px);
  background: var(--cream);
  color: var(--black);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px 24px;
  border-top: 4px solid var(--gold);
}

.sheet .pin { margin: 8px 0 0; }

.dock { flex: none; padding: 6px 0 calc(8px + env(safe-area-inset-bottom)); }

.ticker {
  position: relative;
  display: block;
  width: calc(100% - 28px);
  height: 36px;
  margin: 0 auto 6px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: var(--black);
  color: var(--gold);
  padding: 0;
}

.ticker-track {
  display: flex;
  width: max-content;
  animation: run 14s linear infinite;
  line-height: 34px;
  font-weight: 700;
}

.ticker.paused .ticker-track { animation-play-state: paused; }

.ticker-flag {
  position: absolute;
  right: 8px;
  top: 5px;
  background: var(--gold);
  color: var(--black);
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
  line-height: 1.4;
  padding: 2px 8px;
  font-weight: 700;
}

.ticker-flag:empty { display: none; }

@keyframes run {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.wheel {
  width: min(58vw, 236px);
  margin: 0 auto;
  position: relative;
  aspect-ratio: 1;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.45));
}

.dial { width: 100%; height: 100%; display: block; }

.dial text {
  pointer-events: none;
  font-family: var(--font);
}

.dial path { cursor: pointer; }

.hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 32%;
  height: 32%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--black);
  color: var(--gold);
  display: grid;
  place-items: center;
  padding: 0;
  z-index: 2;
}

.hub img { width: 78%; height: 78%; object-fit: contain; }

.hub span {
  position: absolute;
  bottom: 6%;
  font-size: 11px;
  font-weight: 700;
  background: var(--black);
  line-height: 1.2;
  padding: 0 4px;
  border-radius: 8px;
}

.day-badge {
  position: absolute;
  left: 2%;
  top: 0;
  z-index: 3;
  padding: 0 7px;
}

.stage {
  position: relative;
  width: min(100%, 320px);
  aspect-ratio: 1;
  margin: 6px auto;
}

.rotor { position: absolute; inset: 0; }

#rotor { z-index: 1; }
#rotor img { width: 100%; height: 100%; object-fit: contain; }
#arm { z-index: 3; pointer-events: none; }

.pip {
  position: absolute;
  left: 50%;
  top: 7%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: var(--cream);
  border: 2px solid var(--black);
  box-shadow: 0 0 0 2px var(--gold);
}

.window {
  position: absolute;
  z-index: 2;
  top: 4%;
  left: 50%;
  transform: translateX(-50%);
  width: 46%;
  height: 24%;
  border-radius: 14px 14px 28px 28px;
  border: 3px solid var(--gold);
  background: rgba(17, 17, 17, 0.45);
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  padding: 0;
}

.window.hot {
  background: var(--gold);
  color: var(--black);
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.hud span, .finish p {
  background: rgba(17, 17, 17, 0.72);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 4px 8px;
}

.note { min-height: 1.7em; font-weight: 700; color: var(--gold); margin: 4px 0; }

.finish { margin-top: 8px; }

.slots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.slot {
  background: var(--black);
  color: var(--cream);
  border-radius: 12px;
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--gold);
}

.slot.on { background: var(--gold); color: var(--black); }

.strikes { display: flex; gap: 6px; align-items: center; }

.strikes i, .pips i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid var(--red);
  background: transparent;
}

.strikes i.bad { background: var(--red); }
.pips { display: flex; gap: 8px; }
.pips i.on { background: var(--gold); border-color: var(--gold); }

.choice, .board, .tool, .preset {
  width: 100%;
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 8px 10px;
  background: var(--cream);
  font-weight: 600;
}

.choice.good { background: var(--gold); }
.choice.bad { background: var(--red); color: var(--cream); }

.tools, .boards, .choices, .presets { display: flex; flex-direction: column; gap: 8px; }

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: 12px;
}

.week b {
  display: grid;
  place-items: center;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--gold);
}

.week b.on { background: var(--gold); }

.heat {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  align-items: end;
  background: var(--black);
  color: var(--cream);
  border-radius: 16px;
  padding: 10px 6px;
}

.stack {
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
}

.stack i { display: block; border-radius: 4px; min-height: 4px; }
.stack i.meas { background: var(--gold); }
.stack i.tape { background: var(--red); }
.stack i.quiz { background: var(--cream); }
.stack i.day { background: repeating-linear-gradient(135deg, var(--gold) 0 3px, var(--black) 3px 6px); }

.heat span { display: block; text-align: center; font-size: 11px; line-height: 1.3; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; }
.legend .meas { background: var(--gold); }
.legend .tape { background: var(--red); }
.legend .quiz { background: var(--cream); box-shadow: inset 0 0 0 1px var(--black); }
.legend .day { background: var(--black); box-shadow: inset 0 0 0 2px var(--gold); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--red); color: var(--cream); padding: 6px; }
td { text-align: center; padding: 5px; border-bottom: 1px solid var(--gold); }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; }

input, select, textarea {
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: var(--cream);
  color: var(--black);
  padding: 8px;
  width: 100%;
}

.set {
  border: 2px solid var(--red);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.demo { margin: 0; color: var(--red); font-weight: 700; }

#view.dark .demo, #view.dark .note { color: var(--gold); }

.phone.is-game .dock { display: none; }
