:root {
  --bg: #0a1521;
  --bg2: #0d1b2a;
  --surface: #16263b;
  --surface2: #1d3450;
  --line: #26415e;
  --gold: #f7c948;
  --gold-2: #ffd866;
  --green: #5fd08a;
  --red: #ff6b6b;
  --txt: #eaf1fb;
  --muted: #9bb1c9;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--txt);
  background:
    radial-gradient(1100px 520px at 85% -10%, rgba(247, 201, 72, 0.1), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(61, 110, 255, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  background-attachment: fixed;
}

/* ---- top bar -------------------------------------------------------------- */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 27, 42, 0.72);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-size: 19px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.2px;
}
.spacer {
  flex: 1;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--txt);
  font: inherit;
  font-weight: 600;
}
button.chip {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
}
button.chip:hover {
  border-color: var(--gold);
}
button.chip:active {
  transform: translateY(1px);
}
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}
.chip .chip-x {
  color: var(--muted);
  font-size: 13px;
}
.chip code {
  font: 13px ui-monospace, monospace;
  color: var(--muted);
}
.bal {
  font-weight: 800;
}
.bal #funbal {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.bal .coin {
  filter: drop-shadow(0 0 6px rgba(247, 201, 72, 0.45));
}
.bal.flash {
  animation: balflash 0.6s ease;
}
@keyframes balflash {
  0% {
    border-color: var(--gold);
    box-shadow: 0 0 0 0 rgba(247, 201, 72, 0.5);
  }
  100% {
    border-color: var(--line);
    box-shadow: 0 0 0 14px rgba(247, 201, 72, 0);
  }
}

/* ---- hero ----------------------------------------------------------------- */
.hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 22px 22px 6px;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(120deg, rgba(247, 201, 72, 0.08), transparent 55%),
    var(--surface);
  box-shadow: var(--shadow);
}
.hero-text h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -0.2px;
}
.hero-text .accent {
  color: var(--gold);
}
.hero-text p {
  margin: 0;
  max-width: 56ch;
  color: var(--muted);
}
.hero-glow {
  margin-left: auto;
  font-size: 52px;
  filter: drop-shadow(0 8px 24px rgba(247, 201, 72, 0.4));
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  50% {
    transform: translateY(-8px);
  }
}

/* ---- layout --------------------------------------------------------------- */
.wrap {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  padding: 18px 22px 96px;
  align-items: start;
}
@media (max-width: 860px) {
  .wrap {
    grid-template-columns: 1fr;
  }
  .hero-glow {
    display: none;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 0;
}
.hint {
  font-size: 12.5px;
  color: var(--muted);
}

/* ---- game cards ----------------------------------------------------------- */
.games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
}
.game {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--surface2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 14px 14px;
  text-align: center;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.game:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 14px 30px -16px rgba(247, 201, 72, 0.5);
}
.game.win {
  animation: pop 0.5s ease;
}
.game.lose {
  animation: shake 0.4s ease;
}
@keyframes pop {
  40% {
    transform: scale(1.05);
    border-color: var(--green);
  }
}
@keyframes shake {
  20% {
    transform: translateX(-5px);
  }
  60% {
    transform: translateX(5px);
  }
}
.game .ico {
  font-size: 36px;
  line-height: 1;
}
.game h3 {
  margin: 10px 0 2px;
  font-size: 15px;
}
.game .odds {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.game button {
  width: 100%;
  cursor: pointer;
  border: none;
  border-radius: 9px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 800;
  color: #08121f;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  transition: filter 0.12s, transform 0.05s;
}
.game button:hover {
  filter: brightness(1.06);
}
.game button:active {
  transform: translateY(1px);
}
.game button:disabled {
  filter: grayscale(0.6) brightness(0.8);
  cursor: not-allowed;
}

/* ---- deposits row --------------------------------------------------------- */
.deposits {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.deposits-label {
  color: var(--muted);
  font-size: 13px;
  margin-right: auto;
}
.ghost {
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--txt);
  border-radius: 9px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
}
.ghost:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ---- activity log --------------------------------------------------------- */
.log-panel {
  position: sticky;
  top: 78px;
}
.log {
  max-height: 360px;
  overflow: auto;
  font: 12px/1.55 ui-monospace, monospace;
  background: #07111d;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.log > div {
  padding: 2px 0;
  border-bottom: 1px solid rgba(38, 65, 94, 0.4);
}
.log .ok {
  color: var(--green);
}
.log .dup {
  color: var(--gold);
}
.log .bad {
  color: var(--red);
}
.log .dim {
  color: var(--muted);
}

/* ---- win / loss toasts ---------------------------------------------------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2147482000; /* below the widget iframe, above the page */
  pointer-events: none;
}
.toast {
  min-width: 200px;
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: var(--surface2);
  animation: toastin 0.25s ease, toastout 0.3s ease 2.2s forwards;
}
.toast.win {
  border-color: var(--green);
  color: var(--green);
  background: linear-gradient(180deg, rgba(95, 208, 138, 0.18), var(--surface2));
}
.toast.lose {
  border-color: var(--red);
  color: var(--red);
}
.toast.info {
  color: var(--gold);
  border-color: var(--gold);
}
@keyframes toastin {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}
@keyframes toastout {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ---- session banner (loading / error) ------------------------------------- */
.banner {
  position: fixed;
  left: 22px;
  bottom: 22px;
  max-width: 340px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 2147482000;
  font-size: 13.5px;
}
.banner.loading {
  border-color: var(--gold);
}
.banner.error {
  border-color: var(--red);
}
.banner .spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border: 2px solid var(--muted);
  border-top-color: var(--gold);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}
