:root {
  --wood-900: #17100a;
  --wood-800: #241a10;
  --wood-700: #332516;
  --brass: #c99b4c;
  --brass-bright: #f2c14e;
  --cream: #f3e9d2;
  --ice: #bfe3f2;
  --blues: #57a4f0;
  --oranges: #f79b46;
  --reds: #f0575a;
  --leaf1: #cfe0c9;
  --leaf2: #5f8f82;
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #060d14;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#ui button { pointer-events: auto; }

/* ---------- top bar ---------- */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
}

.logo {
  font-family: "Alfa Slab One", serif;
  font-size: 26px;
  letter-spacing: 2px;
  color: var(--cream);
  text-shadow: 0 2px 0 #5c3a12, 0 5px 14px rgba(0,0,0,.6);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.logo-flake { color: var(--ice); font-size: 20px; }
.logo-sub {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 4px;
  color: var(--brass-bright);
  border: 1px solid rgba(242,193,78,.5);
  padding: 3px 8px;
  border-radius: 3px;
}

.top-right { display: flex; gap: 10px; align-items: center; }

.balance {
  background: linear-gradient(180deg, var(--wood-700), var(--wood-900));
  border: 1px solid var(--brass);
  color: var(--brass-bright);
  font-size: 24px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-variant-numeric: tabular-nums;
}
.bal-label {
  display: block;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--cream);
  opacity: .55;
}
.balance.pulse { animation: pulse .6s ease; }
.balance.shake { animation: shake .4s ease; }
@keyframes pulse { 30% { transform: scale(1.09); box-shadow: 0 0 30px rgba(242,193,78,.5); } }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

.btn-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--brass);
  background: linear-gradient(180deg, var(--wood-700), var(--wood-900));
  color: var(--brass-bright);
  font-size: 20px;
  cursor: pointer;
  transition: transform .15s ease;
}
.btn-icon:hover { transform: scale(1.08); }
.btn-icon.off { color: #6b5a44; text-decoration: line-through; }

/* ---------- phase banner + timer ---------- */

.phase-wrap {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
}

.phase-banner {
  font-family: "Alfa Slab One", serif;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--cream);
  background: linear-gradient(180deg, rgba(36,26,16,.92), rgba(23,16,10,.92));
  border: 1px solid var(--brass);
  border-radius: 12px;
  padding: 10px 26px;
  box-shadow: var(--shadow-lg);
  text-shadow: 0 2px 6px rgba(0,0,0,.6);
  transition: color .3s ease;
}
.phase-bet { color: var(--ice); }
.phase-spin { color: var(--brass-bright); }
.phase-bonus { animation: bannerFlash .5s ease infinite alternate; }
.phase-blues { color: var(--blues); }
.phase-oranges { color: var(--oranges); }
.phase-reds { color: var(--reds); }
@keyframes bannerFlash { to { box-shadow: 0 0 34px rgba(242,193,78,.55), var(--shadow-lg); } }

.timer-ring {
  position: relative;
  width: 52px; height: 52px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5));
}
.timer-ring.hidden { display: none; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: rgba(23,16,10,.9); stroke: #3d2f1d; stroke-width: 4; }
.ring-fg {
  fill: none;
  stroke: var(--ice);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset .1s linear;
}
.timer-ring.urgent .ring-fg { stroke: var(--reds); }
.timer-num {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--cream);
  font-size: 19px;
  font-weight: 700;
}

/* ---------- history rail ---------- */

