@font-face {
  font-family: "Faculty Glyphic";
  src: url("./assets/fonts/faculty-glyphic-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("./assets/fonts/atkinson-hyperlegible-next-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #21140f;
  --muted: #d5b99b;
  --text: #fcf0de;
  --gold: #f0c17b;
  --wood-grain: repeating-linear-gradient(2deg, transparent 0 4px, #edb78c0d 5px, transparent 6px 10px, #1a0b0860 12px, transparent 14px 19px);
  --lacquer: var(--wood-grain), linear-gradient(174deg, #65412d, #473022 55%, #382319);
  --scroll-thumb: #b78651;
  --scroll-track: #332216;
  --inset-panel: #593b28;
  --inset-edge: #95704b;
  --tool-face: linear-gradient(#6b4934, #4a2f21);
  --tool-hover: #805634;
  --tool-edge: #9c7149;
  --frame-filter: drop-shadow(0 2px 2px #1e110eae);
  --display: "Faculty Glyphic", Georgia, serif;
  --body-font: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  font-family: var(--body-font);
  color: var(--text);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  isolation: isolate;
  background: var(--bg);
}
body.midnight {
  --bg: #131d1c;
  --muted: #c7c1a5;
  --lacquer: var(--wood-grain), linear-gradient(174deg, #3f4237, #302e25 55%, #252721);
  --scroll-thumb: #9d8c65;
  --scroll-track: #252a23;
  --inset-panel: #33382f;
  --inset-edge: #7e785d;
  --tool-face: linear-gradient(#464739, #2d342c);
  --tool-hover: #515345;
  --tool-edge: #857853;
  --frame-filter: brightness(.68) saturate(.56) hue-rotate(19deg) drop-shadow(0 2px 3px #070d0eeb);
}
body::before, body::after { content: ""; position: fixed; inset: 0; pointer-events: none; }
body::before {
  z-index: -2;
  background:
    linear-gradient(0deg, #21130cbd, #46261718 44%, #24140f2e),
    url("./assets/palace-pharmacy-room.webp") center / cover;
  filter: sepia(.39) saturate(1.1);
}
body::after {
  z-index: -1;
  opacity: 0;
  background:
    linear-gradient(0deg, #081314a3, transparent 50%, #06121424),
    url("./assets/palace-midnight-room.webp") center / cover;
  transition: opacity .95s ease;
}
body.midnight::after { opacity: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid #ffd591; outline-offset: 4px; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 21px; height: 21px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  background: var(--lacquer);
  border-bottom: 2px solid var(--tool-edge);
  box-shadow: 0 2px 0 #342014, 0 4px 18px #1c100a80;
}
.topbar-inner {
  width: min(100% - 64px, 1192px);
  min-height: 77px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-inline: auto;
}
.brand { display: flex; align-items: center; gap: 12px; color: #faecd9; font: 400 1.5rem/1.15 var(--display); }
.brand img {
  flex: none;
  object-fit: contain;
  padding: 2px;
  border: 1px solid #ab7753;
  border-radius: 7px;
  background: radial-gradient(ellipse at 50% 45%, #776044, #3e2926 78%);
  box-shadow: inset 0 0 0 2px #332025, 0 2px 2px #1c1118;
}
.top-actions { display: flex; align-items: center; gap: 9px; }
.wallet {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 137px;
  min-height: 45px;
  padding: 5px 15px 5px 10px;
  border: 1px solid var(--tool-edge);
  border-radius: 6px;
  background: var(--tool-face);
  box-shadow: inset 0 0 0 2px #1d11075c;
}
.wallet-coin { width: 28px; height: 28px; flex: none; object-fit: contain; filter: drop-shadow(0 2px 1px #1a1017); }
.wallet strong { font-size: 1rem; font-variant-numeric: tabular-nums; line-height: 1.12; }
.small-label { display: block; color: var(--muted); font-size: .8rem; font-weight: 650; letter-spacing: .025em; }
.wallet .small-label { font-size: .76rem; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: #f1dcc0;
  border: 1px solid var(--tool-edge);
  border-radius: 6px;
  background: var(--tool-face);
}
.icon-button:hover { color: var(--gold); background: var(--tool-hover); border-color: var(--gold); }
.paytable {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  padding-inline: 11px;
  font-size: .875rem;
  font-weight: 700;
  white-space: nowrap;
}
.paytable .icon { width: 18px; height: 18px; }

.layout {
  width: min(100% - 64px, 1192px);
  margin: 29px auto 0;
  display: grid;
  grid-template-columns: minmax(282px, 350px) minmax(0, 1fr);
  gap: 18px 22px;
}
.wood-frame {
  --frame-depth: 26px;
  position: relative;
  isolation: isolate;
}
.wood-frame::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 4;
  pointer-events: none;
  border: var(--frame-depth) solid transparent;
  border-image: url("./assets/carved-cabinet.webp") 135 stretch;
  filter: var(--frame-filter);
  transition: filter .65s ease;
}
.portrait {
  min-height: 590px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid #573128;
  border-radius: 7px;
  background: var(--lacquer);
  box-shadow: 0 6px 0 #301a1c, 0 16px 45px #1008158c;
}
.portrait-art { position: absolute; z-index: -2; inset: 0; }
.portrait-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 47%; }
.portrait-midnight { opacity: 0; transition: opacity .75s ease; }
body.midnight .portrait-midnight { opacity: 1; }
.portrait-reaction { opacity: 0; transition: opacity .22s ease; }
body:not(.midnight) .portrait[data-reaction="glance"] .day-glance,
body:not(.midnight) .portrait[data-reaction="excited"] .day-excited,
body.midnight .portrait[data-reaction="glance"] .midnight-glance,
body.midnight .portrait[data-reaction="excited"] .midnight-excited { opacity: 1; }
.portrait-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(0deg, #2d1d14 0%, #2c19119c 15%, transparent 38%),
    linear-gradient(180deg, #251810b8 0%, #341e1144 25%, transparent 43%);
}
body.midnight .portrait-art::after {
  background: linear-gradient(0deg, #191c1b 0%, transparent 32%), linear-gradient(180deg, #13231c89 0%, transparent 44%);
}
.cabinet-hinges { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.cabinet-hinges span, .cabinet-hinges::after {
  position: absolute;
  width: 17px;
  height: 36px;
  border: 1px solid #4c3024;
  border-radius: 3px;
  background:
    radial-gradient(circle at 50% 5px, #5f3b29 0 1.4px, transparent 2.3px),
    radial-gradient(circle at 50% calc(100% - 5px), #5f3b29 0 1.4px, transparent 2.3px),
    linear-gradient(90deg, #805135, #e9b579 42%, #aa6e47 77%, #71462f);
  box-shadow: inset 0 1px #f7dca2a8, 0 2px 4px #1e1017a4;
}
.cabinet-hinges span { top: 32%; left: 8px; }
.cabinet-hinges span:nth-child(2) { top: auto; bottom: 25%; }
.cabinet-hinges::after { content: ""; right: 8px; top: 52%; height: 31px; }
body.midnight .cabinet-hinges { filter: brightness(.68) saturate(.64); }
.portrait-top {
  margin: 23px 20px 0;
  padding: 17px 7px 19px;
  border-block: 1px solid var(--tool-edge);
  background:
    radial-gradient(ellipse at 48% 9%, #8f563543, transparent 73%),
    var(--lacquer);
  box-shadow: inset 0 2px #1e1009bb, inset 0 -2px #1e10099f, 0 5px 6px #1e1009a8;
  text-align: center;
}
h1 { margin: 0; font: 400 clamp(2rem, 4.1vw, 3.05rem)/1.1 var(--display); text-shadow: 0 4px 15px #160d13; }
h1 em { display: block; font-style: normal; color: #f6c77e; }
.bonus-card {
  display: grid;
  text-align: left;
  grid-template-columns: 48px 1fr 16px;
  align-items: center;
  gap: 9px;
  margin: 16px 25px 25px;
  padding: 8px 9px;
  min-height: 76px;
  border: 1px solid var(--tool-edge);
  background: var(--lacquer);
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px #25171c, inset 0 0 0 3px #a6744c57, 0 4px 0 #28191d, 0 8px 20px #180e18a8;
}
.bonus-card:hover { border-color: var(--gold); }
.bonus-card strong { display: block; margin-bottom: 3px; color: #f9d18f; font: 400 1.15rem/1.2 var(--display); }
.bonus-description { display: block; color: #ead4b8; font-size: .88rem; line-height: 1.32; }
.bonus-image {
  position: relative;
  display: grid;
  place-items: end center;
  aspect-ratio: 1;
  padding: 1px 3px 4px;
  border: 1px solid #9a6c49;
  border-radius: 3px 3px 0 0;
  background: var(--wood-grain), radial-gradient(ellipse at 50% 70%, #6a5036, #33231f 82%);
  box-shadow: inset 3px 3px 4px #2b1515, inset 0 0 0 1px #39211c;
}
.bonus-image::after {
  content: "";
  position: absolute;
  inset: auto -2px -2px;
  height: 7px;
  pointer-events: none;
  border: 1px solid #613b2b;
  background: linear-gradient(#d2a16a, #9b6945 40%, #60402e 43% 100%);
  box-shadow: 0 2px 2px #27141b;
}
.bonus-image img { width: 100%; height: 100%; min-height: 0; object-fit: contain; filter: drop-shadow(0 2px 1px #190e19aa); }
.bonus-icon { color: #edc486; width: 17px; height: 17px; }

.machine {
  --frame-depth: 21px;
  --gap: 4px;
  --tile-height: clamp(47px, 6.75vh, 66px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 23px 24px 23px;
  background: var(--wood-grain), linear-gradient(156deg, #5b3929, #41271d 68%, #38241a);
  border: 1px solid #573128;
  border-radius: 7px;
  box-shadow: 0 6px 0 #301a1c, 0 16px 45px #1008158c;
}
body.midnight .machine { background: var(--wood-grain), linear-gradient(156deg, #303d35, #252d29 66%, #22231e); }
.cabinet-title {
  --paper: linear-gradient(98deg, #ba8855, #e7bb81 9%, #f5dcae 52%, #e8c493 89%, #b77e4e);
  display: flex;
  position: relative;
  isolation: isolate;
  align-self: center;
  align-items: center;
  min-width: 0;
  gap: clamp(6px, 1.5vw, 11px);
  margin: 3px 0 12px;
  padding: 8px clamp(12px, 2vw, 20px);
  color: #49271c;
  filter: drop-shadow(0 2px 2px #1b0f09c2);
}
.cabinet-title::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  clip-path: polygon(2% 5%, 12% 2%, 35% 4%, 57% 0, 76% 3%, 98% 1%, 99% 25%, 98.5% 53%, 100% 80%, 98% 96%, 83% 98%, 60% 96%, 33% 100%, 1% 97%, 0 76%, 1% 51%, 0 24%);
  background:
    repeating-linear-gradient(3deg, #6c53321a 0 1px, transparent 1px 4px, #fff2cf48 5px 6px, transparent 7px 10px),
    radial-gradient(ellipse at 83% 105%, #85522c35, transparent 56%),
    var(--paper);
}
.cabinet-stamp {
  display: grid;
  place-items: center;
  width: 19px;
  aspect-ratio: 1;
  flex: none;
  border: 1px solid #8c3d30;
  border-radius: 2px;
  color: #ffe2a9;
  background: #9b3c2e;
  box-shadow: inset 0 0 0 1px #e9b37cab;
  transform: rotate(-6deg);
}
.cabinet-stamp .icon { width: 13px; height: 13px; }
.cabinet-title h2 {
  margin: 0;
  font: 400 clamp(1.05rem, 2.5vw, 1.48rem)/1.2 var(--display);
  text-wrap: balance;
}
body.midnight .cabinet-title {
  --paper: linear-gradient(98deg, #888160, #ab9b77 9%, #d5c9a3 52%, #c1ae82 89%, #8b7658);
  color: #35291d;
}
body.midnight .cabinet-stamp { background: #774034; border-color: #67372c; }

.board-frame {
  --drawer-top: #895e45;
  --drawer-bottom: #623e2c;
  --drawer-alt-top: #815239;
  --drawer-alt-bottom: #583927;
  --drawer-edge: #a47857;
  --drawer-shadow: #3b2318;
  --drawer-marked: radial-gradient(ellipse at center, #83543a, #603c26 74%);
  --drawer-boosted: radial-gradient(ellipse at center, #a86d40, #674224 77%);
  position: relative;
  isolation: isolate;
  padding: 13px;
  border: 1px solid #c39a6a;
  border-radius: 9px;
  background:
    repeating-linear-gradient(2deg, transparent 0 5px, #2c181d22 6px 7px),
    linear-gradient(155deg, #986443, #623c31 24%, #4b2b2a 60%, #78503a);
  box-shadow: inset 0 0 0 3px #3d2326, inset 0 0 0 5px #d39b694a, 0 5px 0 #301c21, 0 8px 19px #160b16;
}
.board-frame::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 2;
  border-radius: 6px;
  pointer-events: none;
  border: 1px solid #edb77b52;
  background:
    radial-gradient(circle at 2px 2px, #efc38e 0 1px, transparent 2px),
    radial-gradient(circle at calc(100% - 2px) 2px, #efc38e 0 1px, transparent 2px),
    radial-gradient(circle at 2px calc(100% - 2px), #efc38e 0 1px, transparent 2px),
    radial-gradient(circle at calc(100% - 2px) calc(100% - 2px), #efc38e 0 1px, transparent 2px);
}
.board-frame.bonus-active {
  --drawer-top: #47605a;
  --drawer-bottom: #303e38;
  --drawer-alt-top: #3d554f;
  --drawer-alt-bottom: #2e3b35;
  --drawer-edge: #788e7d;
  --drawer-shadow: #1e2a28;
  --drawer-marked: radial-gradient(ellipse at center, #5f6250, #444338 74%);
  --drawer-boosted: radial-gradient(ellipse at center, #867052, #514636 77%);
  border-color: #9b9972;
  background: linear-gradient(155deg, #526355, #2d3732 55%, #47564a);
  box-shadow: inset 0 0 0 3px #29332a, inset 0 0 0 5px #b5b47b43, 0 4px 0 #212923, 0 0 22px #a9bc7940;
}
.board { position: relative; overflow: hidden; border-radius: 4px; display: grid; gap: var(--gap); grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: var(--tile-height); background: var(--drawer-shadow); }
.tile {
  --tile-top: var(--drawer-top);
  --tile-bottom: var(--drawer-bottom);
  position: relative;
  display: grid;
  justify-items: center;
  align-items: start;
  min-width: 0;
  border: 1px solid var(--drawer-edge);
  border-radius: 4px;
  background:
    repeating-linear-gradient(1deg, transparent 0 7px, #190f1321 8px, transparent 10px),
    linear-gradient(180deg, var(--tile-top), var(--tile-bottom));
  box-shadow: inset 0 1px #fde0a72e, inset 0 -2px var(--drawer-shadow);
}
.tile:nth-child(2n) { --tile-top: var(--drawer-alt-top); --tile-bottom: var(--drawer-alt-bottom); }
.tile::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid #29181f44;
  border-radius: 2px;
  pointer-events: none;
}
.tile::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: clamp(10px, 24%, 18px);
  height: 4px;
  transform: translateX(-50%);
  border: 1px solid #39212a;
  border-radius: 2px;
  background: linear-gradient(#e6bd85, #9b673e);
  box-shadow: 0 1px 1px #322024, 0 0 0 1px #c78c505e;
  opacity: .9;
}
.tile.scatter {
  background: radial-gradient(ellipse at center, #57794e, #344939 75%);
  border-color: #a2bd6a;
  box-shadow: inset 0 0 13px #9cd28844, inset 0 -2px #233727;
}
.tile.marked { border-color: #b48862; background: var(--drawer-marked); }
.tile.boosted { border-color: #e2b678; background: var(--drawer-boosted); }
.tile.winning {
  z-index: 3;
  border-color: #ffde94;
  background: radial-gradient(ellipse at center, #a26e46, #724728 73%);
  box-shadow: inset 0 0 10px #ffb44c60, 0 0 12px #ffb34b75;
}
.glyph {
  position: relative;
  z-index: 1;
  width: min(90%, var(--tile-height));
  height: calc(var(--tile-height) - 9px);
  margin-top: 1px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 3px 3px #1c10238c);
}
.badge {
  z-index: 4;
  position: absolute;
  right: 3px;
  top: 3px;
  padding: 1px 4px;
  border: 1px solid #d6a360;
  border-radius: 4px;
  color: #ffe1a1;
  background: #543521;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.1;
}
.badge.mark { padding: 0; width: 6px; height: 6px; border: 0; top: 6px; right: 6px; transform: rotate(45deg); border-radius: 1px; background: #e1a56d; box-shadow: 0 0 4px #ffb25d8c; }
.board.clearing .winning .glyph { animation: pop 180ms ease-in both; }
@keyframes pop { 45% { opacity: 1; transform: scale(1.27); filter: brightness(1.65); } 100% { opacity: 0; transform: scale(.5); } }
.round-banner {
  position: absolute;
  z-index: 5;
  inset: 50% auto auto 50%;
  width: max-content;
  max-width: calc(100% - 26px);
  padding: 8px 14px 10px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border: 1px solid #e1a772;
  background: var(--lacquer);
  color: #ffe3b7;
  border-radius: 10px;
  box-shadow: 0 6px 24px #0f0718c7;
  text-align: center;
  font: 400 1.15rem/1.2 var(--display);
}

.round-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 41px;
  padding: 6px 1px;
}
.mode { display: inline-flex; flex: none; align-items: center; gap: 6px; min-height: 22px; padding: 2px 7px; border-radius: 5px; border: 1px solid #997049; color: #f3d6ad; background: #604028; font-size: .75rem; font-weight: 700; }
.mode.bonus { color: #e1f0c8; border-color: #879c79; background: #384d3b; }
.round-status p { margin: 0; color: #e8cda9; font-size: .9rem; line-height: 1.25; }
.controls {
  display: grid;
  grid-template-columns: minmax(140px, .9fr) minmax(100px, .7fr) minmax(142px, 1.08fr);
  gap: 11px;
  margin-top: auto;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid var(--tool-edge);
  background: var(--lacquer);
  box-shadow: inset 0 0 0 2px #24161b, 0 2px 0 #25171d;
}
.stake, .winnings { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 6px; }
.bet-control { display: grid; grid-template-columns: 33px 1fr 33px; gap: 2px; align-items: center; }
.bet-control strong, .winnings strong { font-size: 1.14rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.bet-control strong { text-align: center; }
.winnings { border-left: 1px solid #754f3d; padding-left: 14px; }
.winnings strong { color: #f8d294; overflow-wrap: anywhere; }
.step-button { width: 33px; height: 30px; display: inline-grid; place-items: center; padding: 0; background: var(--tool-face); border: 1px solid var(--tool-edge); color: #f8e1c7; border-radius: 4px; }
.step-button .icon { width: 15px; height: 15px; stroke-width: 2; }
.step-button:hover:not(:disabled) { background: var(--tool-hover); border-color: var(--gold); }
.step-button:disabled { opacity: .45; }

.ornate-control {
  --control-ink: #3b2416;
  --control-rim: #e4a96a;
  --control-glint: #fff0be;
  --control-shadow: #793f29;
  --control-pin: #714633;
  --control-face: linear-gradient(167deg, #fff0b6, #f4c37a 49%, #d19356 100%);
  position: relative;
  isolation: isolate;
  border: 1px solid var(--control-rim);
  border-bottom-color: var(--control-shadow);
  border-radius: 5px;
  color: var(--control-ink);
  background:
    radial-gradient(circle at 8px 8px, var(--control-pin) 0 1px, var(--control-glint) 1.4px 2px, transparent 2.5px),
    radial-gradient(circle at calc(100% - 8px) 8px, var(--control-pin) 0 1px, var(--control-glint) 1.4px 2px, transparent 2.5px),
    radial-gradient(circle at 8px calc(100% - 8px), var(--control-pin) 0 1px, var(--control-glint) 1.4px 2px, transparent 2.5px),
    radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), var(--control-pin) 0 1px, var(--control-glint) 1.4px 2px, transparent 2.5px),
    repeating-linear-gradient(172deg, #fff9d518 0 1px, transparent 2px 9px),
    var(--control-face);
  box-shadow: inset 0 0 0 2px var(--control-glint), 0 3px 0 var(--control-shadow), 0 5px 12px #1b101758;
  text-shadow: 0 1px #fff3cb90;
}
.ornate-control::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 4px;
  border: 1px solid var(--control-pin);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px #fff5d55c;
  pointer-events: none;
}
.ornate-control:hover:not(:disabled) { filter: brightness(1.09); }
.ornate-control:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 0 0 2px var(--control-glint), 0 1px 0 var(--control-shadow);
}
.spin {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  min-height: 59px;
  font: 400 1.5rem/1.2 var(--display);
}
.spin > span { white-space: nowrap; }
.spin:disabled { filter: saturate(.68); }
.spin.auto-spin {
  --control-ink: #122e31;
  --control-rim: #8ccaa5;
  --control-glint: #d8f5bb;
  --control-shadow: #244f49;
  --control-pin: #356b58;
  --control-face: linear-gradient(167deg, #dbf5c4, #a1d5ae 47%, #629d88 100%);
}
.spin.auto-spin:disabled { filter: none; }
.spin .icon { stroke-width: 2.2; }
.spin kbd { color: #5a3620; background: #fff0c578; border: 1px solid #9d623366; padding: 4px 5px; border-radius: 4px; font: 650 .68rem/1.1 var(--body-font); letter-spacing: .04em; }
.spin.spinning .icon { animation: rotate 1.2s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

.footer {
  grid-column: 1 / -1;
  padding: 3px 3px 18px;
  color: var(--muted);
  font-size: .82rem;
}
.demo-dot { display: inline-block; width: 6px; height: 6px; margin-right: 4px; vertical-align: .12em; border-radius: 50%; background: #caa477; }
dialog {
  width: min(100% - 26px, 740px);
  max-height: min(90dvh, 750px);
  padding: 0;
  border: 1px solid #9a7765;
  border-radius: 8px;
  background: var(--lacquer);
  color: var(--text);
  box-shadow: 0 22px 75px #0c0810ce;
  overscroll-behavior: contain;
}
dialog::backdrop { background: #100b08bd; backdrop-filter: blur(4px); }
dialog:not(.brew-dialog), .table-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
.dialog-top { position: sticky; z-index: 1; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--tool-edge); background: var(--lacquer); }
.dialog-top h2 { margin: 0; color: #ffe3b6; font: 400 1.6rem/1.2 var(--display); }
.dialog-content { padding: 18px 20px 22px; }
.dialog-content h3 { color: #f4ca8b; margin: 0 0 5px; font: 400 1.15rem/1.2 var(--display); }
.dialog-content p { color: #ebd7b9; margin: 0 0 9px; font-size: 1rem; line-height: 1.5; }
.rule-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.rule-grid section, .bonus-rules { padding: 12px; border-radius: 6px; border: 1px solid var(--inset-edge); background: var(--inset-panel); }
.rule-grid p, .bonus-rules p { margin-bottom: 0; }
.bonus-rules { margin: 12px 0 17px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 7px; border-bottom: 1px solid var(--inset-edge); text-align: right; white-space: nowrap; }
th:first-child { text-align: left; }
thead th { color: #e2b991; font-weight: 700; }
.ingredient { display: flex; gap: 8px; align-items: center; }
.ingredient img { width: 36px; height: 36px; object-fit: contain; }
.ingredient a { display: block; margin-top: 2px; color: #e6c698; font-size: .75rem; font-weight: 500; text-underline-offset: 2px; }
.reset-area { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 17px; }
.reset-area p { margin: 0; font-size: .85rem; }

@media (max-width: 960px) {
  .layout, .topbar-inner { width: calc(100% - 36px); }
  .layout { grid-template-columns: minmax(238px, 31%) minmax(0, 1fr); gap: 13px; }
  .portrait { --frame-depth: 20px; min-height: 0; }
  .portrait-top { margin: 18px 17px 0; padding-inline: 7px; }
  h1 { font-size: clamp(1.75rem, 3.7vw, 2.3rem); }
  .bonus-card { margin-inline: 20px; }
  .machine { --frame-depth: 14px; padding: 16px; }
  .controls { gap: 6px; grid-template-columns: minmax(119px, .8fr) minmax(67px, .62fr) minmax(124px, 1fr); }
  .spin { gap: 6px; padding-inline: 8px; font-size: clamp(1.04rem, 2.5vw, 1.34rem); }
  .spin .icon { width: 18px; height: 18px; }
  .spin kbd { display: none; }
}

@media (max-width: 680px) {
  .topbar-inner { width: calc(100% - 24px); min-height: 64px; gap: 8px; padding-block: 8px; }
  .brand { flex: 1 0 36px; container: brand / inline-size; gap: 7px; }
  .brand img { width: 36px; height: 36px; }
  .brand span { font-size: clamp(1rem, 11cqi, 1.19rem); white-space: nowrap; }
  .top-actions { min-width: 0; gap: 5px; margin-inline-start: auto; }
  .wallet { min-width: 0; min-height: 40px; padding: 4px 7px; gap: 4px; }
  .wallet > div { min-width: 0; }
  .wallet-coin { width: 19px; height: 19px; }
  .wallet strong { font-size: .88rem; overflow-wrap: anywhere; }
  .wallet .small-label { font-size: .7rem; }
  .top-actions .icon-button { flex: none; width: 35px; height: 39px; }
  .top-actions .icon-button .icon { width: 17px; height: 17px; }
  .paytable { padding-inline: 0; }
  .paytable span { display: none; }
  .layout {
    grid-template-columns: minmax(0, 3fr) minmax(0, 7fr);
    width: calc(100% - 16px);
    margin-top: 12px;
    gap: 10px clamp(6px, 2vw, 11px);
  }
  .portrait { --frame-depth: clamp(7px, 2vw, 13px); }
  .portrait-art img { object-position: 55% 47%; }
  .cabinet-hinges { display: none; }
  .portrait-top { margin: clamp(7px, 1.8vw, 12px) clamp(5px, 1.4vw, 10px) 0; padding: 7px 3px 8px; }
  h1 { font-size: clamp(.66rem, 3.4vw, 1.43rem); }
  .bonus-card {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    min-height: 44px;
    gap: 4px;
    margin: 6px clamp(5px, 1.4vw, 10px) clamp(7px, 1.8vw, 12px);
    padding: 5px 3px;
    text-align: center;
  }
  .bonus-image { width: clamp(21px, 7vw, 35px); padding: 0 2px 2px; }
  .bonus-image::after { height: 4px; }
  .bonus-card strong { margin: 0; font: 700 clamp(.65rem, 2.65vw, .86rem)/1.2 var(--body-font); }
  .bonus-icon, .bonus-description { display: none; }
  .machine { --frame-depth: clamp(7px, 1.65vw, 11px); --gap: clamp(2px, .55vw, 3px); padding: clamp(7px, 1.8vw, 11px) clamp(5px, 1.5vw, 9px); }
  .cabinet-title { max-width: 100%; margin-block: 2px 7px; padding: 5px clamp(9px, 2vw, 14px); }
  .cabinet-title h2 { font-size: clamp(.85rem, 3.5vw, 1.35rem); }
  .cabinet-stamp { width: clamp(14px, 3.8vw, 19px); }
  .cabinet-stamp .icon { width: 72%; height: auto; aspect-ratio: 1; }
  .board-frame { padding: clamp(4px, 1.4vw, 8px); border-radius: 7px; }
  .board-frame::before { inset: 2px; }
  .board { grid-auto-rows: auto; }
  .tile { aspect-ratio: 1; min-height: 0; border-radius: 3px; }
  .tile::before { inset: 1px; }
  .tile::after { bottom: 2px; width: max(5px, 24%); height: clamp(2px, .55vw, 3px); }
  .glyph {
    position: absolute;
    inset: 1px auto auto 1px;
    width: calc(100% - 2px);
    height: calc(100% - 4px);
    margin: 0;
  }
  .badge { top: 1px; right: 1px; padding-inline: 1px; font-size: clamp(.52rem, 1.8vw, .66rem); }
  .badge.mark { top: 3px; right: 3px; width: 4px; height: 4px; }
  .round-status { min-height: 36px; flex-wrap: wrap; gap: 3px 6px; }
  .round-status p { flex: 1 1 6rem; min-width: 0; font-size: .8rem; }
  .controls { gap: 6px; padding: 6px; grid-template-columns: minmax(100px, .9fr) minmax(59px, .6fr) minmax(92px, 1.05fr); }
  .stake { padding-inline: 0; }
  .winnings { padding-inline: 7px 0; }
  .bet-control { grid-template-columns: 27px 1fr 27px; }
  .bet-control strong, .winnings strong { font-size: .97rem; }
  .step-button { width: 27px; height: 28px; }
  .spin { gap: 4px; padding-inline: 6px; min-height: 50px; font-size: clamp(.875rem, 3.8vw, 1.15rem); }
  .spin .icon { width: clamp(14px, 4vw, 17px); height: auto; aspect-ratio: 1; }
  .footer { font-size: .74rem; }
  .rule-grid { grid-template-columns: 1fr; }
  .dialog-top { padding-inline: 12px; }
  .dialog-content { padding-inline: 12px; }
}

@container brand (width < 130px) {
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

@media (max-width: 480px) {
  .controls { grid-template-columns: minmax(106px, 1.52fr) minmax(0, 1fr); }
  .bet-control { grid-template-columns: 27px minmax(0, 1fr) 27px; }
  .bet-control strong, .winnings strong { font-size: clamp(.84rem, 3.5vw, .97rem); }
  .spin { grid-column: 1 / -1; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; }
  body::after, .wood-frame::before, .portrait-midnight, .portrait-reaction { transition: none; }
}
