html,body{margin:0}img{max-width:100%}

/* Fonts are embedded so the app looks the same with no internet connection */
@font-face{font-family:'Figtree';font-style:normal;font-weight:400 700;font-display:swap;src:url(/zar/fonts/figtree-latin.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:'Figtree';font-style:normal;font-weight:400 700;font-display:swap;src:url(/zar/fonts/figtree-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;}
@font-face{font-family:'Marcellus';font-style:normal;font-weight:400;font-display:swap;src:url(/zar/fonts/marcellus-latin.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:'Marcellus';font-style:normal;font-weight:400;font-display:swap;src:url(/zar/fonts/marcellus-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;}
/* Layout: one-column game table; header with menu, presets, settings, result tray; roll button pinned to the bottom. Single dark felt look with Bayterek gold. */
:root {
  --felt: #0f2e2a;
  --felt-2: #163c36;
  --felt-3: #1b4740;
  --line: #2a554d;
  --gold: #b48f4c;
  --gold-hi: #d8b46e;
  --gold-lo: #7d6131;
  --ivory: #f3ecdd;
  --muted: #9fb8b1;
  --die: #f6f1e6;
  --die-ink: #1d2b28;
  --lose: #c4473a;
  --win: #2e8b57;
  --on-mark: #ffffff;
  --on-gold: #1b1408;
  --splash: #ffffff;
  --splash-ink: #a99064;
  --scrim: rgba(4, 16, 14, .62);
  --alert: #e0664a;
  --display: "Marcellus", "Palatino Linotype", Palatino, Georgia, serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, var(--felt-2), var(--felt) 70%) fixed;
  background-color: var(--felt);
  color: var(--ivory);
  font-family: var(--body);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

/* Splash */
#splash {
  position: fixed; inset: 0; z-index: 50;
  background: var(--splash);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  transition: opacity .6s ease, visibility .6s;
}
#splash img { width: min(56vw, 260px); height: auto; animation: grow 1.4s cubic-bezier(.2,.8,.2,1) both; }
#splash .brand { font-family: var(--display); color: var(--gold); font-size: 30px; letter-spacing: .14em; animation: fade 1s .5s both; }
#splash .hint { color: var(--splash-ink); font-size: 13px; letter-spacing: .1em; text-transform: lowercase; animation: fade 1s 1.1s both; }
#splash.gone { opacity: 0; visibility: hidden; }
@keyframes grow { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* App */
.app {
  max-width: 520px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px calc(112px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 18px;
}
header { display: flex; align-items: center; gap: 12px; }
header img { width: 40px; height: auto; flex: none; }
header .titles { flex: 1; min-width: 0; }
header h1 { font-family: var(--display); font-weight: 400; font-size: 24px; margin: 0; letter-spacing: .06em; color: var(--gold-hi); }
header p { margin: 0; font-size: 13px; color: var(--muted); }
.icon-btn {
  flex: none; position: relative; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: transparent;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--felt-3); }
.icon-btn svg { width: 22px; height: 22px; }
.header-actions { flex: none; display: flex; gap: 8px; }
.badge { position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--alert); box-shadow: 0 0 0 2px var(--felt); }
.news-list { display: flex; flex-direction: column; gap: 14px; }
.news-item { border: 1px solid var(--line); border-radius: 16px; background: var(--felt); overflow: hidden; display: flex; flex-direction: column; }
.news-item img { width: 100%; max-height: 220px; object-fit: cover; display: block; background: var(--felt-3); }
.news-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.news-date { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.news-body h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--gold-hi); text-wrap: balance; }
.news-body p { margin: 0; font-size: 15px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.news-more { align-self: flex-start; margin-top: 4px; padding: 9px 14px; border-radius: 12px; background: var(--gold); color: var(--on-gold); font-weight: 700; font-size: 14px; text-decoration: none; }
.news-more:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.news-empty { color: var(--muted); font-size: 15px; text-align: center; padding: 24px 0; }

.label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }

/* Presets */
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preset {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: transparent; border: 1.5px solid var(--gold); border-radius: 16px;
  padding: 12px 14px; min-height: 72px; min-width: 0;
  transition: background .15s, transform .1s;
}
.preset:active { transform: scale(.97); }
.preset:hover { background: rgba(180,143,76,.1); }
.preset svg { flex: none; width: 42px; height: 42px; }
.preset div { min-width: 0; }
.preset b { display: block; font-weight: 700; font-size: 15px; color: var(--ivory); }
.preset span { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }
.presets.single { grid-template-columns: 1fr; }
.presets.single .preset { justify-content: center; min-height: 84px; gap: 16px; }
.presets.single .preset svg { width: 50px; height: 50px; }
.presets.single .preset b { font-size: 19px; }
.presets.single .preset span { font-size: 13px; }

/* Settings */
.settings { background: rgba(0,0,0,.18); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--felt-2); font-size: 22px; line-height: 1;
}
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper button:active:not(:disabled) { background: var(--line); }
.stepper output { min-width: 56px; text-align: center; font-family: var(--display); font-size: 30px; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--gold); height: 28px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 6px 12px; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted);
}
.chips button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--felt); font-weight: 700; }