.banner button {
  margin-top: 8px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--txt);
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  font-weight: 700;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- dev console (raw-event tester) --------------------------------------- */
.span2 {
  grid-column: 1 / -1;
}
.console summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}
.console summary::-webkit-details-marker {
  display: none;
}
.console summary h2::before {
  content: "▸ ";
  color: var(--gold);
}
.console details[open] summary h2::before {
  content: "▾ ";
}
.console summary h2 {
  display: inline;
}
.muted-inline {
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.console-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.console-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.console-grid label.span-all {
  grid-column: 1 / -1;
}
.console-grid input,
.console-grid textarea {
  font: 13px ui-monospace, monospace;
  color: var(--txt);
  background: #07111d;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  text-transform: none;
  letter-spacing: 0;
}
.console-grid textarea {
  resize: vertical;
  line-height: 1.5;
}
.console-grid input:focus,
.console-grid textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.console-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}
.console-actions .hint {
  flex: 1;
}
.cta {
  cursor: pointer;
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 800;
  color: #08121f;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  white-space: nowrap;
  transition: filter 0.12s, transform 0.05s;
}
.cta:hover {
  filter: brightness(1.06);
}
.cta:active {
  transform: translateY(1px);
}

/* ---- player state (inspector) --------------------------------------------- */
.state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface2), var(--surface));
}
.stat-k {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.stat-v {
  font-size: 26px;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.state-rewards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.state-rewards .rwd {
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--green);
  color: var(--green);
  background: rgba(95, 208, 138, 0.1);
}

/* ---- rewards received (callback panel) ------------------------------------ */
.cb-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}
.cb {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--surface2), var(--surface));
  font-size: 13px;
}
.cb b {
  color: var(--gold);
}
.cb .cb-v {
  font: 11px ui-monospace, monospace;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.cb .cb-v.ok {
  color: var(--green);
  border-color: var(--green);
}
.cb .cb-v.bad {
  color: var(--red);
  border-color: var(--red);
}
.cb .cb-v.dim {
  color: var(--muted);
}
.cb .cb-t {
  margin-left: auto;
  color: var(--muted);
  font: 12px ui-monospace, monospace;
}

/* The widget is injected as a fixed-position iframe (collapsed launcher → full
   modal on LUCKY_COINS_EXPAND). Its chrome is set inline in lobby.js. */
