:root {
  --bg: #0c1f1a;
  --panel: #1c2a2c;
  --panel-2: #26383b;
  --edge: #3f5659;
  --text: #ffffff;
  --muted: #9fb5b3;
  --gold: #f7c548;
  --blue: #0a93f5;   --blue-d: #0561a6;
  --red: #fe5048;    --red-d: #a8302b;
  --orange: #ff9a1f; --orange-d: #b0620a;
  --green: #2fbf7f;  --green-d: #1a7a50;
  --grey: #5b6d70;   --grey-d: #37474a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  overflow: hidden; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  font-family: 'Silkscreen', ui-monospace, monospace;
  letter-spacing: -0.02em;
}
body { position: fixed; inset: 0; }

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0; transition: opacity .3s;
  background: linear-gradient(to top, rgba(230, 40, 30, .55), transparent 28%);
}
.zones { position: fixed; inset: 0; z-index: 5; pointer-events: none; font-size: 13px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.zones.fade { animation: zonesfade 3.2s ease-in forwards; }
.zones .z { position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.5; border: 2px dashed rgba(255,255,255,.55); background: rgba(12,22,24,.28); border-radius: 14px; }
.zones .l { left: 4px; top: 30%; width: calc(30% - 6px); bottom: calc(var(--zb) + 4px); }
.zones .m { left: 30%; width: 40%; top: 30%; bottom: calc(var(--zb) + 4px); }
.zones .r { right: 4px; top: 30%; width: calc(30% - 6px); bottom: calc(var(--zb) + 4px); }
.zones .b { left: 4px; right: 4px; bottom: 4px; height: calc(var(--zb) - 4px); align-items: flex-start; padding-top: 10px; }
@keyframes zonesfade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }

/* ---------- buttons (Archer's Casino house style, shared with Blackjack) ---------- */
.btn {
  --c: var(--grey); --cd: var(--grey-d);
  font-weight: 700; color: #fff; border: 0; border-radius: 11px;
  height: 54px; padding: 0 14px; font-size: 18px; letter-spacing: 0;
  background: var(--c); box-shadow: 0 5px 0 var(--cd);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .3);
  transition: transform .06s, box-shadow .06s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--cd); }
.btn:disabled { filter: grayscale(1) brightness(.6); cursor: default; }
.btn.blue { --c: var(--blue); --cd: var(--blue-d); }
.btn.red { --c: var(--red); --cd: var(--red-d); }
.btn.green { --c: var(--green); --cd: var(--green-d); }
.btn.grey { --c: var(--grey); --cd: var(--grey-d); }
.btn.wide { width: 100%; }
.btn.play { width: 100%; height: 64px; font-size: 24px; }
.btn.play small { display: block; font-size: 12px; margin-top: 2px; opacity: .85; }
.btn.play:has(small:not(:empty)) { height: auto; padding: 10px 0 12px; }