/* Results */
.tray { border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.total-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.total-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wl { display: flex; gap: 8px; }
.wl span { padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 18px; color: var(--on-mark); font-variant-numeric: tabular-nums; }
.wl-w { background: var(--win); }
.wl-l { background: var(--lose); }
.coin { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #f6dc93, var(--gold-hi) 45%, var(--gold) 75%, var(--gold-lo));
  box-shadow: inset 0 0 0 3px rgba(125,97,49,.55), inset 0 0 0 6px rgba(246,220,147,.35), 0 3px 8px rgba(0,0,0,.35); }
.coin img { width: 26px; height: auto; filter: brightness(.42) sepia(.4); }
.coin.pop { animation: pop .45s cubic-bezier(.3,.7,.3,1) both; }
@keyframes pop { 0% { transform: scale(.3) rotateY(180deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toggle-text small { font-size: 12px; font-weight: 400; color: var(--muted); }
.total { font-family: var(--display); font-size: 56px; line-height: 1; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.what { font-size: 14px; color: var(--muted); text-align: right; }
.dice { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.die {
  width: 62px; height: 62px; border-radius: 14px;
  background: var(--die); color: var(--die-ink);
  display: grid; place-items: center; position: relative;
  font-weight: 700; font-size: 24px; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.35);
}
.die .sides { position: absolute; bottom: 3px; right: 6px; font-size: 9px; font-weight: 600; opacity: .45; }
.die.max { box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), 0 0 0 3px var(--gold-hi), 0 4px 10px rgba(0,0,0,.35); }
.die.min { opacity: .82; }
.die.big { width: 120px; height: 120px; border-radius: 26px; font-size: 54px; }
.die.big .sides { font-size: 13px; bottom: 6px; right: 10px; }
/* d6 outcome: 1-4 is a loss (L, red), 5-6 a win (W, green) */
.die.lose { background: var(--lose); color: var(--on-mark); }
.die.win { background: var(--win); color: var(--on-mark); }
.die .mark { position: absolute; top: 4px; right: 7px; font-size: 13px; font-weight: 800; line-height: 1; }
.die.big .mark { font-size: 22px; top: 8px; right: 12px; }
.rolling .die { animation: tumble .45s cubic-bezier(.3,.7,.3,1) both; }
@keyframes tumble { 0% { transform: rotate(-200deg) scale(.4); opacity: 0; } 70% { transform: rotate(12deg) scale(1.06); opacity: 1; } 100% { transform: none; } }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 18px 0; }
.error { text-align: center; color: var(--ivory); background: rgba(160,60,40,.35); border-radius: 12px; font-size: 14px; padding: 12px; }

.history { display: flex; flex-direction: column; gap: 6px; }
.history ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.history li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); padding: 6px 0; border-bottom: 1px dashed var(--line); }
.history li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.history li b { color: var(--ivory); font-variant-numeric: tabular-nums; }

/* Bottom roll bar */
.rollbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: 12px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(15,46,42,0), var(--felt) 30%);
}
.rollbar-inner { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.summary { text-align: center; font-size: 13px; color: var(--muted); }
.summary b { color: var(--ivory); }
#roll {
  width: 100%; border: 0; border-radius: 18px; padding: 16px; font-size: 20px; font-weight: 700; letter-spacing: .04em;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: var(--on-gold);
  box-shadow: 0 6px 0 var(--gold-lo), 0 10px 24px rgba(0,0,0,.35);
  transition: transform .08s, box-shadow .08s;
}
#roll:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--gold-lo), 0 4px 12px rgba(0,0,0,.35); }

/* Menu sheet */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 88%; overflow-y: auto;
  background: var(--felt-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  padding-top: 10px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 18px;
  animation: up .25s ease-out both;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); align-self: center; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { font-family: var(--display); font-weight: 400; font-size: 22px; margin: 0; color: var(--gold-hi); }
#menuClose, #newsClose { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-size: 20px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--felt); }
.toggle-row span { font-size: 15px; font-weight: 600; }
.switch { flex: none; position: relative; width: 52px; height: 30px; border-radius: 999px; border: 0; padding: 0; background: var(--line); transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--ivory); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--gold); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.switch:disabled { opacity: .35; cursor: not-allowed; }
.toggle-text .lock { color: var(--gold-hi); }
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.links a { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1.5px solid var(--gold); border-radius: 14px; color: var(--ivory); text-decoration: none; font-size: 14px; font-weight: 600; min-width: 0; }
.links a:active { background: rgba(180,143,76,.15); }
.links a:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.links svg { flex: none; width: 26px; height: 26px; }
.links span { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.links small { font-size: 12px; font-weight: 400; color: var(--muted); overflow-wrap: anywhere; }
.langs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.langs button {
  border: 1px solid var(--line); background: var(--felt); border-radius: 12px;
  padding: 12px 6px; font-size: 15px; font-weight: 600; color: var(--muted);
}
.langs button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.about { display: flex; flex-direction: column; gap: 10px; }
.about-brand { display: flex; align-items: center; gap: 12px; }
.about-brand img { width: 48px; height: auto; }
.about-brand b { font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--ivory); display: block; }
.about-brand span { font-size: 13px; color: var(--muted); }
.about p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ivory); max-width: 62ch; }
.about ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.about li { display: flex; gap: 10px; font-size: 14px; line-height: 1.45; color: var(--ivory); }
.about li::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 2px; background: var(--gold); transform: rotate(45deg); }

@media (prefers-reduced-motion: reduce) {
  .coin.pop { animation: none; }
  #splash img, #splash .brand, #splash .hint, .rolling .die, .sheet { animation: none; }
}
