:root {
  --orange: #F39320;
  --text: #ffffff;
  --cream: #F5ECD9;
  --muted: #cdbfae;
  --panel-strong: rgba(0, 0, 0, .6);
  --line: rgba(243, 147, 32, .55);
  /* egg column width; each egg sprite is 460x560 so a row is 1.217 x this.
     Sized so 3 rows always fit on screen without scrolling. */
  --cell: min(calc((100vw - 40px) / 3), calc((100vh - 340px) / 3.65), 170px);
}
@supports (height: 100dvh) {
  :root { --cell: min(calc((100vw - 40px) / 3), calc((100dvh - 340px) / 3.65), 170px); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
@supports (overflow-x: clip) { html, body { overflow-x: clip; } }
body { background: #0b0503; color: var(--text); font: 14px/1.45 Poppins, system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* ---------- background (designer artwork) ---------- */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: #0b0503 url("/bg/bg-mobile.webp") center / cover no-repeat; }
@media (min-width: 768px) {
  .scene { background-image: url("/bg/bg-desktop.webp"); }
}

/* ---------- buttons (designer style, pure CSS) ---------- */
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 10px 26px;
  border-radius: 999px; border: 3px solid; font-weight: 800; font-size: 16px; letter-spacing: .6px; line-height: 1;
  text-decoration: none; transition: transform .08s ease-out, box-shadow .08s ease-out; user-select: none;
}
.btn-primary {
  color: #2A1405; text-transform: uppercase; border-color: #B8650E;
  background: linear-gradient(180deg, #FFB347 0%, #F39320 100%); box-shadow: 0 6px 0 #9A520A;
}
.btn-secondary {
  color: var(--cream); border-color: #E08A1E; background: #2A1A10; box-shadow: 0 6px 0 #6B3A0C;
}
.btn-primary:active, .btn-secondary:active { transform: translateY(4px); }
.btn-primary:active { box-shadow: 0 2px 0 #9A520A; }
.btn-secondary:active { box-shadow: 0 2px 0 #6B3A0C; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .6; transform: none; }
/* round icon buttons use the secondary look */
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; padding: 0;
  color: var(--cream); background: #2A1A10; border: 3px solid #E08A1E; box-shadow: 0 4px 0 #6B3A0C; text-decoration: none;
  transition: transform .08s ease-out, box-shadow .08s ease-out; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #6B3A0C; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .bang { font-weight: 800; font-size: 18px; line-height: 1; }

/* ---------- centre column ---------- */
.view { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; max-width: 560px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; }
.title { margin: 0; font-size: clamp(24px, 7.4vw, 34px); font-weight: 800; letter-spacing: 2px; line-height: 1.15; text-align: center;
  color: var(--text); text-shadow: 0 1px 2px rgba(0, 0, 0, .8); }

/* ---------- login ---------- */
#vLogin { justify-content: center; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 26px 22px 28px; border-radius: 16px;
  background: var(--panel-strong); border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.login-logo { width: 190px; max-width: 70%; height: auto; }
.login-card .title { margin: 12px 0 6px; }
.login-eggs { display: flex; justify-content: center; align-items: end; gap: 6px; margin: 8px 0 14px; }
.login-eggs .egg { width: 72px; }
.login-eggs .egg:nth-child(2) { width: 88px; }
#loginForm { text-align: left; display: grid; gap: 8px; }
#loginForm label { font-weight: 600; font-size: 13px; color: var(--muted); }
#loginForm input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .55);
  color: var(--text); font: inherit; font-size: 16px; }
#loginForm input:focus { outline: none; border-color: var(--orange); }
#loginForm .btn-primary { margin-top: 2px; }
.form-err { color: #ff8a7a; min-height: 20px; margin: 0; font-size: 13px; }

/* ---------- game ---------- */
.top { /* header bar */ width: 100%; display: flex; align-items: center; justify-content: space-between; height: 54px; padding: 0 8px 4px 12px;
  border-radius: 14px; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@media (min-width: 768px) { .top { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0 0 4px; } }
.logo { height: 26px; width: auto; }
.top-btns { display: flex; gap: 10px; }
#vGame .title { margin: 10px 0 10px; padding: 0 10px; border-radius: 10px; background: rgba(0, 0, 0, .35); }
@media (min-width: 768px) { #vGame .title { background: none; } }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.stat { background: var(--panel-strong); border: 1px solid var(--line); border-radius: 12px; padding: 7px 10px; text-align: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.stat span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stat b { display: block; font-size: 20px; font-weight: 700; color: var(--orange); line-height: 1.3; font-variant-numeric: tabular-nums; }

/* eggs sit straight on the background; on phones a very soft dark pool keeps them apart from the money trees */
.stage { position: relative; width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; margin: 6px 0 0; }
@media (max-width: 767.98px) {
  .stage::before { content: ""; position: absolute; inset: -4% -2%; pointer-events: none;
    background: radial-gradient(ellipse 58% 52% at 50% 50%, rgba(0, 0, 0, .5), rgba(0, 0, 0, 0) 100%); }
}
.grid { position: relative; display: grid; grid-template-columns: repeat(3, var(--cell)); grid-auto-rows: calc(var(--cell) * 1.2174); gap: 0 4px; }

/* ---------- egg (sprite images) ---------- */
.egg { position: relative; display: block; border: 0; padding: 0; background: none; }
.egg .lift { position: relative; display: block; transition: transform .15s ease-out; }
.egg img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.egg .base { transform-origin: 50% 92%; }
.egg .shell-top { position: absolute; left: 0; top: 0; width: 100%; opacity: 0; pointer-events: none; }
.egg.ready { cursor: pointer; }
@media (hover: hover) { .egg.ready:hover .lift { transform: translateY(-6px); } }
.egg.ready:active .lift { transform: translateY(-6px); }
/* open: shake twice, then the top shell flies up */
.egg.shaking .base { animation: shake .35s ease-in-out infinite; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
.egg.cracked .shell-top { animation: fly .75s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes fly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  55% { opacity: 1; }
  100% { opacity: 0; transform: translate(-6%, -55%) rotate(-24deg); }
}
.egg .tag { position: absolute; z-index: 2; left: 50%; top: 22%; transform: translateX(-50%); white-space: nowrap; max-width: 108%;
  overflow: hidden; text-overflow: ellipsis; font-size: max(11px, calc(var(--cell) * .1)); font-weight: 800; color: #2A1405;
  background: linear-gradient(180deg, #FFB347, #F39320); border: 2px solid #B8650E; padding: 1px 8px; border-radius: 999px; }
.coin { position: fixed; width: 16px; height: 16px; border-radius: 50%; pointer-events: none; z-index: 40;
  background: #f5c242; box-shadow: inset 0 0 0 2px #b07a10; }

.hint { margin: 6px 0 10px; min-height: 20px; font-size: 13px; color: var(--text); text-align: center;
  background: rgba(0, 0, 0, .55); border-radius: 999px; padding: 2px 12px; }
.hint.warn { color: #ffc48f; }
.bottom { display: flex; gap: 12px; width: 100%; justify-content: center; padding-bottom: 6px; }
.bottom .btn-primary { flex: 1; max-width: 260px; }
.foot { margin: 8px 0 0; font-size: 11px; color: var(--muted); text-align: center; text-shadow: 0 1px 2px #000; }
.foot b { color: var(--text); font-weight: 600; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .7); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; width: 100%; max-width: 380px; max-height: 86vh; display: flex; flex-direction: column;
  background: #140b05; border: 1px solid var(--line); border-radius: 16px; padding: 22px 18px 24px; text-align: center; animation: pop .25s ease-out; }
.sheet.tall { height: 80vh; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.sheet h2 { margin: 0 0 12px; font-weight: 800; font-size: 22px; letter-spacing: .5px; color: var(--text); }
.sheet .x { position: absolute; right: 10px; top: 10px; width: 36px; height: 36px; }
.sheet .x svg { width: 15px; height: 15px; }
.rules { text-align: left; white-space: pre-wrap; overflow: auto; flex: 1; margin-bottom: 18px; color: var(--text); font-size: 13.5px; }
.prize-sheet { padding-top: 26px; }
.prize-sheet h2 { font-size: 26px; }
.prize-sheet .won { margin: 0; color: var(--muted); }
.prize-name { margin: 2px 0 10px; font-size: 36px; font-weight: 800; line-height: 1.15; color: var(--orange); }
.credit-note { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.rw-list { overflow: auto; flex: 1; text-align: left; margin-bottom: 18px; }
.rw-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 11px 4px; border-bottom: 1px solid rgba(243, 147, 32, .2); }
.rw-item .p { font-weight: 700; color: var(--orange); }
.rw-item .d { font-size: 12px; color: var(--muted); }
.badge { align-self: center; grid-row: span 2; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge.pending { color: var(--orange); border: 1px solid var(--orange); }
.badge.credited { color: #6ee59a; border: 1px solid #6ee59a; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.toast { position: fixed; left: 50%; top: calc(76px + env(safe-area-inset-top)); transform: translate(-50%, -12px); z-index: 60;
  background: #2A1A10; color: var(--cream); border: 2px solid #E08A1E; border-radius: 12px; padding: 10px 16px;
  font-size: 13px; text-align: center; width: max-content; max-width: calc(100vw - 32px); opacity: 0; transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 768px) {
  .logo { height: 34px; }
  .stat b { font-size: 24px; }
  .stat span { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .egg.shaking .base { animation-duration: .7s; }
}
