:root {
  --bg: #170b1c;
  --bg-2: #22112a;
  --panel: #2b1634;
  --line: #4a2856;
  --text: #f8eefb;
  --muted: #c3a9cc;
  --pink: #ff4fb6;
  --pink-dark: #c02c86;
  --gold: #ffcc4d;
  --green: #2ecc71;
  --red: #e5484d;
  --black: #1d1d22;
  --felt: #0f5a3a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% -20%, #3d1748 0%, var(--bg) 60%);
  background-color: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) { border-color: var(--pink); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: linear-gradient(180deg, var(--pink), var(--pink-dark));
  border-color: transparent;
  font-weight: 700;
}
button.big { padding: 14px 28px; font-size: 1.1rem; min-width: 140px; }

[hidden] { display: none !important; }

/* Loading screen */
.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}
.logo {
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 800;
  background: linear-gradient(90deg, var(--gold), var(--pink), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#loading-text { color: var(--muted); max-width: 420px; }

/* Layout */
#casino { max-width: 1100px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.player { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
#player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; position: relative; overflow: hidden;
  background: var(--pink-dark); display: grid; place-items: center; font-weight: 700;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.balance {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: 1.05rem; white-space: nowrap;
}
.balance strong { color: var(--gold); transition: color 0.3s; }
.balance strong.up { color: var(--green); }
.balance strong.down { color: var(--red); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.tabs button { white-space: nowrap; flex: none; }
.tabs button[aria-selected="true"] { background: var(--pink-dark); border-color: var(--pink); }

.banner {
  background: #4a1d1d; border: 1px solid var(--red); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px;
}

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; }
@media (max-width: 760px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.table, .feed {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}

/* Bet bar */
.betbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.betbar label { font-weight: 700; color: var(--muted); }
#bet {
  width: 110px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-weight: 700;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 12px; border-radius: 999px; font-size: 0.9rem; }

.panel { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.status { min-height: 1.5em; margin: 0; font-weight: 600; }
.status.win { color: var(--green); }
.status.lose { color: var(--red); }
.paytable { color: var(--muted); font-size: 0.85rem; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* Slots */
.machine {
  width: 100%; max-width: 420px; padding: 20px; border-radius: 20px;
  background: linear-gradient(180deg, #3a1a45, #24102c); border: 2px solid var(--gold);
  box-shadow: 0 0 30px rgba(255, 79, 182, 0.25);
}
.reels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.reel {
  aspect-ratio: 1; display: grid; place-items: center; font-size: clamp(2.2rem, 9vw, 3.4rem);
  background: #fff6fb; border-radius: 12px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12);
}
.reel.spinning { animation: blur 0.12s linear infinite; }
.reel.hit { box-shadow: 0 0 0 4px var(--gold), inset 0 -6px 0 rgba(0, 0, 0, 0.12); }
@keyframes blur { 50% { transform: translateY(4px); filter: blur(1px); } }

/* Blackjack */
.felt {
  width: 100%; background: radial-gradient(circle at 50% 30%, #16784f, var(--felt));
  border: 6px solid #5b3a1e; border-radius: 22px; padding: 16px;
}
.hand-row { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 14px; }
.hand-label { font-weight: 700; color: #d9ffe9; }
.hand-label b { color: var(--gold); }
.cards { display: flex; gap: 8px; min-height: 92px; flex-wrap: wrap; justify-content: center; }
.card {
  width: 62px; height: 88px; border-radius: 8px; background: #fff; color: #1b1b1f;
  display: flex; flex-direction: column; justify-content: space-between; padding: 6px 7px;
  font-weight: 800; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35); animation: deal 0.25s ease-out;
}
.card.red { color: #d0263b; }
.card .suit { align-self: center; font-size: 1.8rem; line-height: 1; }
.card.back {
  background: repeating-linear-gradient(45deg, var(--pink-dark), var(--pink-dark) 6px, var(--pink) 6px, var(--pink) 12px);
  border: 3px solid #fff;
}
@keyframes deal { from { transform: translateY(-14px) scale(0.9); opacity: 0; } }

/* Roulette */
.wheel-result { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ball {
  width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center;
  font-size: 2.6rem; font-weight: 800; background: var(--panel); border: 4px solid var(--gold);
  transition: background 0.1s;
}
.ball.red { background: var(--red); }
.ball.black { background: var(--black); }
.ball.green { background: #149e57; }
.outside-bets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 520px; }
.number-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; width: 100%; max-width: 620px; }
.number-grid button { padding: 8px 0; border-radius: 6px; font-weight: 700; font-size: 0.85rem; }
.number-grid .zero { grid-column: 1 / -1; background: #149e57; }
.number-grid .red-n, .red-bet { background: #8f2028; }
.number-grid .black-n, .black-bet { background: var(--black); }
.selected { outline: 3px solid var(--gold); outline-offset: 1px; }
@media (max-width: 520px) { .number-grid { grid-template-columns: repeat(6, 1fr); } }

/* Coin */
.coin-stage { perspective: 800px; padding: 10px; }
.coin {
  width: 150px; height: 150px; position: relative; transform-style: preserve-3d;
  transition: transform 1.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.face {
  position: absolute; inset: 0; border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 3.4rem; backface-visibility: hidden;
  background: radial-gradient(circle at 35% 30%, #ffe69a, var(--gold) 55%, #b88a1c);
  border: 5px solid #d9a92a; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}
.face span { font-size: 0.85rem; font-weight: 800; color: #6b4a00; text-transform: uppercase; }
.face.tails { transform: rotateY(180deg); }

/* Feed */
.feed h2 { font-size: 1rem; margin: 0 0 10px; }
#feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
#feed li { background: var(--panel); border-radius: 10px; padding: 8px 10px; font-size: 0.9rem; animation: deal 0.3s ease-out; }
#feed li b { color: var(--gold); }
#feed li small { color: var(--muted); display: block; }
#feed .empty { color: var(--muted); background: none; }

.footnote { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 18px 0 0; }

/* Toasts */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 10; width: min(92vw, 420px); }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--pink);
  border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: deal 0.25s ease-out;
}
.toast.error { border-left-color: var(--red); }
.toast.win { border-left-color: var(--green); }
.toast b { display: block; margin-bottom: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
