/* CrapSim site chrome. The cream-and-ink system. Never borrows felt colors
   for surfaces, gold is the shared accent between the two systems. */

:root {
    --felt: #0a2e1a;
    --felt-shadow: #05170c;
    --gold: #c9a84c;
    --gold-bright: #e8c874;
    --cream: #f5f0e8;
    --cream-dim: #cfc6b8;
    --ink: #182420;
    --win: #3f9142;
    --loss: #9c3b2e;

    --display: 'Playfair Display', serif;
    --body: 'Work Sans', sans-serif;
    --mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--body);
    background: var(--cream);
    color: var(--ink);
    display: flex;
    flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- header ---------- */

.site-header {
    display: flex;
    align-items: baseline;
    gap: 32px;
    padding: 14px 24px 12px;
    border-bottom: 2px solid var(--gold);
    background: var(--cream);
}

.wordmark {
    font-family: var(--display);
    font-weight: 700;
    font-size: 26px;
    letter-spacing: 0.5px;
}

.tabs { display: flex; gap: 4px; }

.tab {
    font-family: var(--body);
    font-weight: 500;
    font-size: 14px;
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    border-radius: 4px 4px 0 0;
}

.tab.active {
    background: var(--ink);
    color: var(--cream);
}

.tab:disabled { color: var(--cream-dim); cursor: default; }

/* ---------- layout ---------- */

.layout {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* The felt scales to the width of this box, so anything that makes a
   scrollbar come and go here resizes the whole table. Sideways scrolling is
   off and the vertical scrollbar keeps its gutter whether it shows or not. */
.felt-wrap {
    flex: 1;
    position: relative;
    padding: 18px;
    background: var(--felt-shadow);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.panel {
    width: 340px;
    flex: 0 0 340px;
    padding: 18px;
    overflow-y: auto;
    border-left: 1px solid var(--cream-dim);
}

.panel-block { display: flex; flex-direction: column; gap: 12px; }

.panel-title {
    font-family: var(--display);
    font-weight: 500;
    font-size: 22px;
}

.panel-sub {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink);
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.exposure { font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--loss); }

.fld {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    justify-content: space-between;
}

.fld input, .fld select {
    font-family: var(--mono);
    font-size: 14px;
    padding: 6px 8px;
    border: 1px solid var(--cream-dim);
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
    width: 120px;
}

/* ---------- buttons ---------- */

.btn {
    font-family: var(--body);
    font-weight: 600;
    font-size: 14px;
    padding: 9px 16px;
    border: 1px solid var(--ink);
    border-radius: 5px;
    background: var(--cream);
    color: var(--ink);
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease;
}

.btn:hover { background: #fff; }
.btn:active { transform: translateY(1px); }

.btn-gold {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--ink);
}

.btn-gold:hover { background: var(--gold-bright); border-color: var(--gold-bright); }

.btn-quiet { border-color: var(--cream-dim); color: var(--ink); font-weight: 500; }

.btn-wide { width: 100%; }

.btn-roll {
    font-size: 18px;
    padding: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- bankroll + counters ---------- */

.bankroll-display { display: flex; flex-direction: column; }

.bankroll-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--cream-dim);
}

.bankroll-figure {
    font-family: var(--display);
    font-weight: 700;
    font-size: 42px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.bankroll-felt { font-family: var(--mono); font-size: 13px; }
.bankroll-delta { font-family: var(--mono); font-size: 13px; min-height: 18px; }
.bankroll-delta.up { color: var(--win); }
.bankroll-delta.down { color: var(--loss); }

.counters {
    display: flex;
    gap: 18px;
    font-size: 13px;
    color: var(--ink);
}

.counters b { font-family: var(--mono); font-weight: 500; }

/* ---------- bet list ---------- */

.bet-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }

.bet-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 7px 9px;
    border: 1px solid var(--cream-dim);
    border-radius: 5px;
    background: #fff;
}

.bet-list .bname { flex: 1; font-weight: 500; }
.bet-list .bamt { font-family: var(--mono); }
.bet-list .off-tag {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    color: var(--loss); border: 1px solid var(--loss);
    padding: 1px 5px; border-radius: 3px;
}

