/* Mobile/WebView friendly defaults */
:root{
  --bg:#120b1f;
  --panel: rgba(12, 8, 18, 0.62);
  --panel2: rgba(12, 8, 18, 0.72);
  --text:#fff;
  --muted: rgba(255,255,255,0.75);
  --stroke: rgba(255,255,255,0.20);
  --accent: #ffd24d;
}

*{ box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body{
  margin:0;
  background: radial-gradient(1200px 800px at 50% 0%, rgba(140,90,255,0.12), transparent 60%), var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow-x:hidden;
  overscroll-behavior: none;
}

#page{
  min-height:100%;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:
    max(14px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}

#card{
  width: min(1100px, 96vw);
  display:flex;
  flex-direction:column;
  gap:12px;
}

/* Game area should NOT take the full page */
#gameWrap{
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.18);
  box-shadow: 0 18px 55px rgba(0,0,0,0.40);
  overflow:hidden;
}

/* This element holds the background image and constrains the canvas */
#gameSurface{
  position:relative;
  width:100%;
  aspect-ratio: 16 / 9;
  background: url("assets/plinko-bg.png") center / cover no-repeat;
}

#plinko{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  touch-action: none; /* avoid scroll/bounce in WebViews */
}

/* HUD BELOW the game */
#hud{
  width:100%;
  padding: 12px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud-row{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
}

.pill{
  padding:10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.25);
  min-width: 130px;
}
.pill-label{ font-size: 12px; color: var(--muted); }
.pill-value{ font-size: 18px; font-weight: 800; letter-spacing: 0.2px; }
.pill-unit{ font-size: 12px; color: var(--muted); font-weight: 700; margin-left: 6px; }

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width: 140px;
  flex:1 1 140px;
}
label{ font-size: 12px; color: var(--muted); }

.betline{ display:flex; align-items:center; gap:8px; }

input[type="number"], select{
  width:100%;
  padding:10px 10px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.30);
  color: var(--text);
  outline: none;
  font-size: 16px;
}

.btn{
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  user-select:none;
}
.btn:active{ transform: translateY(1px); }

.btn.primary{
  background: linear-gradient(180deg, rgba(255,210,77,0.95), rgba(255,210,77,0.65));
  border-color: rgba(255,210,77,0.75);
  color: #1b102e;
  min-width: 120px;
}

.btn.ghost{ background: rgba(0,0,0,0.15); }
.btn.small{ padding: 10px 12px; min-width: 44px; }

.hint{
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  flex: 1 1 auto;
}

/* Toast (bottom center, under the whole card) */
#toast{
  align-self:center;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--stroke);
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
  opacity: 0;
  pointer-events:none;
  transition: opacity 220ms ease;
  max-width: min(92vw, 520px);
  text-align:center;
}
#toast.show{ opacity: 1; }

/* Small screens: keep HUD compact */
@media (max-width: 520px){
  #card{ width: 98vw; }
  .pill{ min-width: 110px; }
  .pill-value{ font-size: 16px; }
  .btn.primary{ min-width: 110px; }
}


.chips{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:8px;
}
.chip{
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  cursor:pointer;
}
.chip:active{ transform: translateY(1px); }

.toggles{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:10px;
  flex-wrap:wrap;
}
.toggle{
  display:flex;
  align-items:center;
  gap:8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.18);
  font-weight: 800;
  cursor:pointer;
  user-select:none;
}
.toggle input{ transform: scale(1.05); }

.autoline{
  display:flex;
  gap:8px;
  align-items:center;
}
.history{
  width:100%;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.hitem{
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.22);
  font-weight: 800;
  font-size: 13px;
}
.hitem.win{ border-color: rgba(124,255,122,0.35); }
.hitem.lose{ border-color: rgba(255,83,112,0.35); }
.hitem.big{ outline: 2px solid rgba(255,210,77,0.30); }


/* Bulb lights overlay */
#bulbs{
  position:absolute;
  inset:0;
  pointer-events:none;
}


.casino-footer {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: rgba(20, 5, 40, 0.65);
  border-radius: 30px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 12px rgba(255, 200, 100, 0.25);
  z-index: 1000;
  font-family: Poppins, Arial, sans-serif;
}

.footer-text {
  color: #ffdca8;
  font-size: 12px;
  white-space: nowrap;
}

.home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff1b0 0%, #ffb300 60%, #ff8c00 100%);
  box-shadow: 0 0 6px rgba(255,190,0,0.8), inset 0 0 4px rgba(255,255,255,0.6);
  font-size: 16px;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease;
}

.home-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(255,200,0,1), inset 0 0 6px rgba(255,255,255,0.8);
}


/* Fullscreen button (top-right over the board) */
.fs-btn{
  position:absolute;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(8, 5, 14, 0.45);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.35), inset 0 0 10px rgba(255,210,77,0.10);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  z-index: 20;
}
.fs-btn:hover{
  transform: translateY(-1px);
  background: rgba(12, 8, 18, 0.55);
  box-shadow: 0 14px 30px rgba(0,0,0,0.40), 0 0 14px rgba(255,210,77,0.20), inset 0 0 12px rgba(255,210,77,0.14);
}
.fs-btn:active{ transform: translateY(0px) scale(0.98); }
.fs-btn:focus-visible{
  outline: 2px solid rgba(255,220,168,.95);
  outline-offset: 3px;
}
.fs-ico{
  width: 18px;
  height: 18px;
  display:block;
  background: currentColor;
  color: rgba(255, 220, 168, 0.95);
  -webkit-mask: var(--mask) center/contain no-repeat;
  mask: var(--mask) center/contain no-repeat;
}
/* default icon = enter fullscreen */
.fs-btn[data-state="enter"] .fs-ico{
  --mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M7 14H5v5h5v-2H7v-3Zm0-4h2V7h3V5H5v5Zm10 9h-3v2h5v-5h-2v3Zm0-14V5h-5v2h3v3h2Z'/%3E%3C/svg%3E");
}
/* exit icon */
.fs-btn[data-state="exit"] .fs-ico{
  --mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M5 16h2v3h3v2H5v-5Zm0-8V3h5v2H7v3H5Zm14 13h-5v-2h3v-3h2v5Zm-5-18h5v5h-2V5h-3V3Z'/%3E%3C/svg%3E");
}

