/* Loaded - weighted random number generator */

:root {
  --ink:      #1B1035;
  --ink-2:    #241748;
  --panel:    #2A1A4E;
  --panel-2:  #33205C;
  --line:     #45308A;
  --paper:    #F2ECFF;
  --paper-dim:#B9A9DE;
  --muted:    #8B7AB8;

  --gold:  #FFD23F;
  --teal:  #34E0C8;
  --pink:  #FF5C8A;
  --violet:#8B7BFF;
  --orange:#FF9F45;
  --sky:   #5CC8FF;
  --slate: #5A4B7C;

  --shadow-hard: 0 4px 0 #150C2B;
  --r: 10px;

  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  background-image:
    radial-gradient(1100px 620px at 50% -12%, #3A2270 0%, rgba(58,34,112,0) 62%);
  background-repeat: no-repeat;
  color: var(--paper);
  font-family: var(--font);
  font-variation-settings: "wdth" 100, "wght" 450;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

.wrap {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--gold);
  color: #241748;
  padding: 10px 16px;
  border-radius: 0 0 var(--r) 0;
  z-index: 50;
  font-variation-settings: "wght" 700;
}
.skip:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- top bar ---------- */

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(27,16,53,.82);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  flex-wrap: wrap;
}

.mark {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--gold);
}

.mark-glyph { width: 24px; height: 24px; display: block; }

.mark-word {
  font-variation-settings: "wdth" 122, "wght" 900;
  font-size: 21px;
  letter-spacing: -.01em;
  color: var(--paper);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--paper-dim);
  font: inherit;
  font-variation-settings: "wght" 600;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.tab:hover { color: var(--paper); }
.tab[aria-selected="true"] {
  background: var(--gold);
  color: #241748;
  font-variation-settings: "wght" 800;
}

/* ---------- shared bits ---------- */

main { padding-bottom: 56px; }

.panel { padding-top: 30px; }

.h-sec {
  font-size: 15px;
  font-variation-settings: "wdth" 108, "wght" 750;
  margin: 0;
  color: var(--paper);
}

.hint, .muted, .bands-sub, .sim-sub, .board-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0;
}

.alert {
  margin: 18px 0 0;
  padding: 11px 14px;
  border-radius: var(--r);
  font-size: 14px;
  border: 1px solid var(--pink);
  background: rgba(255,92,138,.12);
  color: #FFC9D8;
}
.alert.is-warn {
  border-color: var(--gold);
  background: rgba(255,210,63,.11);
  color: #FFE8A6;
}

.btn {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-variation-settings: "wght" 700;
  color: var(--paper);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px 15px;
  cursor: pointer;
}
.btn:hover { background: #3D2770; }
.btn:active { transform: translateY(1px); }
.btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  background: var(--panel);
}
.btn[disabled]:hover { background: var(--panel); }
.btn-quiet { background: transparent; color: var(--paper-dim); }
.btn-quiet:hover { background: rgba(255,92,138,.14); color: #FFC9D8; border-color: var(--pink); }

.linkbtn {
  appearance: none;
  background: none;
  border: 0;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  min-width: 38px;
  justify-content: center;
  padding: 0 8px;
}
.linkbtn:hover { color: var(--paper); }

label {
  display: block;
  font-size: 13px;
  font-variation-settings: "wght" 650;
  color: var(--paper-dim);
  margin-bottom: 5px;
}

.num, .text, select {
  appearance: none;
  font: inherit;
  font-variation-settings: "wght" 650;
  color: var(--paper);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px 11px;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23B9A9DE' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
  padding-right: 32px;
}
.num::-webkit-outer-spin-button,
.num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num { -moz-appearance: textfield; }

/* ---------- stage: readout + roll ---------- */

.stage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 24px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--ink-2) 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  flex-wrap: wrap;
}

.readout { flex: 1 1 260px; min-width: 0; }

