:root {
  --ink: #140a14;
  --panel: rgba(30, 15, 28, .92);
  --panel-solid: #1d1020;
  --brass: #d4829a;
  --brass-hi: #f7c6d2;
  --brass-dim: #7d3654;
  --text: #f6e6ea;
  --muted: #c2a3ae;
  --faint: #87707a;
  --parchment: #fbeef1;
  --parchment-ink: #2c1220;
  --good: #9ad68f;
  --bad: #ff8a78;
  --soft: #98c6ff;
  --ember: #ffb35c;
  --display: "Cormorant Garamond", "Georgia", serif;
  --body: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
  --ledgerw: 300px;
  --mindw: 300px;
  --bottom: 0px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); font-family: var(--body); font-size: 15px; }
body { overflow: hidden; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.4; margin: 6px 0; }
#stage { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: absolute; left: 0; right: 0; top: 0; height: 60px; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: linear-gradient(#2b1428, #1c0e1b); border-bottom: 2px solid var(--brass-dim); box-shadow: 0 1px 0 rgba(247, 198, 210, .25), 0 6px 20px rgba(0, 0, 0, .35);
}
.brand { min-width: 0; flex: 1 1 260px; }
.brand h1 { font-family: var(--display); font-weight: 700; font-size: 30px; line-height: .9; margin: 0; color: var(--brass-hi); letter-spacing: .03em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.season { color: var(--muted); font-size: 14px; white-space: nowrap; }
.season b { color: var(--text); font-weight: 700; }
.purse { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.purse span { color: var(--muted); font-size: 12px; }
.purse b { font-family: var(--display); font-size: 26px; color: var(--brass-hi); font-variant-numeric: tabular-nums; }
.controls { display: flex; gap: 8px; align-items: center; }
.seg { display: flex; border-radius: 999px; overflow: hidden; border: 1px solid var(--brass-dim); background: rgba(255, 255, 255, .03); }
.seg button { background: transparent; border: 0; padding: 6px 14px; cursor: pointer; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: linear-gradient(#f0a9bb, #d4829a); color: #2c1220; font-weight: 800; }
.select select { max-width: 168px; }
#mindToggle { white-space: nowrap; }
.select select, #mindToggle, #btnPause {
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(212, 130, 154, .55); border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--text);
}
.select select option { background: var(--panel-solid); }
#mindToggle[aria-pressed="true"] { border-color: var(--brass-hi); color: var(--brass-hi); background: rgba(247, 198, 210, .1); }
.select { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; }

/* ------------------------------------------------------------ the guild ledger */
#ledger {
  position: absolute; left: 0; top: 60px; bottom: 0; width: var(--ledgerw); z-index: 5; overflow-y: auto; padding: 12px 14px 16px;
  background: linear-gradient(90deg, rgba(34, 17, 32, .97), rgba(27, 13, 25, .95)); border-right: 1px solid var(--brass-dim);
  box-shadow: inset -1px 0 0 rgba(247, 198, 210, .15), 4px 0 18px rgba(0, 0, 0, .3);
}
#ledger h2 { font-family: var(--display); font-size: 21px; margin: 0 0 8px; color: var(--brass-hi); }
#ledger h3 { font-family: var(--display); font-size: 17px; margin: 14px 0 6px; color: var(--parchment); border-bottom: 1px solid rgba(212, 130, 154, .25); padding-bottom: 3px; }
#ledger h3 small { font-family: var(--body); font-size: 12px; color: var(--muted); }
#prices { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
#prices th { font-weight: 600; color: var(--muted); font-size: 11.5px; text-align: center; padding: 2px; }
#prices tr th:first-child { text-align: left; color: var(--text); font-size: 12.5px; white-space: nowrap; }
#prices td { text-align: center; padding: 2px 1px; color: var(--text); border-radius: 4px; }
#prices th.here { color: var(--brass-hi); }
#prices td.here { outline: 1px solid rgba(247, 198, 210, .55); background: rgba(247, 198, 210, .08); font-weight: 800; }
#prices td.cheap, .hint .cheap { color: var(--good); }
#prices td.dear, .hint .dear { color: var(--ember); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two h3 { font-size: 15px !important; }
ul.goods { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
ul.goods li { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; padding: 2px 0; }
ul.goods li small { flex-basis: 100%; color: var(--faint); font-size: 11px; padding-left: 37px; margin-top: -3px; }
ul.goods li.empty { color: var(--faint); font-style: italic; }
.tier { font-size: 10.5px; padding: 0 6px; border-radius: 99px; font-weight: 700; }
.tier[data-t="2"] { background: rgba(154, 214, 143, .2); color: var(--good); }
.tier[data-t="1"] { background: rgba(247, 198, 210, .16); color: var(--brass-hi); }
.tier[data-t="0"] { background: rgba(255, 138, 120, .16); color: var(--bad); }
.tier[data-t="-1"] { background: rgba(255, 255, 255, .08); color: var(--muted); }
#gossip { list-style: none; margin: 0; padding: 0; font-size: 13px; }
#gossip li { display: flex; justify-content: space-between; padding: 3px 4px; border-radius: 6px; }
#gossip li.here { background: rgba(247, 198, 210, .08); }
#gossip .chips { display: flex; gap: 4px; }
#gossip .chips b { font-size: 11.5px; padding: 0 6px; border-radius: 99px; font-weight: 700; }
#gossip .chips em { color: var(--faint); font-size: 12px; }
b.bad { background: rgba(255, 138, 120, .18); color: var(--bad); }
b.good { background: rgba(154, 214, 143, .18); color: var(--good); }
b.soft { background: rgba(152, 198, 255, .16); color: var(--soft); }
b.pend { background: rgba(255, 255, 255, .08); color: var(--parchment); }
#log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
#log li { font-size: 12.5px; line-height: 1.35; color: var(--muted); padding: 3px 7px; border-left: 2px solid var(--brass-dim); }
#log li[data-side="T"] { border-left-color: var(--ember); }
#log li[data-side="M"] { border-left-color: var(--soft); }
#log li b { color: var(--text); font-weight: 700; }
#log li q { display: block; color: var(--parchment); font-style: italic; margin-top: 1px; }
#log li q::before { content: "“"; } #log li q::after { content: "”"; }
.bad { color: var(--bad); } .gold { color: var(--brass-hi); }

/* ------------------------------------------------------------ the brains' read */
#mind {
  position: absolute; right: 0; top: 60px; bottom: var(--bottom); width: var(--mindw); z-index: 5; overflow-y: auto; padding: 12px 14px;
  background: linear-gradient(270deg, rgba(34, 17, 32, .96), rgba(27, 13, 25, .93)); border-left: 1px solid var(--brass-dim);
}
#mind h2 { font-family: var(--display); font-size: 18px; margin: 0 0 4px; color: var(--brass-hi); }
#mind h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 0 5px; }
#mind section { padding-bottom: 12px; margin-bottom: 10px; border-bottom: 1px solid rgba(212, 130, 154, .2); }
#mind .big { font-size: 15px; margin: 6px 0; }
#mind .big b { color: var(--brass-hi); font-size: 19px; font-family: var(--display); }
.truth { color: var(--muted); font-size: 12.5px; }
.bars2 { display: flex; flex-direction: column; gap: 3px; }
.mrow { display: grid; grid-template-columns: 70px 1fr 42px; align-items: center; gap: 6px; font-size: 12.5px; }
.bar { position: relative; height: 9px; background: rgba(255, 255, 255, .08); border-radius: 5px; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--brass), var(--brass-hi)); border-radius: 5px; }
.bar.diverge i { background: var(--good); border-radius: 0; }
.bar.diverge i.neg { background: var(--bad); }
.bar.diverge::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .3); }
.bar s { position: absolute; top: -1px; bottom: -1px; width: 2px; background: #fff; box-shadow: 0 0 4px #fff; }
.pct { color: var(--muted); font-size: 11.5px; text-align: right; }
.mindstats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 0; }
.mindstats dt { font-size: 11px; color: var(--muted); }
.mindstats dd { margin: 0; font-size: 13px; }
.considered { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text); }
.considered li span { color: var(--brass-hi); float: right; }
ul.mem { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--parchment); }
ul.mem li { margin: 2px 0; }

