:root {
  --bg: #0b1512;
  --bg-2: #0f2019;
  --panel: #142a22;
  --panel-2: #1a352b;
  --gold: #e8c468;
  --gold-dim: #b6923f;
  --green: #2fbf71;
  --red: #e0475a;
  --text: #eef3ef;
  --text-dim: #9db3a8;
  --border: #244539;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 50% -10%, var(--bg-2), var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px 32px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.topbar .back {
  font-size: 20px;
  color: var(--gold);
  padding: 2px 8px;
  border-radius: 8px;
}
.topbar .back:active { background: var(--panel-2); }

.balance {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}
.balance .amount {
  font-weight: 700;
  font-size: 16px;
  color: var(--gold);
}
.balance .label {
  font-size: 11px;
  color: var(--text-dim);
}

h1.title {
  font-size: 20px;
  margin: 4px 0 14px;
  text-align: center;
  color: var(--gold);
  letter-spacing: 0.3px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.game-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 10px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.game-tile:active { transform: scale(0.97); border-color: var(--gold-dim); }
.game-tile .emoji { font-size: 34px; }
.game-tile .name { font-weight: 600; font-size: 14px; text-align: center; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.center { justify-content: center; }

button.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button.btn:active { transform: scale(0.97); }
button.btn.primary {
  background: linear-gradient(160deg, var(--gold), var(--gold-dim));
  color: #241a05;
  border-color: var(--gold-dim);
}
button.btn.danger { border-color: var(--red); color: var(--red); }
button.btn:disabled { opacity: 0.45; cursor: default; }

.amount-input {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}
.amount-input input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
}
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.preset {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}
.preset.active { color: var(--gold); border-color: var(--gold-dim); }

.result {
  text-align: center;
  padding: 14px;
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 15px;
  font-weight: 600;
}
.result.win { background: rgba(47, 191, 113, 0.15); color: var(--green); }
.result.lose { background: rgba(224, 71, 90, 0.15); color: var(--red); }
.result .delta { font-size: 22px; display: block; margin-top: 4px; }

.hint { color: var(--text-dim); font-size: 13px; text-align: center; margin-top: 6px; }
.error-box {
  background: rgba(224, 71, 90, 0.12);
  color: var(--red);
  border: 1px solid rgba(224, 71, 90, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 10px;
  display: none;
}
.error-box.show { display: block; }

/* --- Слоты --- */
.reels {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 18px 0;
}
.reel {
  width: 74px;
  height: 74px;
  background: var(--bg-2);
  border: 2px solid var(--gold-dim);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  overflow: hidden;
}
.reel.spin { animation: reelSpin 0.12s linear infinite; }
@keyframes reelSpin {
  0% { transform: translateY(-6px); opacity: 0.6; }
  50% { transform: translateY(6px); opacity: 1; }
  100% { transform: translateY(-6px); opacity: 0.6; }
}

/* --- Кости --- */
.dice-row { display: flex; justify-content: center; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.die {
  width: 52px; height: 52px;
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15);
}
.die.rolling { animation: dieRoll 0.6s ease; }
@keyframes dieRoll {
  0% { transform: rotate(0deg) scale(0.8); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

/* --- Карты --- */
.hand { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.playing-card {
  width: 52px; height: 74px;
  background: var(--text);
  color: #111;
  border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  animation: cardDeal 0.25s ease;
}
.playing-card.red { color: var(--red); }
.playing-card.back {
  background: repeating-linear-gradient(45deg, var(--gold-dim), var(--gold-dim) 6px, #7a5f22 6px, #7a5f22 12px);
  color: transparent;
}
@keyframes cardDeal {
  from { transform: translateY(-16px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.hand-value { text-align: center; font-size: 13px; color: var(--text-dim); margin-top: -2px; }

/* --- Рулетка --- */
.wheel-wrap { display: flex; justify-content: center; margin: 16px 0; }
#wheelCanvas { border-radius: 50%; box-shadow: 0 0 0 6px var(--gold-dim), var(--shadow); }
.bet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.bet-grid button { padding: 12px 4px; font-size: 13px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold); color: #241a05; font-size: 11px; font-weight: 800;
  border: 2px solid #241a05;
}

/* --- Монетка --- */
.coin {
  width: 96px; height: 96px; margin: 18px auto; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, var(--gold) 60%, var(--gold-dim));
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; box-shadow: var(--shadow);
}
.coin.flip { animation: coinFlip 0.7s ease; }
@keyframes coinFlip {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(1080deg); }
}
