:root {
  --ink: #1a1218;
  --bone: #c4b49a;
  --gold: #f3e2a4;
  --grave: #6e8f78;
  --linen: #efe6d6;
  color-scheme: dark;
}
* { box-sizing: border-box; }
@font-face {
  font-family: "Press Start 2P";
  src: url("./assets/fonts/PressStart2P-Regular.ttf") format("truetype");
  font-display: swap;
}
html, body {
  margin: 0; height: 100%; background: var(--ink); color: var(--linen);
  font-family: "Press Start 2P", Georgia, serif;
  font-size: 8px;
  line-height: 1.8;
}
button, input { font: inherit; color: inherit; }
#app { display: grid; grid-template-columns: 1fr 320px; height: 100%; }
#stage { position: relative; min-height: 0; }
#well, #rises { width: 100%; height: 100%; display: block; }
#well { touch-action: none; }
#rises { position: absolute; inset: 0; pointer-events: none; }
#toast {
  position: absolute; left: 16px; bottom: 16px; margin: 0;
  color: var(--gold); letter-spacing: 0.04em; text-shadow: 0 1px 2px #000;
}
#side {
  background: #120d12; border-left: 1px solid #3a2c32; padding: 10px 12px;
  overflow-x: hidden; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  height: 100%; min-height: 0;
}
#crown { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
#side h1 { font-size: 16px; margin: 0; color: var(--bone); font-weight: normal; line-height: 1.6; }
#round, #mission { margin: 0; color: var(--gold); line-height: 1.8; overflow-wrap: break-word; }
#side header { display: flex; align-items: center; gap: 8px; row-gap: 4px; flex-wrap: wrap; }
#ver, #ver2 { opacity: 0.7; margin: 0; }
#mute { margin-left: auto; background: transparent; border: 1px solid var(--bone); padding: 2px 8px; }
#stats, #bank { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 0; }
#stats div, #bank div { display: flex; justify-content: space-between; border-bottom: 1px solid #3a2c32; }
dt { opacity: 0.7; } dd { margin: 0; color: var(--gold); }
#words {
  flex: 0 0 auto; height: 5.4em; margin: 0; padding: 4px 6px;
  color: var(--gold); line-height: 1.8; white-space: pre-wrap;
  overflow-x: hidden; overflow-y: auto;
  background: #0c090c; border: 1px solid #3a2c32;
}
#next-slot, #shaft-slot { position: relative; background: #0c090c; border: 1px solid #3a2c32; min-height: 0; }
#next-slot { flex: 0 0 72px; height: 72px; }
#shaft-slot { flex: 1 1 180px; min-height: 160px; overflow: auto; }
#next { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#shaft { display: block; width: 100%; cursor: pointer; }
#side-low {
  flex: 1 1 96px; min-height: 72px; max-height: 38%;
  overflow-x: hidden; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
#help { font-size: 8px; line-height: 1.8; opacity: 0.8; margin: 0; max-height: 5.4em; overflow: auto; }
#build { border: 1px solid var(--grave); padding: 8px; }
#build p { margin: 0 0 6px; overflow-wrap: break-word; }
#landingline, #shopnote {
  min-height: 1.8em; color: var(--gold); margin: 4px 0 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#landingline { white-space: normal; overflow: visible; line-height: 1.65; }