/* Under-game visual strip */
#underBar{
  position: relative;
  height: 26px;
  margin: 10px 0 2px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.14);
  background:
    radial-gradient(120% 180% at 50% -40%, rgba(255,210,77,0.35), transparent 55%),
    linear-gradient(90deg, rgba(122,64,255,0.25), rgba(255,210,77,0.18), rgba(39,194,255,0.18), rgba(122,64,255,0.25));
  overflow:hidden;
  box-shadow: 0 18px 45px rgba(0,0,0,0.30), inset 0 0 18px rgba(255,255,255,0.06);
}
#underBar .underBar-glow{
  position:absolute;
  inset:-60px -40px auto -40px;
  height: 120px;
  background: radial-gradient(circle, rgba(255,210,77,0.35) 0%, rgba(255,140,0,0.20) 35%, transparent 70%);
  filter: blur(2px);
  opacity: .75;
}
#underBar .underBar-lights{
  position:absolute;
  inset:0;
  background:
    radial-gradient(circle at 10px 50%, rgba(255,240,200,0.85) 0 3px, transparent 4px) 0 0/26px 26px repeat,
    radial-gradient(circle at 23px 50%, rgba(255,210,77,0.55) 0 2px, transparent 3px) 0 0/26px 26px repeat;
  mix-blend-mode: screen;
  opacity: .55;
  animation: underLights 2.2s linear infinite;
}
@keyframes underLights{
  from{ transform: translateX(0); }
  to{ transform: translateX(26px); }
}

/* True fullscreen styling (no cropping) */
#card:fullscreen{
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}
#card:fullscreen #gameWrap{
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
#card:fullscreen #gameSurface{
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 260px); /* leaves room for HUD + footer */
  aspect-ratio: 16 / 9;
  background-size: contain; /* IMPORTANT: avoid cropping the background art */
  background-position: center;
}
#card:fullscreen #hud{
  flex: 0 0 auto;
}
#card:fullscreen .casino-footer{
  position: fixed;
  bottom: 10px;
}

/* Fallback pseudo-fullscreen (mobile where Fullscreen API is limited) */
body.pseudo-fs #card{
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}
body.pseudo-fs #gameWrap{
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.pseudo-fs #gameSurface{
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 260px);
  aspect-ratio: 16 / 9;
  background-size: contain;
  background-position: center;
}
body.pseudo-fs #hud{ flex: 0 0 auto; }
body.pseudo-fs .casino-footer{ position: fixed; bottom: 10px; z-index: 10000; }
body.pseudo-fs #gameSurface{
  height: min(72vh, 720px);
  aspect-ratio: auto;
}
body.pseudo-fs .casino-footer{ position: fixed; bottom: 10px; z-index: 10000; }

#card:fullscreen #gameWrap{ overflow: visible; }
body.pseudo-fs #gameWrap{ overflow: visible; }

/* True fullscreen styling (board fits the background, no letterboxing) */
#card:fullscreen{
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  display: block;
}

/* The board uses the full screen */
#card:fullscreen #gameWrap{
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}
#card:fullscreen #gameSurface{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  background-size: cover;   /* fill screen like the background art */
  background-position: center;
}
#card:fullscreen #plinko{ width:100%; height:100%; }

/* Hide the decorative under bar in fullscreen */
#card:fullscreen #underBar{ display:none; }

/* HUD becomes an overlay at the bottom */
#card:fullscreen #hud{
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 64px; /* keep space for footer */
  margin: 0;
  background: rgba(12, 8, 18, 0.55);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(10px);
  border-radius: 18px;
  box-shadow: 0 18px 55px rgba(0,0,0,0.45);
  z-index: 30;
}

/* Keep footer visible */
#card:fullscreen .casino-footer{
  position: fixed;
  bottom: 10px;
}

/* Fallback pseudo-fullscreen (mobile/WebViews) */
body.pseudo-fs #card{
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  z-index: 9999;
  display: block;
}
body.pseudo-fs #gameWrap{
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}
body.pseudo-fs #gameSurface{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  background-size: cover;
  background-position: center;
}
body.pseudo-fs #underBar{ display:none; }
body.pseudo-fs #hud{
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 64px;
  margin: 0;
  background: rgba(12, 8, 18, 0.55);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(10px);
  border-radius: 18px;
  box-shadow: 0 18px 55px rgba(0,0,0,0.45);
  z-index: 10001;
}
body.pseudo-fs .casino-footer{ position: fixed; bottom: 10px; z-index: 10002; }

/* In fullscreen, place the fullscreen button above HUD */
#card:fullscreen .fs-btn{ top: 12px; right: 12px; z-index: 40; }
body.pseudo-fs .fs-btn{ top: 12px; right: 12px; z-index: 10003; }
