:root {
  --bar-h: 96px;
  --gold-1: #f0ffd0;
  --gold-2: #7dff5a;
  --gold-3: #128a3c;
  --purple: #b24bff;
  --ink: #eafff0;
  --muted: #8ec9a3;
  --glass: rgba(8, 20, 14, 0.85);
  --line: rgba(140, 255, 130, 0.22);
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
/* embedded in the in-game phone (?embed=1): the host handles navigation */
.embedded #bar a.icon[href="./"] { display: none; }
html, body { height: 100%; background: #05130a; color: var(--ink); font-family: Montserrat, "Baloo 2", Inter, system-ui, sans-serif; overflow: hidden; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
html, body { -webkit-touch-callout: none; overscroll-behavior: none; height: 100dvh; }
img { -webkit-user-drag: none; pointer-events: none; }

/* sized to the embedding container, not the window/screen */
#stage { position: absolute; inset: 0 0 var(--bar-h) 0; }
#stage canvas { display: block; touch-action: none; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(ellipse at center, #123a1e 0%, #05130a 70%);
  transition: opacity .8s ease, transform .8s ease;
}
#loader.gone { opacity: 0; transform: scale(1.08); pointer-events: none; }
.load-logo { width: min(560px, 80vw); filter: drop-shadow(0 10px 40px rgba(125, 255, 90, .35)); animation: float 3s ease-in-out infinite; }
.load-track { width: min(420px, 70vw); height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
#load-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-3), var(--gold-2), var(--gold-1)); box-shadow: 0 0 16px var(--gold-2); transition: width .2s; }
#load-text { font-weight: 700; letter-spacing: .2em; color: var(--muted); font-size: 14px; text-transform: uppercase; }
#load-start {
  font-weight: 900; font-size: 26px; letter-spacing: .06em; padding: 16px 64px; border-radius: 99px;
  color: #052008; background: linear-gradient(180deg, var(--gold-1), var(--gold-2) 50%, var(--gold-3));
  box-shadow: 0 0 0 2px #0a3d17, 0 8px 30px rgba(125, 255, 90, .45), inset 0 2px 0 rgba(255, 255, 255, .6);
  animation: pulse 1.6s ease-in-out infinite;
}
.load-note { position: absolute; bottom: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--muted); letter-spacing: .08em; }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes pulse { 50% { transform: scale(1.05); box-shadow: 0 0 0 2px #0a3d17, 0 8px 50px rgba(125, 255, 90, .75), inset 0 2px 0 rgba(255, 255, 255, .6); } }

/* ---------- bottom bar ---------- */
#bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--bar-h); z-index: 10;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px; padding: 0 24px;
  padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(180deg, rgba(10, 28, 16, .92), rgba(3, 10, 6, .98));
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .6);
}
#bar::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-2), transparent); opacity: .7; }
.left, .controls, .stats, .betbox { display: flex; align-items: center; gap: 10px; }
.stats { justify-content: center; gap: 36px; }
.icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); transition: background .15s; }
.icon:hover { background: rgba(255, 255, 255, .12); }
.icon svg, .round svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#sound.off .wave { opacity: 0; }
#sound.off { color: #5f8c6f; }

