:root {
  --bg: #f8f6ef;
  --paper: #fffef8;
  --ink: #1a1d16;
  --muted: #5a614f;
  --green: #0e6f4b;
  --green-dark: #084f35;
  --accent: #ff6b1a;
  --danger: #bf1d1d;
  --line: #d8d7ca;
  --shadow: 0 16px 35px rgba(22, 30, 15, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #ffe3c9 0 20%, transparent 45%),
    radial-gradient(circle at 95% 20%, #c8f3df 0 15%, transparent 42%),
    linear-gradient(160deg, #f7f3e8 0%, #f2efe3 100%);
  font-family: "Space Grotesk", sans-serif;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(40px);
  pointer-events: none;
}

.bg-shape-1 {
  width: 420px;
  height: 420px;
  left: -120px;
  top: -160px;
  background: rgba(255, 111, 0, 0.22);
}

.bg-shape-2 {
  width: 360px;
  height: 360px;
  right: -80px;
  bottom: -150px;
  background: rgba(14, 111, 75, 0.2);
}

.app {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1rem 1rem 2.2rem;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

h1, h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2rem, 6vw, 3.1rem);
  letter-spacing: 0.03em;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 0.8rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.72rem;
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.wallets {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 0.55rem;
  width: min(620px, 100%);
}

.wallet {
  border: 1px solid var(--line);
  background: #fcfcee;
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
}

.wallet.pot {
  background: #eefbf5;
  border-color: #acc8b8;
}

.wallet .name {
  font-size: 0.8rem;
  color: var(--muted);
}

.wallet .amount {
  font-size: 1.05rem;
  font-weight: 700;
}

.stack {
  display: grid;
  gap: 0.65rem;
}

.stack-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.controls {
  justify-content: flex-start;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: #283119;
}

input, button {
  font: inherit;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid #bfc6b2;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: #fff;
}

input[type="range"] {
  accent-color: var(--accent);
  width: min(260px, 78vw);
}

button {
  border: 0;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--green), var(--green-dark));
  color: #fff;
  font-weight: 600;
  padding: 0.56rem 0.85rem;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease;
}

button.ghost {
  background: linear-gradient(145deg, #41534a, #2b3932);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.room-box {
  margin-top: 0.8rem;
  border: 1px dashed #a4ab99;
  border-radius: 12px;
  padding: 0.6rem;
  font-size: 0.92rem;
}

.muted {
  color: var(--muted);
}

.game-card {
  grid-column: 1 / -1;
}

.game-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.badge {
  font-size: 0.82rem;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  border: 1px solid #bac6b0;
  background: #f4fce8;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.score {
  border: 1px solid #c9cfbf;
  border-radius: 14px;
  padding: 0.6rem;
  background: #fbfff8;
}

.score.active {
  outline: 2px solid rgba(255, 107, 26, 0.35);
}

.score .top {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.84rem;
}

.group-chip {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.42rem;
  border-radius: 999px;
  border: 1px solid #b9c0b2;
  background: #f3f7ee;
  color: #374132;
}

.group-chip.solid {
  background: #fff3df;
  border-color: #e7caa1;
}

.group-chip.striped {
  background: #e7f2ff;
  border-color: #b9d3ef;
}

.score .big {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 0.2rem;
}

.table-wrap {
  border: 10px solid #6e442d;
  border-radius: 18px;
  background: #0f754f;
  overflow: hidden;
  margin-bottom: 0.9rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 10px 22px rgba(0, 0, 0, 0.22);
}

#poolCanvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.turn-info {
  margin: 0;
  font-weight: 500;
}

.turn-info.warn {
  color: #8b2c00;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.6rem;
  margin-bottom: 0.35rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  font-size: 0.84rem;
  color: #3e4a3b;
}

.legend-ball {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.28);
  display: inline-block;
}

.legend-ball.solid {
  background: #ea7d11;
}

.legend-ball.striped {
  background: linear-gradient(to bottom, #ffffff 0 28%, #2557c6 28% 72%, #ffffff 72% 100%);
}

.legend-ball.eight {
  background: #151515;
}

.log-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
  max-height: 240px;
  overflow: auto;
}

.log-list li {
  border-left: 3px solid #d0d5c6;
  background: #fafbf6;
  padding: 0.35rem 0.5rem;
  border-radius: 0 9px 9px 0;
  font-size: 0.89rem;
}

.reveal {
  opacity: 0;
  transform: translateY(8px);
  animation: rise 420ms ease forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .game-card {
    grid-column: auto;
  }

  .topbar {
    flex-direction: column;
  }

  .wallets {
    width: 100%;
  }

  .controls {
    align-items: flex-start;
  }
}