.readout-numbers {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
  font-variation-settings: "wdth" 125, "wght" 900;
  font-variant-numeric: tabular-nums;
  font-size: clamp(56px, 15vw, 96px);
  line-height: .92;
  letter-spacing: -.035em;
}

.rn { color: var(--gold); }
.rn-idle { color: var(--slate); }
.rn-small { font-size: .58em; }

.readout-note {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--paper-dim);
  font-variation-settings: "wght" 550;
}

.roll {
  appearance: none;
  font: inherit;
  cursor: pointer;
  flex: 0 0 auto;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 38% 32%, #FFE98A 0%, var(--gold) 46%, #E0A800 100%);
  color: #2B1A05;
  box-shadow: 0 7px 0 #A97A00, 0 7px 26px rgba(255,210,63,.28);
  transition: transform .08s ease, box-shadow .08s ease;
}
.roll-face {
  font-size: 25px;
  font-variation-settings: "wdth" 118, "wght" 900;
  letter-spacing: -.01em;
}
.roll:hover { box-shadow: 0 7px 0 #A97A00, 0 7px 34px rgba(255,210,63,.42); }
.roll:active { transform: translateY(6px); box-shadow: 0 1px 0 #A97A00; }
.roll[disabled] {
  background: var(--panel-2);
  color: var(--muted);
  box-shadow: 0 4px 0 #150C2B;
  cursor: not-allowed;
}
.roll.is-busy { cursor: progress; }

/* ---------- board ---------- */

.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 34px 0 12px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 7px;
}
.grid.is-dense { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 5px; }

.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 9px;
  background: #190F3B;
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

.tile-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background: var(--tint, var(--slate));
  box-shadow: inset 0 2px 0 rgba(255,255,255,.42);
}

.tile-n {
  font-variation-settings: "wdth" 108, "wght" 800;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  line-height: 1;
  color: var(--paper);
  text-shadow: 0 1px 2px rgba(20,11,42,.7);
}
.grid.is-dense .tile-n { font-size: 12px; }

.tile-p {
  font-size: 9.5px;
  font-variation-settings: "wght" 650;
  line-height: 1;
  margin-top: 3px;
  color: rgba(242,236,255,.82);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(20,11,42,.7);
}
.grid.is-dense .tile-p { display: none; }

.tile.is-full .tile-n { color: var(--tint-ink, var(--paper)); text-shadow: none; }
.tile.is-full .tile-p { color: var(--tint-ink, var(--paper)); opacity: .68; text-shadow: none; }

.tile.is-out { opacity: .28; }

