/* Dispute Factory v1: app shell and in-run screen ("The stack"). Owned by PLAY. */
:root {
  --black: #000000; --sand: #F8F4EB; --orange: #FF8933; --tint: #FFA666;
  --shade: #C7BCA3; --coral: #F27C71; --gold: #FFED77; --lucite: #7ACBA7; --white: #FFFFFF;
  --px: 'Press Start 2P', monospace; --ss: 'Silkscreen', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--black); color: var(--sand); overflow: hidden; }
body { font-family: var(--ss); -webkit-text-size-adjust: 100%; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
button { font-family: inherit; cursor: pointer; margin: 0; color: var(--sand); background: var(--black); border: 2px solid var(--sand); border-radius: 0; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; color: var(--shade); border-color: #4a463e; opacity: .55; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }

/* the app box is the viewport minus safe areas; the stage is scaled to fit inside it */
#app { position: fixed; inset: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--black); }
#stage {
  position: absolute; left: 0; top: 0; width: 844px; height: 390px; transform-origin: 0 0;
  background: var(--black); color: var(--sand); overflow: hidden;
  display: grid; grid-template-columns: 124px minmax(0, 1fr) 130px; grid-template-rows: 390px;
}
#stage.dense { grid-template-columns: 100px minmax(0, 1fr) 110px; }
#stage.hide { visibility: hidden; }

.lbl { font-size: 10px; color: var(--shade); line-height: 1; }
.num { font-family: var(--px); font-weight: 400; font-size: 12px; line-height: 1; white-space: nowrap; }
.mut { color: var(--shade); }
.or { color: var(--orange); }
.co { color: var(--coral); }
.go { color: var(--gold); }
.lu { color: var(--lucite); }

/* ---------- left rail */
#lrail { padding: 12px 10px 10px 12px; display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; overflow: hidden; }
#stage.dense #lrail { padding: 10px 4px 10px 6px; gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#stage.dense .stat .num { font-size: 10px; }
.bar { display: block; height: 4px; background: #2a2823; position: relative; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; background: var(--sand); }
#h-cash.neg { color: var(--coral); }
#h-cash.up { color: var(--lucite); }
#h-cash.dn { color: var(--coral); }
.lbtns { margin-top: auto; display: grid; grid-template-columns: 46px 46px; gap: 8px; }
.lbtns .sm { height: 44px; }
#stage.dense .lbtns { grid-template-columns: 44px 44px; gap: 2px; }
.sq { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1.2; }
#stage.dense .sq { width: 44px; height: 44px; }
#stage.dense .sq.sm { height: 44px; }
.sq.sm { font-size: 9px; }
.lbtns .sq.wide, #stage.dense .lbtns .sq.wide { grid-column: 1 / -1; width: auto; }
.sq.on { background: var(--orange); border-color: var(--orange); color: var(--black); }
.pz { display: flex; gap: 5px; }
.pz i { width: 5px; height: 16px; background: currentColor; display: block; }
.pz.play i:first-child { width: 0; height: 0; background: none; border-left: 14px solid currentColor; border-top: 8px solid transparent; border-bottom: 8px solid transparent; }
.pz.play i:last-child { display: none; }

/* ---------- centre field */
#field { padding: 10px 4px 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; overflow: hidden; }
#ticker { height: 14px; display: flex; align-items: center; gap: 7px; font-size: 10px; white-space: nowrap; overflow: hidden; min-width: 0; }
#tk-dot { flex: 0 0 8px; height: 8px; background: var(--shade); }
#tk-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#ticker.bad #tk-dot { background: var(--coral); }
#ticker.good #tk-dot { background: var(--lucite); }
#ticker.warn #tk-dot, #ticker.hb #tk-dot { background: var(--gold); }
#ticker.event #tk-dot { background: var(--orange); }
#ticker.fresh #tk-text { animation: tkin .25s steps(4) both; }
@keyframes tkin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#wells { position: relative; flex: 1 1 auto; min-height: 0; }
#cv { position: absolute; left: 0; top: 0; width: 100%; height: 100%; image-rendering: pixelated; }
#hit { position: absolute; inset: 0; }
#hit > div { position: absolute; top: 0; cursor: pointer; }
#plus { position: absolute; inset: 0; pointer-events: none; }
#plus > button { position: absolute; bottom: 0; height: 44px; font-size: 16px; pointer-events: auto; font-family: var(--px); }
#plus > button.sel { background: var(--orange); border-color: var(--orange); color: var(--black); }
#plus > button.coach { animation: coach .9s linear infinite; }
@keyframes coach { 0%, 49% { background: var(--black); border-color: var(--sand); color: var(--sand); } 50%, 100% { background: var(--gold); border-color: var(--gold); color: var(--black); } }
#ticker.coach #tk-dot { background: var(--gold); animation: coach-dot .9s linear infinite; }
#ticker.coach #tk-text { color: var(--gold); }
@keyframes coach-dot { 0%, 49% { background: var(--gold); } 50%, 100% { background: transparent; } }
.warn { font-size: 9px; line-height: 1.3; color: var(--coral); min-height: 0; white-space: pre-line; }
.warn:empty { display: none; }
.warn.go { color: var(--gold); }
#plus > button.ext { font-size: 9px; font-family: var(--ss); line-height: 1.3; }

/* ---------- right rail */
#rrail { padding: 12px 12px 10px 8px; display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; overflow: hidden; }
#stage.dense #rrail { padding: 10px 8px 10px 4px; }
#next { border: 2px solid var(--sand); padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 0 1 auto; min-height: 0; overflow: hidden; }
#next-top { display: flex; justify-content: space-between; align-items: flex-start; }
#next-top { align-items: baseline; }
#next-when { font-size: 9px; }
#next-name { font-size: 10px; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
#next-tip { font-size: 9px; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
#stage.dense #next-tip { -webkit-line-clamp: 2; }
#stage.dense #next { padding: 6px; gap: 4px; }
#stage.dense #rrail { gap: 6px; }
#stage.dense .act { padding: 0 5px; gap: 1px 4px; }
#sel { margin-top: auto; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
#sel-name { font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
#sel-stats { display: grid; grid-template-columns: 1fr; gap: 2px; font-size: 9px; color: var(--shade); line-height: 1.2; }
#sel-stats span { white-space: nowrap; display: flex; justify-content: space-between; gap: 4px; min-width: 0; overflow: hidden; }
#sel-stats i { font-style: normal; }
#sel-stats b { font-weight: 400; color: var(--sand); }
#sel-stats b.co { color: var(--coral); }
#sel-stats b.go { color: var(--gold); }
#stage.dense #sel-stats { grid-template-columns: 1fr; gap: 2px; }
#stage.dense #sel-stats span { justify-content: space-between; }
#sel-stats.ext span:nth-child(n+3) { display: none; }
#sel-why { font-size: 9px; line-height: 1.35; color: var(--shade); min-height: 24px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
#sel-why.co { color: var(--coral); }
#sel-why.go { color: var(--gold); }
#sel-why.lu { color: var(--lucite); }
#sel-act { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.act { height: 44px; display: flex; flex-wrap: wrap; align-items: center; align-content: center; justify-content: space-between; gap: 3px 4px; padding: 0 6px; font-size: 10px; white-space: nowrap; text-align: left; }
.act { flex-wrap: nowrap; }
.act .pr { font-size: 9px; }
.act[hidden] { display: none; }
.act.wide { justify-content: center; padding: 0 16px; }
.act.flash { animation: actf .3s steps(2) 2; }
@keyframes actf { 50% { background: var(--orange); color: var(--black); border-color: var(--orange); } }

/* ---------- heat edge */
#edge { position: absolute; inset: 0; pointer-events: none; border: 0 solid var(--coral); }
#edge.h75 { border-width: 2px; }
#edge.h90 { border-width: 3px; animation: hot 1s steps(2) infinite; }
#edge.pulse { animation: pulse .9s steps(6) 2; }
@keyframes pulse { 0% { box-shadow: inset 0 0 0 0 var(--coral); } 50% { box-shadow: inset 0 0 0 6px var(--coral); } 100% { box-shadow: inset 0 0 0 0 var(--coral); } }
@keyframes hot { 50% { border-color: transparent; } }

/* ---------- rotate prompt */
#rotate { display: none; position: fixed; inset: 0; z-index: 50; background: var(--black); flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
#rotate small { font-size: 11px; color: var(--shade); }
#rotate .phone { width: 36px; height: 60px; border: 3px solid var(--sand); position: relative; animation: rot 2s steps(8) infinite; }
#rotate .phone::after { content: ''; position: absolute; left: 50%; bottom: 4px; width: 6px; height: 3px; margin-left: -3px; background: var(--sand); }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
body.portrait:not(.force) #rotate { display: flex; }
body.portrait:not(.force) #stage { visibility: hidden; }

#errs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 99; max-height: 40%; overflow: auto; background: var(--black); color: var(--coral); border-top: 2px solid var(--coral); font: 10px/1.4 monospace; white-space: pre-wrap; padding: 4px 8px; }

@media (prefers-reduced-motion: reduce) {
  #ticker.fresh #tk-text, .act.flash, #edge.pulse, #edge.h90, #rotate .phone, #plus > button.coach, #ticker.coach #tk-dot { animation: none; }
  #plus > button.coach { border-color: var(--gold); }
}