#landings { display: flex; flex-wrap: wrap; gap: 4px; }
#landings button { width: 28px; padding: 4px 0; text-align: center; }
#build .buys { display: flex; flex-direction: column; gap: 4px; }
#build button, #deck button, #end button, #pause button {
  background: #2a201f; border: 1px solid var(--bone); padding: 6px 8px; cursor: pointer;
}
#build .buys button { width: 100%; text-align: left; white-space: nowrap; }
#build button:disabled { cursor: default; }
.hidden { display: none !important; }
#deck, #pause, #end {
  position: fixed; inset: 0; background: rgba(12, 8, 10, 0.97);
  display: grid; place-items: center; padding: 24px; z-index: 3;
}
#deck { padding-bottom: 80px; }
.card {
  display: none; max-width: 38rem;
  max-height: calc(100vh - 104px); max-height: calc(100dvh - 104px);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  padding-right: 10px;
}
#pause > div, #end > div {
  max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding-right: 10px;
}
.card, .hall-window, #pause > div, #end > div, #side, #side-low, #words, #shaft-slot, #help {
  scrollbar-color: var(--bone) #0c090c; scrollbar-width: thin;
}
#hall-note { color: var(--gold); margin: 8px 0 6px; min-height: 1.8em; }
.card.on { display: block; }
.card.demo { max-width: min(920px, 96vw); }
.demo-view { width: 100%; height: auto; display: block; background: #100c10; border: 1px solid #3a2c32; }
.demojump { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#title-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.demojump button[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); }
.card h2 { font-weight: normal; color: var(--bone); font-size: 16px; margin-bottom: 0.8rem; line-height: 1.6; }
.lead { font-size: 10px; line-height: 1.8; }
#rimchoice { display: flex; gap: 8px; margin: 10px 0 6px; }
#rimchoice button[aria-pressed="true"] { background: #3a2a22; color: var(--gold); }
#rimnote, #rimstat { font-size: 8px; line-height: 1.7; color: var(--gold); }
#ladder { margin: 0; color: var(--gold); overflow-wrap: break-word; }
#shortnote { margin: 0; font-size: 8px; opacity: 0.8; }
#mark {
  display: flex; justify-content: center; align-items: flex-end; flex-wrap: nowrap;
  height: 36px; margin: 8px 0 2px; overflow: hidden;
}
#mark span {
  position: relative; display: block; flex: 0 0 auto; height: 10px;
  min-width: 0.55em; text-align: center; font-size: 8px; line-height: 10px;
}
.credit { opacity: 0.85; margin: 0.2rem 0; }
#end-actions, #pause-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
#pauseScore { color: var(--gold); margin: 8px 0; }
#carve { margin: 8px 0 0; }
#carve p { margin: 0 0 8px; color: var(--gold); max-width: 28rem; }
#initials {
  width: 7em; background: #0c090c; border: 1px solid var(--bone);
  padding: 6px 8px; letter-spacing: 0.28em; text-transform: uppercase;
}
.card.hall { max-width: min(28rem, 96vw); }
.hall-window {
  height: 13.2em; margin-top: 8px; overflow-x: hidden; overflow-y: auto;
  background: #0c090c; border: 1px solid #3a2c32;
  scrollbar-color: var(--bone) #0c090c;
}
#hall-roll, #hall-clone { list-style: none; margin: 0; padding: 0; }
#hall-roll li, #hall-clone li {
  display: grid; grid-template-columns: 2.6em 4.6em 1fr; gap: 8px;
  height: 2.2em; align-items: center; padding: 0 8px; color: var(--gold);
  white-space: nowrap;
}
#hall-roll .hall-empty, #hall-clone .hall-empty { opacity: 0.45; }
.hall-score { text-align: right; }
@media (prefers-reduced-motion: reduce) {
  .hall-clone { display: none; }
}
#deck nav { position: absolute; bottom: 18px; display: flex; gap: 12px; }
#deck nav button { width: 44px; height: 44px; font-size: 16px; }
#lines { font-size: 8px; white-space: pre-wrap; opacity: 0.85; line-height: 1.8; }
@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 40vh minmax(0, 1fr); height: 100%; min-height: 100%; }
  #stage { height: 40vh; }
  #side { border-left: 0; border-top: 1px solid #3a2c32; }
  #words { height: 3.6em; }
  #next-slot { flex-basis: 58px; height: 58px; }
  #shaft-slot { flex: 1 1 120px; min-height: 108px; }
  #side-low { flex: 0 0 124px; max-height: 124px; min-height: 96px; }
}