.stat { display: flex; flex-direction: column; align-items: center; position: relative; min-width: 120px; }
.stat label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.stat label em { font-style: normal; color: #7dff5a; margin-left: 4px; }
.stat span { font-weight: 800; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat.win span { color: var(--gold-2); text-shadow: 0 0 18px rgba(125, 255, 90, .5); }
#refill { position: absolute; right: -30px; top: 16px; width: 24px; height: 24px; border-radius: 50%; background: #1b3b2c; color: #7dff5a; font-weight: 800; box-shadow: inset 0 0 0 1px #2f6e50; }
#refill.pulse { animation: pulse 1s ease-in-out 4; }
.shake { animation: shake .4s; }
#balance-box.credit span { animation: credit 1.1s ease-out; }
@keyframes credit { 0% { color: var(--gold-1); text-shadow: 0 0 24px var(--gold-2), 0 0 48px var(--gold-2); transform: scale(1.18); } 100% { color: var(--ink); text-shadow: none; transform: scale(1); } }
.fly-coin {
  position: fixed; left: -18px; top: -18px; width: 36px; height: 36px; z-index: 60; pointer-events: none; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffbd6 0 12%, #f7c948 35%, #b7791f 75%, #5c360a 100%);
  box-shadow: 0 0 12px rgba(255, 200, 60, .8), inset 0 0 0 3px rgba(110, 62, 8, .6);
}
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.round { border-radius: 50%; display: grid; place-items: center; position: relative; background: linear-gradient(180deg, #1c3325, #0d1c13); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1), 0 4px 12px rgba(0, 0, 0, .5); transition: transform .1s, box-shadow .2s; }
.round:active { transform: scale(.94); }
.round.sm { width: 36px; height: 36px; font-size: 22px; font-weight: 700; }
.round.md { width: 52px; height: 52px; }
.round.on { color: #052008; background: linear-gradient(180deg, var(--gold-1), var(--gold-2) 55%, var(--gold-3)); box-shadow: 0 0 20px rgba(125, 255, 90, .6); }
.round.on svg { fill: #052008; }
.betbox .stat { min-width: 96px; }

#spin {
  width: 84px; height: 84px; margin-top: -30px; border-radius: 50%; display: grid; place-items: center; color: #052008;
  background: radial-gradient(circle at 50% 30%, var(--gold-1), var(--gold-2) 45%, var(--gold-3) 90%);
  box-shadow: 0 0 0 3px #0a2f13, 0 0 0 6px rgba(125, 255, 90, .35), 0 10px 30px rgba(0, 0, 0, .7), 0 0 40px rgba(125, 255, 90, .35), inset 0 3px 0 rgba(255, 255, 255, .7);
  transition: transform .12s, filter .2s;
}
#spin:hover { filter: brightness(1.1); }
#spin:active { transform: scale(.93); }
#spin svg { width: 44px; height: 44px; fill: none; stroke: #052008; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; transition: transform .4s; }
body.busy #spin svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.autowrap { position: relative; }
#auto-count { position: absolute; top: -6px; right: -6px; font-style: normal; font-size: 11px; font-weight: 800; background: #c0392b; color: #fff; border-radius: 99px; padding: 1px 6px; }
#auto-count:empty { display: none; }
#auto-menu { position: absolute; bottom: 64px; right: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); }
#auto-menu button { padding: 8px 20px; border-radius: 10px; font-weight: 700; background: rgba(255, 255, 255, .05); }
#auto-menu button:hover { background: rgba(125, 255, 90, .2); }
body.busy #bet-minus, body.busy #bet-plus { opacity: .35; pointer-events: none; }

#buybtn { border-radius: 14px; padding: 0 14px; height: 42px; display: flex; align-items: center; gap: 8px; background: linear-gradient(180deg, #3a1a52, #21102f); box-shadow: inset 0 0 0 1px rgba(210, 130, 255, .4); font-weight: 800; font-size: 12px; letter-spacing: .04em; color: #f0d0ff; }
#buybtn img { width: 26px; height: 26px; }
body.busy #buybtn, body.fs #buybtn { opacity: .35; pointer-events: none; }

/* ---------- paytable / bonus buy modal ---------- */
#paytable, #buymenu { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, .7); backdrop-filter: blur(6px); }
#paytable[hidden], #buymenu[hidden] { display: none; }
.pt-card { position: relative; width: min(920px, 94vw); max-height: 86vh; overflow: auto; padding: 32px; border-radius: 20px; background: linear-gradient(180deg, #0e2416, #06120a); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0, 0, 0, .8); }
#pt-close, #buy-close { position: absolute; top: 16px; right: 16px; }
.pt-card h2 { font-size: 34px; text-align: center; background: linear-gradient(180deg, var(--gold-1), var(--gold-2), var(--gold-3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pt-card h3 { margin: 24px 0 10px; color: var(--gold-2); }
.pt-sub { text-align: center; color: var(--muted); margin: 6px 0 20px; }
#pt-symbols { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pt-row { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .03); }
.pt-row img { width: 72px; height: 72px; object-fit: contain; }
.pt-pays { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; font-size: 13px; font-variant-numeric: tabular-nums; }
.pt-pays b { color: var(--gold-2); }
.pt-special { display: grid; gap: 12px; margin-top: 16px; }
.pt-special div { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 12px; background: rgba(125, 255, 90, .06); border: 1px solid var(--line); }
.pt-special img { width: 84px; height: 84px; object-fit: contain; }
.pt-card ul { padding-left: 20px; line-height: 1.7; color: #c9e1d0; }

.buy-opts { display: grid; gap: 14px; margin-top: 10px; }
.buy-opt { display: flex; align-items: center; gap: 16px; padding: 14px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); cursor: pointer; text-align: left; }
.buy-opt:hover { background: rgba(125, 255, 90, .1); }
.buy-opt img { width: 60px; height: 60px; object-fit: contain; }
.buy-opt b { display: block; font-size: 16px; }
.buy-opt span { color: var(--muted); font-size: 13px; }
.buy-opt em { margin-left: auto; font-style: normal; font-weight: 800; color: var(--gold-2); font-size: 18px; }

@media (max-width: 820px) {
  :root { --bar-h: calc(128px + env(safe-area-inset-bottom)); }
  #bar { grid-template-columns: auto 1fr; grid-template-areas: "left stats" "controls controls"; gap: 4px 8px; padding: 6px 10px; padding-bottom: env(safe-area-inset-bottom); }
  .left { grid-area: left; gap: 6px; }
  .stats { grid-area: stats; gap: 10px; justify-content: flex-end; }
  .controls { grid-area: controls; justify-content: space-between; gap: 6px; }
  .icon { width: 34px; height: 34px; border-radius: 10px; }
  .icon svg { width: 18px; height: 18px; }
  .stat { min-width: 0; }
  .stat label { font-size: 9px; letter-spacing: .08em; }
  .stat label em { display: none; }
  .stat span { font-size: 16px; }
  #refill { position: static; width: 22px; height: 22px; margin-left: 4px; }
  #balance-box { flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 0; }
  #balance-box label { width: 100%; text-align: center; }
  .betbox { gap: 4px; }
  .betbox .stat { min-width: 64px; }
  .round.sm { width: 40px; height: 40px; }
  .round.md { width: 46px; height: 46px; }
  .icon { width: 38px; height: 38px; }
  #spin { margin-top: 0; width: 68px; height: 68px; }
  #spin svg { width: 36px; height: 36px; }
  #buybtn { height: 34px; padding: 0 10px; font-size: 10px; }
  #buybtn img { width: 20px; height: 20px; }
}
/* narrow phones: the feature-buy button floats above the bar so balance + win always fit in the top row */
@media (max-width: 560px) and (orientation: portrait) {
  #buybtn { position: absolute; left: 10px; top: -50px; height: 38px; padding: 0 14px; font-size: 12px; box-shadow: inset 0 0 0 1px rgba(210, 130, 255, .5), 0 6px 18px rgba(0, 0, 0, .6); }
  #buybtn img { width: 22px; height: 22px; }
  .stats { gap: 12px; }
  .stat label { font-size: 10px; }
}

/* phones held sideways: controls move into a slim column on the right, the game gets full height */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --side-w: calc(116px + env(safe-area-inset-right)); }
  #stage { inset: 0 var(--side-w) 0 0; }
  #bar {
    left: auto; right: 0; top: 0; bottom: 0; width: var(--side-w); height: auto;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    padding: 6px env(safe-area-inset-right) 6px 6px;
    border-top: 0; border-left: 1px solid var(--line);
    background: linear-gradient(90deg, rgba(10, 28, 16, .88), rgba(3, 10, 6, .98));
    box-shadow: -12px 0 40px rgba(0, 0, 0, .6);
  }
  #bar::before { display: none; }
  .left { gap: 4px; }
  .icon { width: 30px; height: 30px; border-radius: 9px; }
  .icon svg { width: 16px; height: 16px; }
  .stats { flex-direction: column; gap: 4px; padding: 0; }
  .stat { min-width: 0; }
  .stat label { font-size: 9px; letter-spacing: .06em; }
  .stat label em { display: none; }
  .stat span { font-size: 15px; }
  #balance-box { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  #balance-box label { width: 100%; text-align: center; }
  #refill { position: static; width: 18px; height: 18px; margin-left: 3px; font-size: 12px; }
  .controls { flex-direction: column; gap: 8px; }
  .betbox { gap: 2px; }
  .betbox .stat { min-width: 46px; }
  .round.sm { width: 32px; height: 32px; font-size: 18px; }
  .round.md { width: 40px; height: 40px; }
  .round svg { width: 18px; height: 18px; }
  #spin { order: -1; margin: 2px 0; width: 66px; height: 66px; }
  #spin svg { width: 34px; height: 34px; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; justify-items: center; }
  #spin, .betbox { grid-column: 1 / -1; }
  .betbox { order: 1; }
  #auto-menu { bottom: auto; top: -80px; right: 110%; }
  #buybtn { height: 30px; padding: 0 8px; font-size: 9px; }
  #buybtn img { width: 18px; height: 18px; }
}

/* phones sideways: the side column is ~104px wide – icons in a row of three, feature buy full width below, compact bet box */
@media (orientation: landscape) and (max-height: 520px) {
  .left { display: grid; grid-template-columns: repeat(3, 30px); gap: 5px; justify-content: center; }
  .left > :is(#buy, #buybtn, .buy-btn) { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .betbox { gap: 2px; }
  .betbox .stat { min-width: 0; width: 40px; }
  .betbox .round.sm { width: 28px; height: 28px; font-size: 16px; }
  .betbox .stat span { font-size: 13px; }
}