.tile.is-hit {
  border-color: #FFFFFF;
  box-shadow: 0 0 0 2px #FFFFFF, 0 0 26px rgba(255,255,255,.45);
  animation: pop .42s cubic-bezier(.2,1.5,.4,1);
}
.tile.is-hit .tile-fill { height: 100% !important; box-shadow: none; }
.tile.is-hit .tile-n { color: var(--tint-ink, #1B1035); text-shadow: none; }
.tile.is-hit .tile-p { color: var(--tint-ink, #1B1035); opacity: .72; text-shadow: none; }

@keyframes pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.grid-fallback {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  color: var(--paper-dim);
  font-size: 14px;
}

/* ---------- odds bar ---------- */

.oddsbar-block { margin-top: 26px; }

.oddsbar {
  display: flex;
  height: 34px;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--ink-2);
}

.seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: #1B1035;
  font-size: 12px;
  font-variation-settings: "wght" 800;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  white-space: nowrap;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 11px 0 0;
  padding: 0;
  font-size: 13px;
  color: var(--paper-dim);
}
.legend li { display: flex; align-items: center; gap: 7px; }
.legend .dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend b {
  font-variation-settings: "wght" 750;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

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

.history { margin-top: 34px; }

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.history-strip {
  display: flex;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 34px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 34px), transparent 100%);
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.chip {
  flex: 0 0 auto;
  min-width: 38px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-bottom: 3px solid var(--tint, var(--slate));
  text-align: center;
  font-variation-settings: "wght" 800;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.chip.is-latest { border-color: var(--gold); background: var(--panel-2); }
.chip-group {
  flex: 0 0 auto;
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: rgba(69,48,138,.32);
}

/* ---------- odds tab ---------- */

.range-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.range-row .field { flex: 0 1 150px; }
.range-to {
  color: var(--muted);
  font-size: 14px;
  padding-bottom: 11px;
}
.range-count {
  flex: 1 1 100%;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.bands { margin-top: 32px; }
.bands-head { margin-bottom: 14px; }
.bands-head .bands-sub { margin-top: 5px; max-width: 62ch; }

.bandlist { display: flex; flex-direction: column; gap: 9px; }

.band {
  display: grid;
  grid-template-columns: 14px 1fr auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--tint, var(--slate));
  border-radius: var(--r);
}
.band .swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--tint); }
.band .band-to { color: var(--muted); font-size: 13px; }
.band .share-wrap { display: flex; align-items: center; gap: 5px; }
.band .share-wrap .num { width: 74px; }
.band .pct { color: var(--muted); font-size: 14px; }
.band .drop {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.band .drop:hover { color: var(--pink); background: rgba(255,92,138,.14); }
.band.is-bad { border-color: var(--pink); }

.bands-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.leftover { margin: 0; font-size: 13.5px; color: var(--paper-dim); }
.leftover b { color: var(--paper); font-variation-settings: "wght" 750; }

/* ---------- simulation ---------- */

.sim { margin-top: 38px; padding-top: 26px; border-top: 1px solid var(--line); }
.sim-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.sim-sub { margin-top: 6px; }
.sim-out { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }

.simrow { display: grid; grid-template-columns: 1fr; gap: 5px; }
.simrow-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  color: var(--paper-dim);
}
.simrow-top b { color: var(--paper); font-variation-settings: "wght" 750; }
.simrow-top .got { font-variant-numeric: tabular-nums; }
.simtrack {
  height: 9px;
  border-radius: 999px;
  background: var(--ink-2);
  overflow: hidden;
  border: 1px solid var(--line);
}
.simfill { height: 100%; background: var(--tint, var(--slate)); }

/* ---------- settings ---------- */

.setgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
}
.set .hint { margin-top: 6px; }

.presets { margin-top: 38px; padding-top: 26px; border-top: 1px solid var(--line); }
.presets .hint { margin-top: 6px; max-width: 62ch; }
.preset-add { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.preset-add .text { flex: 1 1 200px; width: auto; }

.preset-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.preset-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.preset-list .pname { flex: 1 1 auto; font-variation-settings: "wght" 700; font-size: 14px; }
.preset-list .pmeta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.danger { margin-top: 38px; padding-top: 26px; border-top: 1px solid var(--line); }
.danger-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.danger .hint { margin-top: 11px; }

/* ---------- foot ---------- */

.foot {
  border-top: 1px solid var(--line);
  padding: 22px 0 34px;
  color: var(--muted);
  font-size: 13px;
}
.foot p { margin: 0; max-width: 62ch; }

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  .topbar-in { min-height: 0; padding: 10px 0; }
  .tabs { width: 100%; justify-content: space-between; }
  .tab { flex: 1 1 auto; text-align: center; padding: 8px 10px; }
  .stage { padding: 20px 18px; gap: 16px; flex-wrap: nowrap; }
  .readout { flex: 1 1 120px; }
  .roll { width: 104px; height: 104px; }
  .roll-face { font-size: 21px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .band { grid-template-columns: 14px 1fr auto 1fr; row-gap: 8px; }
  .band .share-wrap { grid-column: 2 / 4; }
  .band .drop { grid-column: 4; justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  .tile.is-hit { animation: none; }
  .roll { transition: none; }
  * { scroll-behavior: auto; }
}
