:root {
  color-scheme: light;
  --bg: #f6f4ed;
  --panel: #fffefa;
  --soft: #fbf8ee;
  --control: #ece7d8;
  --control-alt: #e7eef3;
  --ink: #16201d;
  --muted: #67716d;
  --line: #d8d4c6;
  --green: #176b5d;
  --blue: #285f9f;
  --red: #b9433b;
  --yellow: #d59b28;
  --shadow: 0 18px 50px rgba(22, 32, 29, 0.12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --panel: #18201d;
  --soft: #202a26;
  --control: #2a332f;
  --control-alt: #21303a;
  --ink: #f2f5ef;
  --muted: #a7b0aa;
  --line: #36423d;
  --green: #36a88f;
  --blue: #78a9df;
  --red: #ef7d72;
  --yellow: #e7bb58;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
}

.topbar,
.tabs,
.stage,
.rooms,
.ad-panel,
.history {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  grid-column: 1 / -1;
  min-height: 92px;
  border-radius: 8px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.tabs {
  grid-column: 1 / -1;
  border-radius: 8px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
}

.tab,
.text-button,
.icon-button,
.primary,
.secondary,
.tile,
.cup,
.balloon,
.straw {
  min-height: 42px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--control);
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.tab {
  padding: 0 8px;
  font-size: 0.88rem;
  font-weight: 750;
  white-space: nowrap;
}

.tab.active,
.primary {
  background: var(--green);
  color: white;
}

.secondary {
  background: var(--control-alt);
  color: var(--blue);
}

.danger {
  background: var(--red);
  color: white;
}

.tab:hover,
.text-button:hover,
.icon-button:hover,
.primary:hover,
.secondary:hover,
.tile:hover,
.cup:hover,
.balloon:hover,
.straw:hover {
  transform: translateY(-1px);
}

.stage,
.rooms,
.ad-panel,
.history {
  border-radius: 8px;
  padding: 18px;
}

.side-panel {
  display: grid;
  gap: 18px;
  align-self: start;
}

.rooms {
  display: grid;
  gap: 14px;
}

.ad-panel {
  display: grid;
  gap: 8px;
  min-height: 120px;
}

.ad-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.adsbygoogle {
  min-height: 90px;
}

.room-head,
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.room-head p,
.share-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.room-actions,
.copy-row {
  display: grid;
  gap: 8px;
}

.copy-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.share-card {
  display: grid;
  gap: 8px;
}

.game {
  min-height: 520px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.game-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.game-head p,
.muted {
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary,
.secondary,
.text-button,
.icon-button {
  padding: 0 14px;
  font-weight: 800;
}

.text-button {
  min-height: 34px;
  background: transparent;
  color: var(--green);
}

.icon-button {
  background: var(--ink);
  color: var(--panel);
}

[data-theme="dark"] .icon-button {
  background: var(--control);
  color: white;
}

.result {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  text-align: center;
  padding: 18px;
}

.result.compact {
  min-height: 160px;
}

.result.compact strong {
  font-size: clamp(2rem, 5vw, 3.2rem);
}

.result strong {
  display: block;
  font-size: clamp(2.2rem, 10vw, 7rem);
  line-height: 1;
  letter-spacing: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat,
.option-row,
.history li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.stat {
  padding: 12px;
}

.stat b {
  display: block;
  font-size: 1.5rem;
}

.grid {
  display: grid;
  gap: 10px;
}

.grid.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.grid.cards {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.cup-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.cup,
.balloon,
.straw,
.tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 8px;
  font-weight: 900;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.cup {
  gap: 8px;
}

.cup-shape {
  position: relative;
  width: min(58px, 70%);
  aspect-ratio: 1 / 0.82;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(135deg, #f3f6f3, #cad3cd);
  border: 2px solid rgba(22, 32, 29, 0.16);
  box-shadow: inset 10px 0 18px rgba(255, 255, 255, 0.48);
}

.cup-shape::before {
  content: "";
  position: absolute;
  inset: -10px -5px auto;
  height: 18px;
  border-radius: 50%;
  background: #f9fbf8;
  border: 2px solid rgba(22, 32, 29, 0.16);
}

.cup.safe .cup-shape {
  background: linear-gradient(135deg, #e7f5df, #86bd78);
}

.cup.bad .cup-shape {
  background: linear-gradient(135deg, #f6d0ca, #d86b61);
}

.cup.safe,
.balloon.safe,
.straw.safe {
  background: #dfeede;
  color: #1f6f35;
}

.cup.bad,
.balloon.bad,
.straw.bad {
  background: #f1d5d1;
  color: var(--red);
}

.wheel-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.wheel-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 320px;
}

.wheel-pointer {
  position: absolute;
  top: 6px;
  z-index: 2;
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 34px solid var(--ink);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.22));
}

.wheel {
  width: min(320px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 14px solid #284056;
  background:
    conic-gradient(#176b5d 0 22%, #d59b28 22% 42%, #b9433b 42% 60%, #285f9f 60% 78%, #7a4e9d 78% 100%);
  color: white;
  text-align: center;
  padding: 28px;
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.72);
}

.wheel strong {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(22, 32, 29, 0.72);
  font-size: clamp(1.1rem, 4vw, 1.8rem);
}

.wheel.spinning {
  animation: spin 900ms cubic-bezier(0.1, 0.75, 0.2, 1);
}

@keyframes spin {
  to {
    transform: rotate(720deg);
  }
}

.option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 36px;
  gap: 8px;
  padding: 8px;
  margin-bottom: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

code {
  color: var(--green);
  font-weight: 800;
}

.chooser-pad {
  position: relative;
  min-height: 320px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
  touch-action: none;
  overflow: hidden;
}

.finger-dot {
  position: absolute;
  width: 62px;
  height: 62px;
  margin: -31px 0 0 -31px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

.finger-dot.winner {
  background: var(--yellow);
  color: #231b08;
  transform: scale(1.18);
}

.card-table {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: radial-gradient(circle at top, rgba(23, 107, 93, 0.16), transparent 55%), var(--soft);
  padding: 18px;
}

.playing-card {
  width: min(210px, 100%);
  aspect-ratio: 2.5 / 3.5;
  justify-self: center;
  border-radius: 12px;
  border: 1px solid #d8d4c6;
  background: #fffefa;
  color: #121816;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px;
  box-shadow: 0 18px 35px rgba(22, 32, 29, 0.16);
  font-weight: 900;
}

.playing-card.red,
.mini-deck .red {
  color: #b72721;
}

.playing-card strong {
  place-items: center;
  display: grid;
  font-size: clamp(3rem, 12vw, 6rem);
}

.playing-card span:last-child {
  justify-self: end;
  transform: rotate(180deg);
}

.mini-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-deck span {
  min-width: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px;
  text-align: center;
  font-weight: 900;
}

.rps-arena {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.8fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.rps-arena.online {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rps-online {
  display: grid;
  gap: 12px;
}

.rps-matchbar {
  display: grid;
  grid-template-columns: auto 110px minmax(120px, auto) minmax(120px, auto);
  gap: 10px;
  align-items: center;
}

.rps-room-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 12px;
  font-weight: 800;
}

.rps-room-status.bad {
  color: var(--red);
}

.rps-card {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 14px;
}

.rps-card.you {
  border-color: color-mix(in srgb, var(--green), var(--line) 38%);
}

.rps-card span {
  color: var(--muted);
}

.rps-card strong {
  font-size: clamp(1.6rem, 5vw, 3rem);
}

.rps-card em {
  color: var(--muted);
  font-style: normal;
  text-transform: capitalize;
}

.rps-card b {
  font-size: 1.4rem;
}

.rps-moves {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.rps-move {
  aspect-ratio: auto;
  min-height: 72px;
}

.history {
  align-self: start;
  height: clamp(260px, calc(100vh - 260px), 560px);
  min-height: 260px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-color: var(--green) var(--control);
  scrollbar-width: thin;
}

.history ol::-webkit-scrollbar {
  width: 10px;
}

.history ol::-webkit-scrollbar-track {
  background: var(--control);
  border-radius: 999px;
}

.history ol::-webkit-scrollbar-thumb {
  background: var(--green);
  border: 2px solid var(--control);
  border-radius: 999px;
}

.history li {
  padding: 10px;
  color: var(--muted);
}

.history b {
  display: block;
  color: var(--ink);
}

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

  .history {
    height: min(420px, 70vh);
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .wheel-layout {
    grid-template-columns: 1fr;
  }

  .card-table,
  .rps-arena {
    grid-template-columns: 1fr;
  }

  .rps-arena.online,
  .rps-matchbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    min-height: 76px;
  }

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

  .game-head {
    display: grid;
  }

  .stats,
  .grid.five,
  .cup-board,
  .rps-moves {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .copy-row {
    grid-template-columns: 1fr;
  }
}