.bet-list .mini {
    font-size: 11px;
    padding: 3px 7px;
    border: 1px solid var(--cream-dim);
    background: var(--cream);
    border-radius: 3px;
    cursor: pointer;
}

.bet-list .mini:hover { border-color: var(--gold); background: var(--gold-bright); }

.bet-list .empty { border: none; background: none; color: var(--cream-dim); font-style: italic; }

/* ---------- roll feed ---------- */

/* The minimal record: hands top to bottom, rolls numbered inside each hand,
   newest at the bottom. A roll opens in the full history when clicked. */

.feed {
    list-style: none;
    font-family: var(--mono);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 46vh;
    overflow-y: auto;
}

.feed li { display: flex; gap: 8px; align-items: baseline; }

.feed .fhand {
    justify-content: space-between;
    margin-top: 8px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--cream-dim);
    font-family: var(--body);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.feed .fhand:first-child { margin-top: 0; }
.feed .fhand .fdelta { font-family: var(--mono); font-weight: 500; letter-spacing: 0; }

.feed .froll { cursor: pointer; border-radius: 3px; padding: 1px 2px; }
.feed .froll:hover { background: #fff; }
.feed .fnum { width: 18px; text-align: right; opacity: 0.6; }
.feed .fdice { width: 46px; }
.feed .ftag { flex: 1; color: var(--ink); }
.feed .fdelta.up { color: var(--win); }
.feed .fdelta.down { color: var(--loss); }
.feed .sevenout .ftag { color: var(--loss); font-weight: 500; }
.feed .pointmade .ftag { color: var(--win); font-weight: 500; }
.feed .fempty { opacity: 0.6; font-style: italic; }

/* ---------- full history ---------- */

.history {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(5, 23, 12, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.history-box {
    width: min(980px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--cream);
    color: var(--ink);
    border: 2px solid var(--gold);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.history-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 14px 20px 10px;
    border-bottom: 1px solid var(--cream-dim);
    font-family: var(--display);
    font-weight: 500;
    font-size: 22px;
}

.history-body { padding: 14px 20px 20px; overflow-y: auto; font-size: 13px; }

.history-body .up { color: var(--win); }
.history-body .down { color: var(--loss); }
.hstart, .hpending { margin-bottom: 10px; }
.hpending { margin-top: 14px; }

.htable { width: 100%; border-collapse: collapse; background: #fff; margin-bottom: 18px; }

.hhand {
    display: flex;
    justify-content: space-between;
    padding: 6px 2px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.hhand span + span { font-family: var(--mono); font-weight: 500; letter-spacing: 0; }

.htable th, .htable td {
    text-align: left;
    vertical-align: top;
    padding: 6px 10px;
    border: 1px solid var(--cream-dim);
    font-family: var(--mono);
    font-size: 12px;
    white-space: nowrap;
}

.htable th { font-family: var(--body); font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.htable .hwhat { width: 100%; white-space: normal; font-family: var(--body); font-size: 13px; line-height: 1.5; }
.hact { opacity: 0.75; }
.hact::before { content: 'bet  '; font-family: var(--mono); font-size: 10px; text-transform: uppercase; opacity: 0.7; }
.hdice { font-weight: 600; }
.htable tr.focus td { background: #fbf3dc; }

/* ---------- picker ---------- */

/* Click only. One panel serves a single bet (one amount with minus and plus)
   and a group bet (a row per member). game.js fills and positions it. */

.picker {
    position: fixed;
    z-index: 60;
    width: 270px;
    background: var(--cream);
    border: 2px solid var(--gold);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.picker-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--display);
    font-weight: 500;
    font-size: 18px;
}

.picker-link {
    font-family: var(--body);
    font-size: 12px;
    font-weight: 500;
    border: none;
    background: none;
    color: var(--ink);
    opacity: 0.65;
    text-decoration: underline;
    cursor: pointer;
}

.picker-link:hover { opacity: 1; }

.picker-mode { display: flex; gap: 4px; flex-wrap: wrap; }

.picker-mode .mode {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 6px;
    border: 1px solid var(--cream-dim);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.picker-mode .mode.active { background: var(--ink); color: var(--cream); border-color: var(--ink); }

.picker-chips { display: flex; gap: 4px; }

.chipbtn {
    flex: 1;
    font-family: var(--mono);
    font-size: 13px;
    padding: 6px 0;
    border: 1px solid var(--cream-dim);
    border-radius: 14px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}

.chipbtn:hover { border-color: var(--gold); }
.chipbtn.active { background: var(--loss); border-color: var(--loss); color: #fff; }

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

.picker-step {
    width: 30px;
    height: 30px;
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 600;
    border: 1px solid var(--cream-dim);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}

.picker-step:hover { border-color: var(--gold); }

.picker-one { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.picker-one .picker-step { width: 44px; height: 44px; font-size: 22px; }

.picker-big {
    font-family: var(--display);
    font-weight: 700;
    font-size: 30px;
    font-variant-numeric: tabular-nums;
}

.picker-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.picker-row .pname { flex: 1; font-weight: 600; }
.picker-row .ppay { width: 62px; font-family: var(--mono); font-size: 11px; opacity: 0.65; }
.picker-row .pamt { width: 52px; text-align: right; font-family: var(--mono); font-size: 14px; }
.picker-row.all { border-top: 1px solid var(--cream-dim); padding-top: 8px; }
.picker-row.all .ppay { display: none; }

/* Hop: a row of totals, then one row per way to roll the total picked. */
.hop-totals { display: grid; grid-template-columns: repeat(11, 1fr); gap: 2px; }

.hop-total {
    padding: 5px 0;
    border: 1px solid var(--cream-dim);
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12px;
    cursor: pointer;
}

.hop-total:hover { border-color: var(--gold); }
.hop-total.has { border-color: var(--loss); color: var(--loss); font-weight: 700; }
.hop-total.active { background: var(--ink); border-color: var(--ink); color: var(--cream); }

.hop-hard { font-size: 12px; padding: 5px 8px; }

.picker.wide { width: 310px; }

.hop-faces { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.hop-faces > span:last-child { margin-left: 3px; font-family: var(--mono); font-weight: 500; }
.hop-pick { font-weight: 400; opacity: 0.7; }

.hop-die {
    display: grid;
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
    width: 22px;
    height: 22px;
    padding: 3px;
    border: 1px solid var(--ink);
    border-radius: 4px;
    background: #fff;
}

.hop-die i { width: 4px; height: 4px; border-radius: 50%; background: var(--ink); place-self: center; }

.picker-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

.picker-hint { font-size: 11px; color: var(--ink); min-height: 14px; }
.picker-hint.err { color: var(--loss); font-weight: 500; }

/* ---------- decision prompt ---------- */

.decision {
    position: absolute;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 55;
    background: var(--cream);
    border: 2px solid var(--gold);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.decision-text { font-weight: 600; font-size: 14px; }
.decision-actions { display: flex; gap: 6px; }

/* ---------- toasts ---------- */

/* Pinned to the visible felt area and clipped to it, so a tall stack or a
   toast sliding in can never add to the scroll size of .felt-wrap. */
.toasts {
    position: absolute;
    top: 16px;
    right: 0;
    bottom: 16px;
    padding: 0 16px 0 24px;
    overflow: hidden;
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    flex: none;
    background: var(--cream);
    border: 1px solid var(--gold);
    border-left-width: 5px;
    border-radius: 6px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.25s ease, toastOut 0.4s ease 2.8s forwards;
}

.toast.win { border-left-color: var(--win); }
.toast.loss { border-left-color: var(--loss); }

@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 980px) {
    .layout { flex-direction: column; }
    .panel { width: auto; flex: none; border-left: none; border-top: 1px solid var(--cream-dim); }
}

/* ---------- app panes ---------- */

#app { flex: 1; display: flex; min-height: 0; }

.pane { display: none; }
.pane.active { display: flex; }

.pane-play { flex: 1; min-height: 0; }

.pane-page {
    flex: 1;
    flex-direction: column;
    gap: 16px;
    padding: 22px 28px;
    overflow-y: auto;
}

.page-head { display: flex; align-items: center; justify-content: space-between; }

/* ---------- strategy cards ---------- */

.strat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.strat-card {
    border: 1px solid var(--cream-dim);
    border-radius: 8px;
    background: #fff;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.strat-card h3 {
    font-family: var(--display);
    font-weight: 500;
    font-size: 19px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.strat-card .desc { font-size: 13px; color: var(--ink); flex: 1; }

.badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid var(--gold);
    color: var(--ink);
    background: var(--gold-bright);
}

.strat-card .card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.strat-card .card-actions .btn { font-size: 12px; padding: 5px 10px; }

/* ---------- editor ---------- */

.editor {
    display: flex;
    gap: 20px;
    border-top: 2px solid var(--gold);
    padding-top: 18px;
}

.editor-main { flex: 1; display: flex; flex-direction: column; gap: 10px; }

.fld-stack { flex-direction: column; align-items: stretch; gap: 4px; font-weight: 600; font-size: 13px; }
.fld-stack input { width: 100%; font-family: var(--body); }

#edRules {
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.5;
    padding: 10px;
    border: 1px solid var(--cream-dim);
    border-radius: 5px;
    background: #fff;
    color: var(--ink);
    resize: vertical;
    tab-size: 2;
}

.editor-msg { font-size: 13px; min-height: 18px; font-family: var(--mono); }
.editor-msg.err { color: var(--loss); }
.editor-msg.ok { color: var(--win); }

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

.grammar {
    width: 320px;
    flex: 0 0 320px;
    font-size: 12.5px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    color: var(--ink);
}

.grammar p { line-height: 1.45; }
.grammar b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }

/* ---------- simulate ---------- */

.sim-form {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 22px;
    align-items: flex-end;
    border: 1px solid var(--cream-dim);
    border-radius: 8px;
    background: #fff;
    padding: 16px;
}

.sim-form .fld { flex-direction: column; align-items: flex-start; gap: 4px; font-weight: 600; font-size: 12px; }
.sim-form .fld input, .sim-form .fld select { width: 130px; }
#simStrategy { width: 240px; }

.sim-msg { font-size: 13px; min-height: 18px; font-family: var(--mono); }
.sim-msg.err { color: var(--loss); }

.sim-results { display: flex; flex-direction: column; gap: 18px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.stat {
    border: 1px solid var(--cream-dim);
    border-radius: 8px;
    background: #fff;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
}

.stat .k {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--cream-dim);
}

.stat .v {
    font-family: var(--display);
    font-weight: 700;
    font-size: 24px;
    font-variant-numeric: tabular-nums;
}

.stat .v.up { color: var(--win); }
.stat .v.down { color: var(--loss); }

.chart-wrap {
    border: 1px solid var(--cream-dim);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
    height: 340px;
}

#singleLog { font-family: var(--mono); font-size: 12px; }
#singleLog table { border-collapse: collapse; width: 100%; background: #fff; }
#singleLog th, #singleLog td { text-align: left; padding: 4px 10px; border-bottom: 1px solid var(--cream-dim); }
#singleLog th { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }

/* ---------- guide ---------- */

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

.guide {
    border: 1px solid var(--cream-dim);
    border-left: 4px solid var(--gold);
    border-radius: 8px;
    background: #fff;
    padding: 20px 26px;
    max-width: 860px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 14px;
    line-height: 1.55;
}

.guide h3 {
    font-family: var(--display);
    font-weight: 500;
    font-size: 18px;
    margin-top: 8px;
}

.guide code {
    font-family: var(--mono);
    font-size: 12.5px;
    background: var(--cream);
    padding: 1px 5px;
    border-radius: 3px;
}

.guide pre {
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.5;
    background: var(--cream);
    border: 1px solid var(--cream-dim);
    border-radius: 6px;
    padding: 12px 14px;
    overflow-x: auto;
}