.mini {
  border: 0; border-radius: 8px; background: rgba(12, 22, 24, .78); color: var(--muted);
  font-size: 11px; padding: 7px 9px; box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
.sound { position: fixed; z-index: 30; right: max(10px, env(safe-area-inset-right)); bottom: calc(10px + var(--safe-b)); }
.sound[aria-pressed="true"] { color: var(--gold); }
body.playing .sound { display: none; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.card {
  position: absolute; background: rgba(12, 22, 24, .82); border-radius: 14px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .35); padding: 10px 12px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.hud-left { left: max(10px, env(safe-area-inset-left)); top: calc(10px + var(--safe-t)); min-width: 168px; }
.hud-right { right: max(10px, env(safe-area-inset-right)); top: calc(10px + var(--safe-t)); min-width: 150px; font-size: 10px; }
.lbl { font-size: 10px; color: var(--muted); }
.lbl.sub { margin-top: 4px; }
.pay {
  font-size: clamp(28px, 8.6vw, 44px); font-weight: 700; color: var(--gold); line-height: 1.05;
  text-shadow: 0 3px 0 #8a5a00, 0 0 18px rgba(247, 197, 72, .35); display: inline-block; transform-origin: left center;
}
.pay.locked { color: #c9d6d4; text-shadow: 0 3px 0 rgba(0,0,0,.5); opacity: .7; }
.pay.pop { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
.profit { font-size: 15px; font-weight: 700; color: #7ff0b8; }
.profit.neg { color: #ff9b94; }
.profit.muted { color: var(--muted); font-size: 11px; font-weight: 400; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.kv span { color: var(--muted); }
.kv b { color: #fff; font-size: 12px; }
.kv.next b { color: var(--gold); }

.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: calc(12px + var(--safe-b));
  display: flex; justify-content: center; gap: 8px; padding: 0 12px;
}
.snd { pointer-events: auto; width: 58px; height: 70px; font-size: 12px; line-height: 1.1; padding: 0; flex: none; }
.snd small { font-size: 10px; opacity: .8; }
.snd.on small { color: var(--gold); opacity: 1; }
.cash {
  pointer-events: auto; flex: 1; max-width: 420px; min-width: 0; height: 70px; font-size: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
}
.cash small { font-size: 11px; opacity: .85; font-weight: 400; }
.cash:not(:disabled) { animation: glow 1.6s ease-in-out infinite; }
.cash.hot:not(:disabled) { animation: glow .7s ease-in-out infinite; }

.toast {
  position: absolute; left: 50%; top: 24%; transform: translateX(-50%);
  background: rgba(12, 22, 24, .88); color: #fff; border-radius: 12px; padding: 10px 16px; font-size: 14px;
  text-align: center; box-shadow: 0 4px 0 rgba(0, 0, 0, .4); width: max-content; max-width: min(92vw, 440px);
}
.toast small { font-size: 11px; color: var(--muted); }
.toast b { color: var(--gold); }
.toast.big { font-size: 20px; padding: 12px 20px; animation: drop .45s cubic-bezier(.2, 1.4, .4, 1); }
.toast.warn { background: rgba(140, 20, 16, .9); }

.decide {
  position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%);
  width: min(420px, calc(100% - 24px)); background: rgba(12, 22, 24, .9); border-radius: 14px; padding: 10px 12px;
  font-size: 11px; color: var(--muted); text-align: center; box-shadow: 0 4px 0 rgba(0, 0, 0, .4);
  animation: rise .35s ease-out;
}
.decide b { color: #fff; }
.decide .gold { color: var(--gold); }
.decide .row { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12px; }
.decide .row > div { flex: 1; background: rgba(255, 255, 255, .05); border-radius: 8px; padding: 6px 4px; }
.decide .row small { display: block; font-size: 9px; color: var(--muted); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-start; justify-content: center;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  background: linear-gradient(to bottom, rgba(8, 18, 16, .25), rgba(8, 18, 16, .55));
}
.panel {
  width: min(460px, 100%); margin: auto 0; background: rgba(16, 28, 30, .92); border-radius: 18px;
  padding: 18px 18px 16px; box-shadow: 0 6px 0 rgba(0, 0, 0, .45), 0 20px 60px rgba(0, 0, 0, .4);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.brand { text-align: center; font-size: 11px; color: var(--muted); letter-spacing: .1em; }
.logo { margin: 2px 0 6px; text-align: center; font-size: clamp(40px, 13vw, 60px); line-height: .92; font-weight: 700; }
.logo span { display: block; }
.logo span:first-child { color: #fff; text-shadow: 0 4px 0 #c0392b, 0 7px 0 rgba(0, 0, 0, .35); }
.logo span:last-child { color: var(--gold); text-shadow: 0 4px 0 #a86a00, 0 7px 0 rgba(0, 0, 0, .35); }
.tag { text-align: center; font-size: 12px; color: var(--muted); margin: 0 0 14px; line-height: 1.35; }

.resume { background: rgba(247, 197, 72, .12); border-radius: 12px; padding: 10px; margin-bottom: 12px; font-size: 12px; text-align: center; }
.resume b { color: var(--gold); }
.resume .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.resume .btn { height: 44px; font-size: 14px; }

.wager-lbl { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.wager-row { display: flex; align-items: center; background: #0d1719; border-radius: 12px; padding: 0 12px; box-shadow: inset 0 3px 0 rgba(0, 0, 0, .35); }
.dollar { font-size: 28px; color: var(--gold); font-weight: 700; }
#wager {
  flex: 1; min-width: 0; background: transparent; border: 0; color: #fff; font: inherit; font-size: 30px; font-weight: 700;
  padding: 10px 6px; outline: none; user-select: text; -webkit-user-select: text;
}
.presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0 12px; }
.presets button {
  border: 0; border-radius: 9px; background: var(--panel-2); font-size: 13px; padding: 9px 0; font-weight: 700;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
}
.presets button.on { background: var(--gold); color: #3a2600; }
.err { color: #ff9b94; font-size: 12px; margin: -4px 0 10px; }

.ladder { margin-top: 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.ladder div { background: rgba(255, 255, 255, .05); border-radius: 8px; padding: 6px 4px; text-align: center; font-size: 10px; color: var(--muted); }
.ladder b { display: block; color: #fff; font-size: 13px; }
.ladder i { display: block; font-style: normal; color: var(--gold); font-size: 9px; }
.ladder .under b { color: var(--muted); }
.ladder .under i { color: var(--muted); }

.how { margin-top: 12px; background: rgba(255, 255, 255, .04); border-radius: 12px; padding: 8px 12px; font-size: 11px; line-height: 1.45; color: #d7e3e1; }
.how summary { cursor: pointer; color: var(--gold); font-size: 12px; }
.how ol { margin: 8px 0 2px; padding-left: 18px; }
.how li { margin-bottom: 6px; }
.how b { color: #fff; }
.fine { text-align: center; font-size: 10px; color: var(--muted); margin: 10px 0 4px; }
.keys { text-align: center; font-size: 9px; color: #6f8785; }

.feeds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.feed h3 { margin: 0 0 4px; font-size: 10px; color: var(--muted); font-weight: 400; }
.feed ul { list-style: none; margin: 0; padding: 0; font-size: 10px; }
.feed li { display: flex; justify-content: space-between; gap: 4px; padding: 3px 0; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.feed li b { color: var(--gold); font-weight: 400; }
.feed li .l { color: #ff9b94; }
.feed li .w { color: #7ff0b8; }
.muted { color: #6f8785; }

.result { text-align: center; }
.result-title { font-size: clamp(34px, 11vw, 52px); font-weight: 700; line-height: 1; margin: 6px 0 4px; }
.result.lose .result-title { color: #ff6b61; text-shadow: 0 4px 0 #7a1a14; }
.result.win .result-title { color: var(--gold); text-shadow: 0 4px 0 #8a5a00; animation: pop .7s cubic-bezier(.2, 1.6, .4, 1); }
.result-cause { font-size: 12px; color: var(--muted); min-height: 16px; margin-bottom: 12px; }
.result-rows { display: grid; gap: 6px; margin-bottom: 10px; }
.result-rows div { display: flex; justify-content: space-between; background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.result-rows span { color: var(--muted); }
.result-rows b { font-size: 16px; }
.result-rows .net b { font-size: 20px; }
.result.win .net b { color: #7ff0b8; }
.result.lose .net b { color: #ff9b94; }
.result .btn.play { margin: 4px 0 10px; }

.net-banner {
  position: fixed; z-index: 50; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%);
  background: var(--red); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 12px;
}

/* coins / confetti */
.coin {
  position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6c8, #f7c548 45%, #b07a10 100%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25); will-change: transform;
}
.conf { position: absolute; width: 8px; height: 12px; will-change: transform; }
.float {
  position: absolute; font-size: 22px; font-weight: 700; color: var(--gold); text-shadow: 0 3px 0 #8a5a00;
  animation: floatup 1.2s ease-out forwards; white-space: nowrap;
}
.rays {
  position: fixed; inset: -50%; z-index: 19; pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(247, 197, 72, .16) 0 10deg, transparent 10deg 20deg);
  animation: rays 3s ease-out forwards;
}

@keyframes pop { 0% { transform: scale(1); } 30% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes glow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
@keyframes drop { from { transform: translate(-50%, -30px) scale(.8); opacity: 0; } to { transform: translate(-50%, 0) scale(1); opacity: 1; } }
@keyframes rise { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes floatup { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-70px); opacity: 0; } }
@keyframes rays { 0% { opacity: 0; transform: rotate(0); } 15% { opacity: 1; } 100% { opacity: 0; transform: rotate(40deg); } }

@media (max-width: 420px) {
  .hud-left { min-width: 0; max-width: calc(52% - 14px); padding: 8px 10px; }
  .hud-right { min-width: 0; max-width: calc(48% - 10px); padding: 8px 10px; font-size: 8px; }
  .lbl { font-size: 9px; }
  .kv b { font-size: 11px; }
  .kv { gap: 8px; }
}
@media (max-height: 560px) {
  .cash { height: 56px; font-size: 20px; }
  .decide { bottom: calc(80px + var(--safe-b)); }
}
@media (prefers-reduced-motion: reduce) {
  .pay.pop, .result.win .result-title, .toast.big { animation: none; }
}