.history {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.history-title {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--cream);
  opacity: .5;
  font-weight: 600;
}
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-token {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #10181c;
  border: 2px solid rgba(0,0,0,.4);
  box-shadow: 0 3px 8px rgba(0,0,0,.4);
  position: relative;
  animation: tokenIn .35s ease;
}
@keyframes tokenIn { from { transform: scale(.3); opacity: 0; } }
.tok-leaf1 { background: var(--leaf1); }
.tok-leaf2 { background: var(--leaf2); color: #eaf5ef; }
.tok-blues { background: var(--blues); color: #fff; }
.tok-oranges { background: var(--oranges); color: #fff; }
.tok-reds { background: var(--reds); color: #fff; }
.history-token[data-boost]::after {
  content: attr(data-boost);
  position: absolute;
  right: -8px; top: -6px;
  background: var(--brass-bright);
  color: #241a10;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 6px;
}

/* ---------- boost banner ---------- */

.boost-banner {
  position: absolute;
  top: 148px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(36,26,16,.95), rgba(23,16,10,.95));
  border: 1px solid var(--brass-bright);
  color: var(--cream);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 24px;
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(242,193,78,.35), var(--shadow-lg);
  animation: dropIn .45s cubic-bezier(.2, 1.6, .4, 1);
  white-space: nowrap;
}
@keyframes dropIn { from { transform: translate(-50%, -26px); opacity: 0; } }
.boost-banner.hidden { display: none; }

/* ---------- win overlay ---------- */

.win-overlay {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  animation: winIn .5s cubic-bezier(.2, 1.8, .4, 1);
  pointer-events: none;
}
.win-overlay.hidden { display: none; }
@keyframes winIn { from { transform: translate(-50%, -50%) scale(.4); opacity: 0; } }
.win-title {
  font-family: "Alfa Slab One", serif;
  font-size: 54px;
  letter-spacing: 3px;
  color: var(--brass-bright);
  text-shadow: 0 3px 0 #5c3a12, 0 8px 30px rgba(0,0,0,.8), 0 0 60px rgba(242,193,78,.45);
}
.tone-blues .win-title { color: var(--blues); text-shadow: 0 3px 0 #143a66, 0 8px 30px rgba(0,0,0,.8), 0 0 60px rgba(87,164,240,.5); }
.tone-oranges .win-title { color: var(--oranges); text-shadow: 0 3px 0 #7a3c05, 0 8px 30px rgba(0,0,0,.8), 0 0 60px rgba(247,155,70,.5); }
.tone-reds .win-title { color: var(--reds); text-shadow: 0 3px 0 #6e0b0e, 0 8px 30px rgba(0,0,0,.8), 0 0 60px rgba(240,87,90,.5); }
.win-sub {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 4px;
  color: var(--cream);
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
.win-amount {
  margin-top: 10px;
  font-size: 42px;
  font-weight: 700;
  color: #b8f5c8;
  text-shadow: 0 2px 0 #14532d, 0 6px 24px rgba(0,0,0,.8);
  font-variant-numeric: tabular-nums;
}

/* ---------- bottom: chips, board, actions ---------- */

.bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 18px;
  padding: 0 18px 16px;
}

.chip-tray {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 8px;
  background: linear-gradient(180deg, rgba(36,26,16,.9), rgba(23,16,10,.94));
  border: 1px solid #4a3920;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.chip {
  width: 52px; height: 52px;
  border-radius: 50%;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  position: relative;
  border: 4px dashed rgba(255,255,255,.75);
  outline: 3px solid rgba(0,0,0,.35);
  outline-offset: -1px;
  box-shadow: 0 4px 10px rgba(0,0,0,.5), inset 0 0 0 6px rgba(0,0,0,.18);
  transition: transform .14s ease, box-shadow .14s ease;
}
.chip:hover { transform: translateY(-3px); }
.chip.active {
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 0 22px rgba(242,193,78,.7), 0 6px 14px rgba(0,0,0,.5), inset 0 0 0 6px rgba(0,0,0,.18);
}
.chip-1   { background: radial-gradient(circle at 35% 30%, #8f9aa6, #5c6670); }
.chip-5   { background: radial-gradient(circle at 35% 30%, #e0575c, #a11e26); }
.chip-10  { background: radial-gradient(circle at 35% 30%, #4d9de6, #1d5da6); }
.chip-25  { background: radial-gradient(circle at 35% 30%, #4bbf73, #1e7a41); }
.chip-100 { background: radial-gradient(circle at 35% 30%, #3b3f47, #14161a); }

.board {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(36,26,16,.9), rgba(23,16,10,.94));
  border: 1px solid #4a3920;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.spot {
  width: 122px;
  padding: 12px 8px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #2a2018, #1a130c);
  border: 1px solid #4a3920;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  position: relative;
  transition: transform .14s ease, border-color .2s ease, box-shadow .2s ease;
  opacity: .8;
}
body.betting .spot { opacity: 1; }
body.betting .spot:hover { transform: translateY(-4px); border-color: var(--brass); }
.spot-glyph { height: 30px; display: grid; place-items: center; font-size: 22px; }
.spot-name {
  font-family: "Alfa Slab One", serif;
  font-size: 14px;
  letter-spacing: .5px;
  color: var(--cream);
}
.spot-leaf1 .spot-name { color: var(--leaf1); }
.spot-leaf2 .spot-name { color: var(--leaf2); }
.spot-blues .spot-name { color: var(--blues); }
.spot-oranges .spot-name { color: var(--oranges); }
.spot-reds .spot-name { color: var(--reds); }
.spot-pays {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: rgba(243,233,210,.55);
}
.spot-bet {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle at 35% 30%, #f5d67c, #c99b4c);
  border: 2px dashed rgba(120,70,10,.6);
  color: #241a10;
  min-width: 44px;
  height: 30px;
  padding: 0 8px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(0,0,0,.55);
  font-variant-numeric: tabular-nums;
}
.spot-boost {
  position: absolute;
  top: -12px;
  right: -6px;
  background: var(--brass-bright);
  color: #241a10;
  font-weight: 700;
  font-size: 14px;
  padding: 2px 8px;
  border-radius: 9px;
  box-shadow: 0 0 16px rgba(242,193,78,.8);
  animation: dropIn .4s cubic-bezier(.2, 1.6, .4, 1);
  z-index: 2;
}
.spot.winner {
  border-color: var(--brass-bright);
  box-shadow: 0 0 26px rgba(242,193,78,.55);
  animation: winnerBlink .55s ease 5;
}
@keyframes winnerBlink { 50% { background: #3d2e1c; } }
.hidden { display: none !important; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 8px;
  background: linear-gradient(180deg, rgba(36,26,16,.9), rgba(23,16,10,.94));
  border: 1px solid #4a3920;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.btn-action {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cream);
  background: linear-gradient(180deg, #3a2c1c, #241a10);
  border: 1px solid #55401f;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-action:hover { border-color: var(--brass); color: var(--brass-bright); }
.btn-rebet { border-color: var(--brass); color: var(--brass-bright); }
body:not(.betting) .btn-action { opacity: .45; cursor: default; }

/* ---------- start screen ---------- */

.start-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(8,18,28,.72), rgba(4,9,15,.94));
  pointer-events: auto;
  transition: opacity .6s ease;
  z-index: 10;
}
.start-screen.gone { opacity: 0; pointer-events: none; }

.start-card {
  text-align: center;
  background: linear-gradient(180deg, rgba(36,26,16,.97), rgba(20,14,9,.97));
  border: 2px solid var(--brass);
  border-radius: 20px;
  padding: 42px 54px;
  box-shadow: 0 0 80px rgba(0,0,0,.8), inset 0 0 40px rgba(0,0,0,.4);
  animation: cardIn .7s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes cardIn { from { transform: translateY(30px) scale(.92); opacity: 0; } }

.start-title {
  font-family: "Alfa Slab One", serif;
  font-size: 52px;
  letter-spacing: 4px;
  color: var(--cream);
  text-shadow: 0 3px 0 #5c3a12, 0 8px 30px rgba(0,0,0,.7);
}
.start-title span { color: var(--ice); font-size: 36px; }

.start-tag {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 5px;
  color: var(--brass-bright);
}

.start-rules {
  margin: 26px auto 0;
  text-align: left;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--cream);
}
.start-rules i {
  display: inline-block;
  width: 13px; height: 13px;
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: -1px;
}
.start-note {
  margin-top: 8px;
  font-size: 13px;
  letter-spacing: 1.5px;
  opacity: .55;
}

.start-btn {
  margin-top: 30px;
  font-family: "Alfa Slab One", serif;
  font-size: 21px;
  letter-spacing: 3px;
  color: #241a10;
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  border: none;
  border-radius: 12px;
  padding: 16px 42px;
  cursor: pointer;
  box-shadow: 0 6px 0 #7a5a22, 0 12px 30px rgba(0,0,0,.5);
  transition: transform .12s ease, box-shadow .12s ease;
}
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #7a5a22, 0 16px 34px rgba(0,0,0,.5); }
.start-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #7a5a22, 0 8px 20px rgba(0,0,0,.5); }

/* ---------- small screens ---------- */

@media (max-width: 980px) {
  .board { flex-wrap: wrap; justify-content: center; }
  .spot { width: 104px; }
  .history { display: none; }
  .logo { font-size: 20px; }
  .win-title { font-size: 38px; }
}
