:root {
  --bg-1: #050810;
  --bg-2: #0b1226;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.11);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f6f8ff;
  --muted: rgba(246, 248, 255, 0.68);
  --accent-1: #7c3aed;
  --accent-2: #2563eb;
  --gold: #fbbf24;
  --danger: #fb7185;
  --cR: #e8322a;
  --cY: #e8a100;
  --cG: #22a355;
  --cB: #2f8fe0;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.42);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-x: hidden;
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(1200px 800px at 15% 10%, rgba(124, 58, 237, 0.22), transparent 55%),
    radial-gradient(1000px 700px at 85% 85%, rgba(37, 99, 235, 0.22), transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
}

button {
  font: inherit;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  width: 38vmax;
  height: 38vmax;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.42;
  animation: drift 16s ease-in-out infinite alternate;
}

.blob-1 {
  top: -12vmax;
  left: -9vmax;
  background: radial-gradient(circle at 30% 30%, #7c3aed, transparent 68%);
}

.blob-2 {
  right: -10vmax;
  bottom: -14vmax;
  background: radial-gradient(circle at 30% 30%, #2563eb, transparent 68%);
  animation-delay: -4s;
}

.blob-3 {
  left: 32%;
  bottom: -18vmax;
  width: 26vmax;
  height: 26vmax;
  opacity: 0.2;
  background: radial-gradient(circle at 30% 30%, #f59e0b, transparent 68%);
  animation-delay: -8s;
}

@keyframes drift {
  to {
    transform: translate3d(4vmax, -3vmax, 0) scale(1.08);
  }
}

.app {
  width: min(100%, 640px);
  display: grid;
  gap: 14px;
}

.hud {
  display: grid;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 24px;
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

h1 {
  margin: 0;
  font-size: clamp(22px, 4vw, 32px);
  letter-spacing: 0.045em;
  background: linear-gradient(90deg, #ffffff, #c4b5fd, #7dd3fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 32px rgba(124, 58, 237, 0.22);
}

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

.stat {
  padding: 10px 12px;
  text-align: center;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
}

.label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.value {
  display: inline-block;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.05;
}

.value.bump {
  animation: bump 0.25s ease;
}

@keyframes bump {
  30% {
    transform: scale(1.18);
  }
}

.chip {
  font-size: 26px;
  line-height: 1.05;
}

.chip.cR { color: var(--cR); }
.chip.cY { color: var(--cY); }
.chip.cG { color: #4ade80; }
.chip.cB { color: #7dd3fc; }

.board-wrap {
  position: relative;
  width: min(94vw, 640px);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 14px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

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

.bot {
  flex: 1;
  max-width: 180px;
  padding: 10px 12px;
  text-align: center;
  border-radius: 14px;
  background: rgba(4, 8, 18, 0.35);
  border: 1px solid var(--border);
}

.bot.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}

.bot .bname {
  font-size: 15px;
  font-weight: 800;
}

.bot .bcards {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.center {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
}

.deck {
  position: relative;
  width: 104px;
  height: 148px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(145deg, #2b3564, #171c2b);
  cursor: pointer;
  color: var(--text);
}

.deck:disabled {
  opacity: 0.45;
  cursor: default;
}

.deck-back {
  font-size: 46px;
}

.deck-count {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
}

.slot {
  width: 104px;
  height: 148px;
}

.log {
  min-height: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.hand {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  overflow-x: auto;
  padding: 6px 2px 10px;
}

.card {
  flex: none;
  width: 96px;
  height: 138px;
  border-radius: 14px;
  border: 2px solid rgba(0, 0, 0, 0.55);
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  cursor: default;
  box-shadow: var(--shadow-md);
  transition: transform 0.1s ease;
}

.card.cR { background: linear-gradient(160deg, #f0564a, #b81f14); }
.card.cY { background: linear-gradient(160deg, #f5b81e, #b57e00); }
.card.cG { background: linear-gradient(160deg, #35bd6a, #147a3c); }
.card.cB { background: linear-gradient(160deg, #4aa5ec, #1663ad); }
.card.cW { background: linear-gradient(160deg, #3a3f4c, #14161c); }

.card.playable {
  cursor: pointer;
  border-color: #fff;
}

.card.playable:hover {
  transform: translateY(-8px);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xl);
  background: rgba(5, 8, 16, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

.panel-box {
  width: min(86%, 320px);
  padding: 22px 20px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 12px;
}

.panel-box h2 {
  margin: 0;
  font-size: 24px;
}

.panel-box.slim {
  width: auto;
}

.ov-text {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.opt-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.seg {
  display: flex;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.seg button {
  padding: 8px 14px;
  border: 0;
  background: rgba(4, 8, 18, 0.35);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.seg button.on {
  background: var(--gold);
  color: #0b1226;
}

.color-row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.cdot {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.cdot.cR { background: var(--cR); }
.cdot.cY { background: var(--cY); }
.cdot.cG { background: var(--cG); }
.cdot.cB { background: var(--cB); }

.break {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.note {
  margin: 0;
  min-height: 18px;
  font-size: 12px;
  color: var(--gold);
}

.note:empty {
  display: none;
}

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

.toolbar-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.toolbar-row .btn {
  flex: 1;
  max-width: 200px;
  padding: 12px 14px;
  font-size: 15px;
}

.btn {
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 800;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--border);
  transition: transform 0.08s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.15);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  width: 100%;
  color: #0b1226;
  background: linear-gradient(135deg, var(--gold), #f59e0b);
  border: none;
  box-shadow: 0 10px 26px rgba(245, 158, 11, 0.35);
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.gg-guest {
  position: fixed;
  right: 8px;
  bottom: 6px;
  z-index: 50;
  max-width: 70%;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(10, 6, 24, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #d9d4ec;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  .card {
    width: 68px;
    height: 98px;
    font-size: 22px;
  }

  .slot,
  .deck {
    width: 76px;
    height: 108px;
  }
}
