@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --bg: #efefee;
  --panel: #fff;
  --line: #dedee4;
  --text: #131628;
  --muted: #60616e;
  --accent: #6f00ff;
  --accent-hover: #5700cc;
  --accent-tint: #f2eaff;
  --green: #198754;
  --red: #d63d47;
  font-family: Poppins, 'Segoe UI', sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.6; }
button, summary { -webkit-tap-highlight-color: transparent; cursor: pointer; }
button { font: inherit; transition: background .18s, transform .18s; }
button:disabled { cursor: wait; }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 5px; }
button:active:not(:disabled) { transform: translateY(2px); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.topbar { background: var(--text); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; max-width: 1100px; margin: auto; padding: 18px 32px; }
.wordmark { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 14px; font-weight: 800; letter-spacing: .04em; margin: 0; }
.brand-mark { display: grid; place-items: center; background: var(--accent); color: #fff; width: 30px; height: 30px; border-radius: 7px; font-size: 26px; line-height: 1; }
.reset-button { background: transparent; border: 1px solid #555767; border-radius: 100px; color: #eeeef5; padding: 8px 16px; font-size: 13px; white-space: nowrap; }
.reset-button:hover { background: #292c41; }
.reset-button:focus-visible { outline-color: #c49bff; }
.page { width: min(100%, 588px); margin: 0 auto; padding: 30px 24px 18px; }
.intro { color: var(--muted); font-size: 14px; text-align: center; margin: 0 0 20px; }
.game-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 8px 28px #13162806; padding: 36px 40px 22px; text-align: center; }
.face { margin: 0 auto; display: grid; place-items: center; width: 132px; height: 132px; background: var(--text); border: 1px solid #282c48; border-radius: 26px; box-shadow: 0 10px 0 #080a15, 0 16px 25px #13162812; color: #fff; transition: background .18s, color .18s, border-color .18s; }
.face span { font-size: 68px; font-weight: 600; line-height: 1; }
.face[data-result=red] { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 10px 0 #9b2631, 0 16px 25px #13162812; }
.face[data-result=green] { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 10px 0 #115c39, 0 16px 25px #13162812; }
.face.rolling { animation: roll .32s ease-in-out; }
.face.rolling span { opacity: .35; }
.result-copy { display: grid; place-items: center; min-height: 58px; margin: 22px 0 14px; font-size: 18px; line-height: 1.45; font-weight: 600; letter-spacing: -.02em; }
.roll-button { border: 0; border-radius: 100px; background: var(--accent); color: #fff; font-weight: 700; width: 100%; min-height: 52px; padding: 13px 20px; display: flex; align-items: center; justify-content: center; gap: 10px; text-transform: uppercase; }
.roll-button:hover:not(:disabled) { background: var(--accent-hover); }
.roll-button:disabled { opacity: .7; }
.roll-button > span:first-child:not(:last-child) { font-size: 25px; line-height: 1; }
.counters { display: grid; grid-template-columns: 1fr 1fr; padding: 23px 0 20px; margin-top: 8px; }
.counters > div + div { border-left: 1px solid var(--line); }
.counter-label { font-size: 13px; color: var(--muted); display: block; }
.counters strong { font-size: 28px; line-height: 1.25; display: block; margin-bottom: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.counters > div:last-child strong { color: var(--green); }
.reveal-section { position: relative; border-top: 1px solid var(--line); padding-top: 14px; }
.secondary-button { display: flex; align-items: center; justify-content: center; gap: 12px; border: 1px solid var(--line); border-radius: 100px; background: transparent; color: var(--text); font-size: 14px; font-weight: 500; min-height: 44px; padding: 10px 18px; }
.secondary-button:hover { background: #f5f5f8; }
.reveal-popover { position: absolute; z-index: 2; bottom: calc(100% + 10px); left: 0; width: 100%; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 40px #13162829; text-align: left; pointer-events: none; }
.die-summary { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.die-summary h2 { font-size: 30px; line-height: 1.2; margin: 0; font-weight: 800; }
.die-summary h2 small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.probability { text-align: right; }
.probability strong { display: block; font-size: 24px; line-height: 1.3; font-weight: 700; }
.probability span { color: var(--muted); font-size: 12px; }
.face-grid { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; margin: 16px 0 8px; }
.face-grid.twenty { grid-template-columns: repeat(10, 1fr); gap: 5px; }
.grid-cell { aspect-ratio: 1; border-radius: 2px; background: var(--red); }
.grid-cell.is-green { background: var(--green); }
.rules { margin-top: 18px; }
.rules summary { width: fit-content; margin: 0 auto; padding: 8px; font-size: 14px; color: var(--muted); }
.rules summary:hover { color: var(--accent); }
.rules-content { padding: 12px 8px 0; font-size: 14px; color: var(--muted); }
.rules-content p { margin: 0 0 16px; }
.rule { display: flex; align-items: flex-start; gap: 10px; }
.rule strong { color: var(--text); font-weight: 600; }
.rule-swatch { display: grid; place-items: center; flex-shrink: 0; width: 22px; height: 22px; border-radius: 5px; font-size: 17px; font-weight: 700; line-height: 1; margin-top: 1px; }
.red { background: var(--red); color: #fff; }
.green { background: var(--green); color: #fff; }
.keyboard-hint { font-size: 12px; }
kbd { border: 1px solid #c3c3ce; border-radius: 4px; background: #f6f6f8; padding: 1px 5px; font: inherit; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 18px 0 0; }
footer p { margin: 0; line-height: 1.7; }
.source-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; margin: 12px 0; }
.source-links a { color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
.source-links a:hover { color: var(--accent-hover); }
.source-links a:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
footer .affiliate-note { font-size: 12px; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 28px; max-width: 450px; width: calc(100% - 32px); box-shadow: 0 24px 80px #13162833; }
dialog::backdrop { background: #131628aa; backdrop-filter: blur(5px); }
dialog h2 { margin: 0 0 12px; font-size: 24px; font-weight: 800; }
dialog p { font-size: 15px; color: var(--muted); margin: 0 0 24px; }
.dialog-actions { display: flex; gap: 12px; }
.dialog-actions button { width: auto; flex: 1; justify-content: center; font-size: 14px; }
noscript { display: block; padding: 20px; color: var(--red); }
@keyframes roll { 0%,100% { transform: rotate(0) scale(1); } 30% { transform: rotate(-9deg) scale(.92); } 70% { transform: rotate(9deg) scale(.97); } }
@media (max-width:600px) {
  .topbar-inner { padding: 14px 18px; gap: 12px; }
  .wordmark { font-size: 12px; gap: 8px; letter-spacing: .02em; }
  .brand-mark { width: 28px; height: 28px; }
  .reset-button { padding: 8px 12px; font-size: 12px; }
  .page { padding: 22px 16px 18px; }
  .intro { font-size: 13px; margin-bottom: 16px; }
  .game-card { padding: 28px 24px 16px; }
  .face { width: 112px; height: 112px; border-radius: 23px; }
  .face span { font-size: 58px; }
  .result-copy { font-size: 17px; }
  .reveal-popover { padding: 16px; }
  .die-summary { gap: 10px; }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Modes share the same player card and keep each player's controls together. */
.mode-picker { display: flex; justify-content: center; gap: 4px; width: fit-content; margin: 0 auto 22px; padding: 4px; border: 1px solid var(--line); border-radius: 100px; background: #e5e5e7; }
.mode-picker button { border: 0; background: transparent; color: var(--muted); border-radius: 100px; padding: 9px 18px; font-size: 14px; font-weight: 500; }
.mode-picker button[aria-pressed=true] { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px #13162814; }
.mode-picker button:disabled { cursor: wait; }
.page.multiplayer { width: min(100%, 1020px); }
.players { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.multiplayer .players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.player-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 26px; }
.player-heading h2 { font-size: 15px; margin: 0; font-weight: 600; }
.shortcut { display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; min-width: 30px; padding: 2px 8px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.game-card[data-mode=single] .player-heading { justify-content: flex-end; margin: -12px 0 16px; }
.game-card[data-mode=single] .player-heading h2 { display: none; }
.quit-button { display: block; margin: 4px auto -4px; padding: 8px 16px; border: 0; background: transparent; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.quit-button:hover:not(:disabled) { color: var(--red); }
.quit-actions { display: flex; flex-direction: column; gap: 12px; }
.quit-actions .roll-button { font-size: 14px; text-transform: none; font-weight: 600; }
.face[data-result=quit] { background: #777985; border-color: #777985; box-shadow: 0 10px 0 #4b4c56, 0 16px 25px #13162812; }
.is-quit .result-copy { color: var(--red); }
.is-quit .roll-button { background: #e5e5e9; color: #777985; opacity: 1; cursor: default; }
[data-role=face-caption] { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
[data-role=reveal] { margin: 0 auto; border-color: transparent; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
[data-role=reveal]:active { transform: none; }
[data-role=reveal][aria-expanded=true] { background: var(--accent-tint); color: var(--accent); }
.rules, footer { max-width: 540px; margin-left: auto; margin-right: auto; }
@media (max-width:700px) {
  .multiplayer .players { grid-template-columns: minmax(0, 1fr); }
  .page.multiplayer { max-width: 588px; }
}