/* ------------------------------------------------------------ the composers */
#composer, #mcomposer, #watchbar {
  position: absolute; left: var(--ledgerw); right: 0; bottom: 0; z-index: 6; padding: 10px 16px 12px;
  background: linear-gradient(rgba(30, 15, 28, .94), rgba(22, 10, 20, .98)); border-top: 1px solid var(--brass-dim);
  box-shadow: 0 -6px 22px rgba(0, 0, 0, .35); display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: flex-start;
}
.mind-open #composer, .mind-open #mcomposer, .mind-open #watchbar { right: var(--mindw); }
#composer.waiting, #mcomposer.waiting { opacity: .55; pointer-events: none; }
.group h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 5px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; max-width: 520px; }
.chip {
  display: inline-flex; align-items: center; background: rgba(255, 255, 255, .05); border: 1px solid rgba(212, 130, 154, .4); border-radius: 999px;
  padding: 4px 11px; cursor: pointer; font-size: 13px; color: var(--text); transition: background .12s, border-color .12s;
}
.chip:hover:not(:disabled) { border-color: var(--brass-hi); background: rgba(247, 198, 210, .08); }
.chip[aria-checked="true"] { background: linear-gradient(#f0a9bb, #d4829a); border-color: var(--brass-hi); color: #2c1220; font-weight: 800; }
.chip:disabled { opacity: .3; cursor: default; }
.chip.price { min-width: 38px; justify-content: center; font-variant-numeric: tabular-nums; }
.go { flex: 1 1 260px; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
.go p { margin: 0; font-size: 13.5px; line-height: 1.4; }
#preview, #mPreview { color: var(--parchment); }
.primary {
  align-self: flex-start; margin-top: 4px; background: linear-gradient(#f2b3c3, #d4829a); color: #2c1220; border: 1px solid var(--brass-hi);
  border-radius: 999px; padding: 8px 22px; font-weight: 800; cursor: pointer; box-shadow: 0 2px 12px rgba(212, 130, 154, .35);
}
.primary:disabled { opacity: .4; cursor: default; box-shadow: none; }
.primary.alt { background: linear-gradient(#b65a3c, #8e3c28); color: #fff2f5; border-color: #e08b6a; }
#secrets { flex-basis: 100%; margin: 0 0 2px; font-size: 13.5px; color: var(--parchment); background: rgba(152, 198, 255, .07); border: 1px solid rgba(152, 198, 255, .25); border-radius: 10px; padding: 6px 10px; }
#secrets b { color: var(--brass-hi); }
#watchbar { align-items: center; }

/* the simple composer: three cards, each a whole move; Advanced shows the chips instead */
#stage.simple #composer .group, #stage.simple #composer .go, #stage.simple #mcomposer .group, #stage.simple #mcomposer .go { display: none; }
#stage:not(.simple) .cards { display: none; }
#composer, #mcomposer { padding-right: 112px; }
.advtoggle {
  position: absolute; top: 10px; right: 14px; font-size: 12px; padding: 4px 11px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid rgba(212, 130, 154, .45); color: var(--muted);
}
.advtoggle:hover { color: var(--brass-hi); border-color: var(--brass-hi); }
#composer.waiting .advtoggle, #mcomposer.waiting .advtoggle { pointer-events: auto; }   /* switch any time, not only on your turn */
.advtoggle[aria-pressed="true"] { color: #2c1220; background: linear-gradient(#f0a9bb, #d4829a); border-color: var(--brass-hi); font-weight: 800; }
.cards { flex: 1 1 100%; display: flex; gap: 10px; align-items: stretch; min-height: 112px; }
.card {
  position: relative; flex: 1 1 0; max-width: 330px; min-width: 0; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
  padding: 9px 12px 10px 38px; border-radius: 12px; border: 1px solid rgba(212, 130, 154, .5); color: var(--text);
  background: linear-gradient(rgba(251, 238, 241, .07), rgba(251, 238, 241, .02)); box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  transition: transform .12s, border-color .12s, background .12s;
}
.card:hover:not(:disabled), .card:focus-visible { transform: translateY(-2px); border-color: var(--brass-hi); background: linear-gradient(rgba(247, 198, 210, .14), rgba(247, 198, 210, .04)); }
.card .key { position: absolute; left: 10px; top: 10px; width: 19px; height: 19px; border-radius: 6px; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; color: #2c1220; background: var(--brass); }
.card .title { font-family: var(--display); font-size: 19px; font-weight: 700; line-height: 1.1; color: var(--parchment); padding-right: 48px; }
.card .big { position: absolute; right: 12px; top: 8px; font-family: var(--display); font-size: 24px; font-weight: 700; color: var(--brass-hi); font-variant-numeric: tabular-nums; }
.card .line { font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.card .stake { margin-top: auto; font-size: 12px; font-weight: 700; color: var(--soft); }
.card[data-kind="good"] .stake { color: var(--good); }
.card[data-kind="risky"] { border-color: rgba(255, 138, 120, .5); }
.card[data-kind="risky"] .stake { color: var(--bad); }
.card[data-kind="end"] .title { color: var(--ember); }
.card .odds { font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--faint); }
.card.pick { border-color: var(--brass); box-shadow: 0 2px 14px rgba(212, 130, 154, .22); }
.card.pick .odds { color: var(--brass-hi); }
.card[data-kind="more"] { justify-content: center; border-style: dashed; }
.card[data-kind="more"] .title { color: var(--brass-hi); }
.card[data-kind="more"][aria-expanded="true"] { background: rgba(247, 198, 210, .12); border-style: solid; }
.morepanel {
  position: absolute; left: 0; right: 0; bottom: 100%; max-height: min(56vh, 520px); overflow-y: auto; z-index: 7; padding: 10px 16px 12px;
  background: linear-gradient(rgba(25, 12, 23, .97), rgba(30, 15, 28, .98)); border-top: 1px solid var(--brass-dim); box-shadow: 0 -10px 30px rgba(0, 0, 0, .45);
}
.morehead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.morehead b { font-family: var(--display); font-size: 19px; color: var(--parchment); }
.morehead span { font-size: 12px; color: var(--muted); }
.moregrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.card.compact { max-width: none; padding: 7px 10px 8px 34px; }
.card.compact .title { font-size: 16.5px; }
.card.compact .big { font-size: 20px; top: 6px; }
.card.compact .key { top: 8px; left: 9px; }
#troubleAdvice { margin: 4px 0 0; font-size: 13.5px; color: var(--brass-hi); font-weight: 700; }
.cards .back { align-self: center; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px; }
.cards .back:hover { color: var(--brass-hi); }
.cards .wait { align-self: center; margin: 0; color: var(--faint); font-size: 13.5px; font-style: italic; }

/* ------------------------------------------------------------ speech, pops, labels */
.bubble {
  position: absolute; z-index: 4; transform: translate(-50%, calc(-100% - 6px)); max-width: min(330px, 34vw); min-width: 120px;
  background: var(--parchment); color: var(--parchment-ink); border-radius: 14px; padding: 9px 13px 8px; box-shadow: 0 6px 22px rgba(0, 0, 0, .45);
  border: 1px solid #e6c2cc; font-size: 15px; line-height: 1.35; pointer-events: none;
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 14px; height: 14px; background: var(--parchment); border-right: 1px solid #e6c2cc; border-bottom: 1px solid #e6c2cc; transform: translateX(-50%) rotate(45deg); }
.bubble[data-side="T"] { transform: translate(-30%, calc(-100% - 6px)); }
.bubble[data-side="M"] { transform: translate(-75%, calc(-100% - 6px)); }
.bubble[data-side="M"]::after { left: 75%; }
.bubble[data-side="T"]::after { left: 30%; }
.bubble p { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 600; line-height: 1.22; }
.bubble .terms { display: block; margin-top: 5px; font-size: 11.5px; color: #6e4a5a; border-top: 1px dashed #d9b2bd; padding-top: 4px; }
.bubble .terms b { color: #2c1220; }
.bubble .terms .bad { color: #b0362a; font-weight: 700; } .bubble .terms .gold { color: #8a2f55; font-weight: 700; }
.bubble.thinking p { color: #94707e; letter-spacing: .2em; }
.pop {
  position: absolute; z-index: 4; transform: translate(-50%, -50%); pointer-events: none; font-family: var(--display); font-weight: 700; font-size: 22px;
  color: var(--brass-hi); text-shadow: 0 2px 8px rgba(0, 0, 0, .8); animation: rise 2.2s ease-out forwards; white-space: nowrap;
}
.pop.offer { font-size: 26px; }
.pop.turn { color: var(--soft); }
.pop.soft { color: var(--soft); font-size: 17px; }
.pop.bad { color: var(--bad); }
.pop.sale { color: #ffd6e0; font-size: 26px; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 12% { opacity: 1; transform: translate(-50%, -60%) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -190%); } }
#maplabels { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.maplabel { position: absolute; transform: translate(-50%, 6px); text-align: center; white-space: nowrap; }
.maplabel b { font-family: var(--display); font-size: 17px; color: var(--parchment); text-shadow: 0 1px 2px #000, 0 0 10px rgba(0, 0, 0, .8); letter-spacing: .03em; }
.maplabel.caravan { transform: translate(-50%, -100%); font-size: 12px; color: var(--brass-hi); text-shadow: 0 1px 3px #000; font-weight: 700; }
#stage[data-view="map"] .bubble { display: none; }
#banner { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; opacity: 0; z-index: 4; }
#banner h2 { font-family: var(--display); font-size: 64px; margin: 0; color: var(--parchment); text-shadow: 0 3px 20px rgba(0, 0, 0, .7), 0 0 40px rgba(255, 190, 110, .35); letter-spacing: .05em; }
#banner p { margin: 0; font-family: var(--display); font-style: italic; font-size: 24px; color: var(--brass-hi); text-shadow: 0 2px 10px rgba(0, 0, 0, .8); }
#banner.show { animation: banner 3.4s ease-in-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -40%); } 18% { opacity: 1; transform: translate(-50%, -50%); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -56%); } }

/* ------------------------------------------------------------ cards */
#trouble, #toast, #result {
  position: absolute; left: 50%; z-index: 8; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--brass); border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(247, 198, 210, .2); padding: 16px 20px; color: var(--text);
}
#trouble { top: 18%; width: min(520px, 90vw); text-align: center; }
#trouble h2, #result h2, #toast h2 { font-family: var(--display); color: var(--brass-hi); font-size: 28px; margin: 0 0 4px; }
#trouble .choices { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
#trouble .choices .primary { align-self: auto; font-size: 13.5px; max-width: 230px; line-height: 1.25; padding: 9px 14px; }
#trouble.ai .choices button { pointer-events: none; }
#trouble .primary.chosen { outline: 3px solid #fff; transform: scale(1.04); }
#toast { top: 76px; min-width: 260px; max-width: 520px; padding: 10px 16px; text-align: center; }
#toast h2 { font-size: 22px; }
#toast p { margin: 0; font-size: 14px; }
#result { top: 14%; width: min(560px, 92vw); }
#result ul { padding-left: 18px; margin: 8px 0 12px; font-size: 14px; }
#result li { margin: 4px 0; } #result li small { color: var(--muted); }
#error { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); background: #3a1414; border: 1px solid var(--bad); padding: 12px 16px; border-radius: 10px; z-index: 20; max-width: 80vw; }
#soundHint { position: absolute; left: 50%; bottom: calc(var(--bottom) + 12px); transform: translateX(-50%); background: var(--panel); border: 1px solid var(--brass-dim); border-radius: 999px; padding: 6px 14px; z-index: 9; font-size: 13px; }


#watchbar .select select { max-width: 330px; }
/* ------------------------------------------------------------ narrow screens
   phones (portrait, or landscape with little height): one column. The scene, then your move
   right under it, then the ledger and the brains' read. */
@media (max-width: 760px), (max-height: 500px) {
  body { overflow: auto; }
  #stage { position: static; display: flex; flex-direction: column; }
  .topbar { order: 0; position: sticky; top: 0; height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  #view { order: 1; position: relative; height: min(58vw, 72vh); flex: none; }
  #composer, #mcomposer, #watchbar { order: 2; position: relative; left: auto; right: auto; bottom: auto; width: auto; }
  #ledger { order: 3; }
  #mind { order: 4; }
  #ledger, #mind { position: static; width: auto; }
  .mind-open #composer, .mind-open #mcomposer, .mind-open #watchbar { right: auto; }
  #composer, #mcomposer { padding: 40px 12px 12px; }
  .cards { flex-direction: column; min-height: 0; }
  .card { max-width: none; }
  .advtoggle { top: 9px; right: 12px; }
  .topbar .controls { flex-wrap: wrap; width: 100%; margin-left: 0; gap: 6px; }
  .topbar .controls .select, .topbar .controls select { min-width: 0; max-width: 100%; }
  .topbar .controls .select { flex: 1 1 140px; }
  .topbar .controls select { width: 100%; }
  .topbar .seg { flex: 1 1 100%; display: flex; }
  .topbar .seg button { flex: 1; }
  #mindToggle { flex: 1 1 120px; }
  .morepanel { position: static; max-height: none; margin: 0 -12px 8px; border-top: 0; box-shadow: none; padding: 4px 12px 10px; }
  .moregrid { grid-template-columns: 1fr; }
  .bubble { max-width: 60vw; }
  #banner h2 { font-size: 34px; }
}
/* phones held sideways: wide but short, so the cards sit side by side and the top bar scrolls away */
@media (max-height: 500px) and (min-width: 600px) {
  .topbar { position: static; }
  .cards { flex-direction: row; }
  .moregrid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* Velvet After Hours — phone and booking-desk styling. */
:root {
  --ink: #0f1424; --panel: rgba(20, 27, 44, .95); --panel-solid: #151d30;
  --brass: #cb83b4; --brass-hi: #ffcee8; --brass-dim: #655075;
  --text: #f2edf6; --muted: #b5b8d0; --faint: #858ba9;
  --parchment: #f3eef7; --parchment-ink: #242640;
  --display: "Nunito Sans", system-ui, sans-serif;
}
.topbar { background: linear-gradient(110deg,#23233e,#111b2f); border-bottom: 1px solid #7b5985; }
.brand h1 { font-size: 23px; letter-spacing: -.025em; }
#ledger, #mind { background: linear-gradient(180deg,rgba(29,33,55,.97),rgba(15,23,39,.97)); }
#ledger h2, #mind h2 { font-size: 20px; }
.story { margin: 12px 0 14px; padding: 12px; background: #242d45; border: 1px solid #4b4668; border-radius: 12px; }
.story summary { font-weight: 800; font-size: 12px; color: #f8c6e2; cursor: pointer; }
.story summary span { float: right; color: #96d9df; }
.story p { font-size: 12px; line-height: 1.5; color: #d5cee1; margin: 9px 0; }
.story small { display: block; font-size: 10.5px; line-height: 1.4; color: #aab9d0; }
.card { border-radius: 12px; }
.primary { border-radius: 9px; }
.bubble { border-radius: 14px; }
@media (max-width: 760px) { .brand h1 { font-size: 20px; } .story { margin: 8px 0; } }
#stage[data-mode="merchant"] .story,
#stage[data-mode="watch"] .story { display: none; }
@media (max-width: 760px) {
  .bubble { width: min(62vw, 270px); padding: 7px 10px; }
  .bubble p { font-size: 14px; line-height: 1.25; }
  .bubble .terms { font-size: 10px; }
}

/* Cinematic interludes take over the scene while the game waits for travel. */
.travelling #ledger, .travelling #mind, .travelling #composer,
.travelling #mcomposer, .travelling #watchbar, .travelling #maplabels { display: none !important; }
#journey { position: absolute; z-index: 6; bottom: 14px; left: 5%; right: 5%; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 20px; border-top: 1px solid #9682b7; background: linear-gradient(100deg,rgba(17,23,41,.96),rgba(29,26,49,.9)); border-radius: 0 0 14px 14px; }
#journeyChapter { color: #9ddde4; font-size: 10px; font-weight: 800; letter-spacing: .2em; }
#journeyTitle { margin: 5px 0; color: #ffe1ee; font-size: clamp(18px,2.2vw,30px); letter-spacing: -.035em; }
#journeySubtitle { margin: 0; color: #c2bfd6; font-size: 12px; }
.journey-controls { min-width: 160px; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
#journeyProgress { appearance: none; width: 100%; height: 3px; border: none; background: #44435c; border-radius: 3px; }
#journeyProgress::-webkit-progress-bar { background: #44435c; }
#journeyProgress::-webkit-progress-value { background: linear-gradient(90deg,#e499cd,#80d9e3); }
#journeyProgress::-moz-progress-bar { background: #80d9e3; }
#skipTravel { border: 1px solid #8d739e; padding: 8px 14px; border-radius: 999px; background: #2c2b47; cursor: pointer; color: #f3dced; font-size: 12px; }
#skipTravel:hover { background: #48405e; }
#skipTravel:disabled { opacity: .5; cursor: default; }
.travelling #toast { z-index: 8; }
@media (max-width:760px), (max-height:500px) {
  .travelling #view { height: min(85vw,70vh); }
  #journey { left: 0; right: 0; bottom: 0; padding: 9px 12px; gap: 8px; border-radius: 0; }
  #journeyTitle { font-size: 17px; }
  #journeySubtitle { display: none; }
  .journey-controls { min-width: 95px; max-width: 110px; gap: 6px; }
  #skipTravel { padding: 7px 9px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { #journey { transition: none; } }

#journeyFade { position: absolute; inset: 0; z-index: 5; background: #0b1020; opacity: 0; pointer-events: none; transition: opacity .12s linear; }
@media (prefers-reduced-motion: reduce) { #journeyFade { display: none; } }

/* Travel uses the viewport aspect ratio, including a full portrait composition. */
#travelVideo { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; display: block; pointer-events: none; object-fit: contain; background: #0a1020; }
#travelVideo[hidden] { display: none; }
.cinematic #journeyFade { display: none; }
.cinematic #journey { background: linear-gradient(0deg,rgba(8,15,26,.96),rgba(8,15,26,.4)); border: 0; }
@media (max-width: 760px), (max-height: 500px) {
  .cinematic #view { position: fixed; inset: 0; width: 100%; height: 100dvh; z-index: 20; }
  .cinematic #journey { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .cinematic #journeyTitle { font-size: 19px; }
  .cinematic #toast { z-index: 25; }
}

@media (max-width: 760px), (max-height: 500px) { .cinematic #travelVideo { object-fit: cover; } }

#learningPanel { margin: 12px 0; padding: 10px; border: 1px solid #586276; border-radius: 10px; font-size: 12px; }
#learningPanel label { display: block; margin: 10px 0; }
#learningPanel input { accent-color: #8dd6cf; }
#learningPanel button { padding: 7px 9px; margin: 3px 0; }
#ladderRows { overflow-wrap: anywhere; }
.run-objectives { border-top: 1px solid #586276; padding-top: 8px; }

/* A single game-styled entry leads to the trophy rankings screen. */
#learningPanel { border: 0; padding: 0; }
#learningPanel .ladder-launch { width: 100%; padding: 12px 18px; font-weight: 800; }
#learningPanel details { margin-top: 12px; color: var(--muted); }
#learningPanel summary { cursor: pointer; }
#learningPanel a { color: #efb2c7; text-underline-offset: 3px; }
#learningPanel .sharing-delete { display: block; margin-top: 14px; }
#ladderPage { box-sizing: border-box; width: min(760px, 100%); max-width: 100%; max-height: 100dvh; padding: 28px; color: var(--text); background: linear-gradient(145deg,#25233e,#101729 75%); border: 1px solid #8b617c; border-radius: 22px; overflow-y: auto; }
#ladderPage::backdrop { background: rgba(5,8,18,.85); backdrop-filter: blur(8px); }
.ladder-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ladder-header h2 { margin: 0; color: #f5b9ce; font-size: 32px; }
.ladder-eyebrow { letter-spacing: .15em; color: #c6a378; font-size: 10px; }
#closeLadder { background: #352c43; border: 1px solid #7e5b70; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; flex-shrink: 0; }
.ladder-filters { display: flex; gap: 12px; margin: 22px 0; }
.ladder-filters label { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }
.ladder-filters select { display: block; width: 100%; margin-top: 6px; background: #1c2035; border: 1px solid #8b617c; border-radius: 12px; padding: 10px; }
.trophy-podium { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: end; gap: 10px; margin: 30px 0; }
.trophy-card { padding: 20px 10px; text-align: center; border-radius: 16px 16px 6px 6px; border: 1px solid #9d7844; background: linear-gradient(#65503555,#31283d); overflow-wrap: anywhere; }
.trophy-icon { display: block; font-size: 48px; filter: drop-shadow(0 3px 14px #e8b45755); }
.trophy-place { font-size: 12px; font-weight: 800; color: #eac77e; }
.trophy-card h3 { font-size: 15px; }
.trophy-card p:last-child { font-size: 12px; color: var(--muted); }
.place-1 { padding-top: 38px; border-color: #ecc777; background: linear-gradient(#b3833e44,#34273d); }
.place-2 { border-color: #a7b3c6; }.place-2 .trophy-icon { filter: grayscale(1) drop-shadow(0 3px 14px #b0c4de44); }.place-2 .trophy-place { color: #c9d4e5; }
.place-3 { border-color: #a57653; }.place-3 .trophy-icon { filter: sepia(.8) saturate(.8); }.place-3 .trophy-place { color: #d5a580; }
.ladder-list { padding-left: 28px; }.ladder-list li { padding: 14px 8px; border-bottom: 1px solid #ffffff18; }.ladder-list li span { display: inline-block; width: 65%; overflow-wrap: anywhere; }.ladder-list strong { font-size: 13px; }
.ladder-empty { text-align: center; color: var(--muted); }
@media(max-width: 600px) { #ladderPage { width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; padding: 20px 14px; }.ladder-header h2 { font-size: 28px; }.trophy-icon { font-size: 36px; }.trophy-card { padding-left: 5px; padding-right: 5px; }.trophy-card h3 { font-size: 12px; }.trophy-place { font-size: 11px; }.ladder-list li span { width: 60%; } }
@media (max-width: 760px) {
  #view:has(#result:not([hidden])) { height: auto; min-height: min(58vw,72vh); padding: 20px 0; }
  #view #result:not([hidden]) { position: relative; top: auto; left: auto; transform: none; width: calc(100% - 28px); margin: 0 auto; }
}
.ladder-tabs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; margin-top: 22px; }
.ladder-tabs button { background: #25263d; border: 1px solid #79566e; border-radius: 10px; padding: 10px 4px; cursor: pointer; font-size: 12px; }
.ladder-tabs button[aria-selected="true"] { background: linear-gradient(#f0a9bb,#d4829a); color: #2c1220; font-weight: 800; }
.point-breakdown { display: block; color: #c5bacb; font-size: 11px; line-height: 1.6; margin-top: 8px; }
.championship-result { color: #eac77e; font-size: 20px; font-weight: 800; }
