/* Chamber Roll (free play): the Chamber Roll look, charcoal, amber and bone. */
:root {
  --amber: #FBAD36;
  --amber-deep: #e0942b;
  --bg: #1c1b1a;
  --panel: #262524;
  --panel-2: #2e2d2b;
  --bone: #f3ede0;
  --bone-pip: #2a2724;
  --muted: #8c8780;
  --line: #3a3937;
  --hit-glow: rgba(251, 173, 54, .55);
  --red: #e23b3b; --orange: #f0883e; --yellow: #f3c63d; --green: #4caf50; --blue: #3d8bf0; --violet: #9b59d0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Josefin Sans', system-ui, sans-serif;
  background: radial-gradient(120% 90% at 50% -10%, #2a2826 0%, var(--bg) 55%);
  background-color: var(--bg);
  color: var(--bone);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 28px 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--amber); }
.stage { width: 100%; max-width: 680px; }

/* ---- Header / hex ring ---- */
.head { text-align: center; margin-bottom: 22px; }
.hexwrap { width: 108px; height: 108px; margin: 0 auto 12px; position: relative; }
.lvl-badge {
  position: absolute; inset: 0; z-index: 1; text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; line-height: 1;
}
.lvl-badge .lab { font-size: 9px; letter-spacing: .28em; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.lvl-badge .num { font-size: 30px; color: var(--amber); }
.eyebrow { font-size: 11px; letter-spacing: .4em; color: var(--muted); font-weight: 600; text-transform: uppercase; }
h1 { font-size: 38px; font-weight: 700; letter-spacing: .01em; margin: 4px 0 2px; line-height: 1.05; }
.tagline { font-size: 14px; color: var(--amber); font-weight: 500; letter-spacing: .04em; }

/* ---- Buff line ---- */
.buffline { text-align: center; font-size: 14px; color: var(--muted); margin-bottom: 20px; font-weight: 400; }
.buffline b { color: var(--bone); font-weight: 600; }

/* ---- Tray + dice ---- */
.tray {
  background: linear-gradient(180deg, var(--panel) 0%, #211f1e 100%);
  border: 1px solid var(--line); border-radius: 18px; padding: 26px 20px 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03), 0 12px 40px rgba(0, 0, 0, .4);
}
.message { text-align: center; font-size: 16px; line-height: 1.55; color: var(--bone); font-weight: 300; }
.message strong { color: var(--amber); font-weight: 600; }
.dice { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 22px; }
@media (max-width: 560px) { .dice { grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 300px; margin-inline: auto; } }
.die {
  aspect-ratio: 1; background: linear-gradient(145deg, #fbf6ec, #e6ddcc);
  border-radius: 14px; padding: 13%; position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  box-shadow: 0 3px 0 #c3b9a6, 0 5px 8px rgba(0, 0, 0, .35);
  transition: transform .25s ease, box-shadow .25s, filter .25s, opacity .25s;
}
.pip { display: flex; align-items: center; justify-content: center; }
.pip::after { content: ''; width: 62%; height: 62%; border-radius: 50%; background: var(--bone-pip); transform: scale(0); transition: transform .08s; }
.pip.on::after { transform: scale(1); }
.die.rolling { animation: tumble .28s infinite; }
@keyframes tumble {
  0% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-7px) rotate(-9deg); }
  50% { transform: translateY(2px) rotate(7deg); }
  75% { transform: translateY(-4px) rotate(-4deg); }
  100% { transform: translateY(0) rotate(0); }
}
.die.hit { box-shadow: 0 0 0 3px var(--amber), 0 0 22px var(--hit-glow), 0 4px 0 #c3b9a6; transform: translateY(-4px); }
.die.miss { filter: grayscale(.7) brightness(.62); opacity: .65; }
.die .badge {
  position: absolute; top: -9px; right: -9px; min-width: 22px; height: 22px; border-radius: 11px;
  background: var(--amber); color: #1c1b1a; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
  transform: scale(0); transition: transform .2s cubic-bezier(.34, 1.56, .64, 1); box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.die .badge.show { transform: scale(1); }
.die .badge.rr { background: var(--blue); color: #fff; }

.tray { position: relative; }
/* ---- Best of 3: counter + roll log ---- */
.counter { text-align: center; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: -4px 0 14px; }
.counter span { color: var(--amber); }
.rolllog { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; }
.rolllog[hidden] { display: none; }
.rolllog li {
  display: grid; grid-template-columns: 58px 58px 1fr auto; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px;
}
.rolllog .rn { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.rolllog .rh { font-weight: 700; font-variant-numeric: tabular-nums; }
.rolllog .rp { color: var(--muted); font-weight: 300; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rolllog li.best { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; }
.rolllog li.best .rp { color: var(--bone); }
.star { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: #1c1b1a; background: var(--amber); border-radius: 4px; padding: 3px 6px; white-space: nowrap; }
.small.first { margin: -2px 0 8px; }
@media (max-width: 420px) { .rolllog li { grid-template-columns: 50px 52px 1fr auto; padding: 8px 10px; gap: 6px; font-size: 12px; } }

/* ---- Tally + roll ---- */
.tally { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-bottom: 20px; min-height: 40px; }
.tally .n { font-size: 44px; font-weight: 700; color: var(--amber); line-height: 1; font-variant-numeric: tabular-nums; }
.tally .l { font-size: 14px; letter-spacing: .2em; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.roll {
  display: block; width: 100%; font-family: inherit; font-size: 18px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #1c1b1a; background: var(--amber); border: none; border-radius: 12px;
  padding: 16px; cursor: pointer; transition: .15s; box-shadow: 0 4px 0 var(--amber-deep);
}
.roll:hover:not(:disabled) { background: #ffbb4d; transform: translateY(-1px); box-shadow: 0 5px 0 var(--amber-deep); }
.roll:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--amber-deep); }
.roll:disabled { opacity: .45; cursor: not-allowed; }
.roll[hidden] { display: none; }
.note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 12px; font-weight: 300; }
.note[hidden] { display: none; }


/* ---- Free play: header buttons, hex, picker ---- */
.head { position: relative; }
.head-btns { position: absolute; top: 0; right: 0; display: flex; gap: 6px; z-index: 2; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-family: inherit;
  background: var(--panel); border: 1px solid var(--line); color: var(--bone); font-size: 14px;
}
.icon-btn:hover { border-color: var(--amber); }
.hexwrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hexwrap polygon { fill: #2b2926; stroke: var(--amber); stroke-width: 3; transition: stroke .3s, fill .3s; }
.hexwrap[data-level="5"] polygon, .hexwrap[data-level="6"] polygon { fill: #3a2c17; stroke: #ffcf6e; }
h1 span { color: var(--amber); }
.picker {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px;
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: center;
}
.picker-label { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.lvlpick { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.lvlpick button {
  font-family: inherit; font-weight: 700; font-size: 15px; color: var(--muted); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  width: 44px; height: 40px; display: flex; align-items: center; justify-content: center; transition: .15s;
}
.lvlpick button:hover { color: var(--bone); border-color: var(--amber-deep); }
.lvlpick button.active { background: var(--amber); color: #1c1b1a; border-color: var(--amber); }
.lvlpick.locked button:not(.active) { opacity: .45; cursor: not-allowed; }

/* ---- Result ---- */
.result {
  margin-top: 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel);
  overflow: hidden; opacity: 0; transform: translateY(8px); transition: opacity .4s, transform .4s;
}
.result[hidden] { display: none; }
.result.show { opacity: 1; transform: none; }
.result .top {
  padding: 18px 20px 14px; text-align: center; border-bottom: 1px dashed var(--line);
  background: linear-gradient(180deg, rgba(251, 173, 54, .07), transparent);
}
.result.exalted { border-color: var(--amber); box-shadow: 0 0 30px var(--hit-glow); }
.result .tier { font-size: 13px; letter-spacing: .24em; font-weight: 700; text-transform: uppercase; color: var(--amber); }
.result.exalted .tier { font-size: 22px; }
.result .flav { font-size: 14px; color: var(--muted); margin-top: 3px; font-weight: 300; }
.result .reward { font-size: 24px; font-weight: 700; margin-top: 10px; color: var(--bone); line-height: 1.2; }
.odds-line { font-size: 13px; color: var(--muted); margin-top: 6px; }
.newbest { display: inline-block; margin-top: 10px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: #1c1b1a; background: var(--amber); border-radius: 5px; padding: 4px 8px; }
.newbest[hidden] { display: none; }
.result .body { padding: 14px 20px; text-align: center; }
.btn {
  font-family: inherit; font-weight: 700; font-size: 14px; letter-spacing: .08em; text-transform: uppercase;
  border-radius: 10px; padding: 11px 18px; cursor: pointer; transition: .15s;
}
.btn.ghost { background: none; color: var(--amber); border: 1px solid var(--amber-deep); }
.btn.ghost:hover { background: rgba(251, 173, 54, .08); }
.btn.gold { background: var(--amber); color: #1c1b1a; border: none; box-shadow: 0 3px 0 var(--amber-deep); }
.copied { font-size: 13px; color: var(--muted); margin-top: 8px; }
.copied[hidden] { display: none; }

/* ---- Records ---- */
.records { margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 14px 18px; }
.records h3 { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--amber-deep); font-weight: 700; margin-bottom: 10px; text-align: center; }
.rec-top { display: flex; justify-content: center; gap: 36px; margin-bottom: 12px; }
.rec-top div { text-align: center; }
.rec-top b { display: block; font-size: 24px; color: var(--amber); font-variant-numeric: tabular-nums; }
.rec-top span { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.rec-levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.rec { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 4px; text-align: center; }
.rec span { display: block; font-size: 10px; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
.rec b { font-size: 18px; font-variant-numeric: tabular-nums; }
.rec.you { border-color: var(--amber-deep); }
.rec.ex b { color: var(--amber); }
.rec-levels::before { content: 'Best roll at each level'; grid-column: 1 / -1; font-size: 11px; color: var(--muted); text-align: center; }

/* ---- Help dialog ---- */
dialog {
  margin: auto; max-width: 440px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); color: var(--bone); padding: 22px 22px 18px; font-family: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog h2 { font-size: 20px; color: var(--amber); margin-bottom: 10px; letter-spacing: .04em; }
dialog ol { padding-left: 20px; font-size: 15px; line-height: 1.55; font-weight: 300; }
dialog ol b { font-weight: 600; }
dialog .scoring { font-size: 13px; color: var(--muted); margin: 12px 0 14px; }
dialog form { text-align: center; }
.foot p { margin: 2px 0; }
@media (max-width: 480px) { .head { padding-top: 40px; } h1 { font-size: 32px; } }

/* ---- How the dice work (accordion) ---- */
.howto {
  margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  overflow: hidden;
}
.howto summary {
  cursor: pointer; list-style: none; padding: 14px 18px; font-weight: 700; font-size: 15px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--amber);
  display: flex; align-items: center; justify-content: space-between;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: '+'; font-size: 22px; line-height: 1; color: var(--muted); transition: transform .2s; }
.howto[open] summary::after { transform: rotate(45deg); }
.howto summary:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }
.howto-body { padding: 0 18px 18px; font-size: 14px; line-height: 1.55; color: var(--bone); font-weight: 300; }
.howto-body b { font-weight: 600; }
.howto h3 { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--amber-deep); font-weight: 700; margin: 18px 0 8px; }
.steps { padding-left: 20px; }
.steps li { margin: 4px 0; }
.perks { margin-top: 12px; display: grid; gap: 8px; }
.perks p { padding-left: 34px; text-indent: -34px; }
.perks .chip { margin-right: 6px; text-indent: 0; }
.chip {
  flex: none; min-width: 24px; height: 22px; border-radius: 11px; padding: 0 6px;
  background: var(--amber); color: #1c1b1a; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
}
.chip.rr { background: var(--blue); color: #fff; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.howto table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.howto th { text-align: left; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.howto td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.howto tr:last-child td { border-bottom: none; }
.odds td:nth-child(n+5), .odds th:nth-child(n+5) { text-align: right; }
.odds td.lv { white-space: nowrap; }
.odds td.pk { white-space: nowrap; }
.odds td.pk .chip + .chip { margin-left: 4px; }
.odds td.lv img { vertical-align: middle; margin-right: 6px; }
.odds tr.you td { background: rgba(251, 173, 54, .08); }
.odds tr.you td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.tagyou { margin-left: 6px; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: #1c1b1a; background: var(--amber); border-radius: 4px; padding: 2px 5px; }
.prizes td:first-child { width: 56px; font-weight: 600; color: var(--amber); }
.small { font-size: 12px; color: var(--muted); margin-top: 8px; }
@media (max-width: 480px) {
  .howto-body { padding: 0 14px 16px; }
  .howto table { font-size: 12px; }
  .howto th, .howto td { padding: 7px 4px; }
}

.foot { text-align: center; font-size: 11px; color: var(--muted); margin-top: 22px; letter-spacing: .04em; line-height: 1.7; opacity: .8; }
.foot a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .die.rolling { animation: none; }
  .prize { transition: opacity .2s; }
}
