:root {
  --bg-deep: #0e071b;
  --bg-alley: #1a0f30;
  --panel-bg: rgba(30, 18, 53, 0.88);
  --panel-border: rgba(160, 107, 255, 0.32);
  --text: #f7f4ff;
  --muted: #b3a4d4;
  --neon-pink: #ff2d95;
  --neon-orange: #ff9f1c;
  --neon-cyan: #2ec4b6;
  --neon-green: #39d353;
  --danger: #ff3b3b;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg-deep);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background-color: #0e061c;
  background-image:
    radial-gradient(circle at 50% 15%, rgba(255, 159, 28, 0.16) 0%, transparent 48%),
    linear-gradient(180deg, rgba(11, 5, 24, 0.42) 0%, rgba(16, 8, 34, 0.72) 55%, rgba(8, 3, 18, 0.92) 100%),
    url('bg-alley.webp');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#root {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

button,
input {
  font: inherit;
  color: inherit;
}

.app {
  max-width: 480px;
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(env(safe-area-inset-top, 0px), 48px) 8px max(env(safe-area-inset-bottom, 0px), 44px);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 4px;
  font-size: 0.82rem;
}

.net {
  padding: 4px 11px;
  border-radius: 999px;
  font-weight: 700;
  background: rgba(18, 9, 36, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
}
.net-online {
  color: var(--neon-green);
}
.net-connecting,
.net-reconnecting {
  color: var(--neon-orange);
}
.net-offline-mode {
  color: #7dd3fc;
}

.topcode {
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--neon-orange);
  background: rgba(255, 159, 28, 0.18);
  border: 1px solid rgba(255, 159, 28, 0.4);
  padding: 3px 10px;
  border-radius: 999px;
}

.icon-btn {
  background: rgba(20, 10, 40, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

/* ── Home & Lobby ── */
.home,
.lobby {
  display: flex;
  flex-direction: column;
  gap: 13px;
  flex: 1;
  justify-content: center;
  padding: 4px 0 16px;
}

.home-hero {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: -4px 0 2px;
}

.home-logo {
  width: min(100%, 390px);
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 18px rgba(255, 45, 149, 0.32));
  animation: heroFloat 3.6s ease-in-out infinite alternate;
}

@keyframes heroFloat {
  from {
    transform: translateY(0px);
  }
  to {
    transform: translateY(-5px);
  }
}

.panel {
  background: linear-gradient(165deg, rgba(40, 22, 72, 0.88) 0%, rgba(20, 10, 40, 0.92) 100%);
  border: 1.5px solid rgba(185, 135, 255, 0.38);
  border-top-color: rgba(255, 210, 125, 0.45);
  border-radius: 20px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.field input,
.join input {
  background: rgba(10, 5, 22, 0.8);
  border: 1.5px solid rgba(160, 107, 255, 0.4);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  outline: none;
}
.field input:focus,
.join input:focus {
  border-color: var(--neon-orange);
  box-shadow: 0 0 0 3px rgba(255, 159, 28, 0.22);
}

.avatars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.avatars button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  padding: 6px 4px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.avatars button .avatar-img {
  width: 58px;
  height: 58px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.avatars button small {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
}
.avatars button.on {
  border-color: var(--neon-orange);
  background: rgba(255, 159, 28, 0.2);
  box-shadow: 0 0 14px rgba(255, 159, 28, 0.45);
  transform: translateY(-2px) scale(1.04);
}
.avatars button.on .avatar-img {
  border-color: var(--neon-orange);
}
.avatars button.on small {
  color: #fff;
}

.avatar-img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: inherit;
  object-fit: cover;
  display: block;
}
.dead-skull {
  font-size: 1.35rem;
  line-height: 1;
}

.join {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.offline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 3px 6px;
}
.stepper button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 800;
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  border: none;
  border-radius: 13px;
  padding: 11px 16px;
  font-weight: 800;
  font-size: 0.96rem;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-big {
  padding: 14px 18px;
  font-size: 1.05rem;
}
.btn-primary {
  background: linear-gradient(135deg, #ff9f1c, #ff2d95);
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 45, 149, 0.38);
}
.btn-secondary {
  background: linear-gradient(135deg, #2ec4b6, #3b82f6);
  color: #fff;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.btn-link {
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}
.btn-nope {
  background: linear-gradient(135deg, #ff2d55, #ff9f1c);
  color: #fff;
  box-shadow: 0 0 18px rgba(255, 45, 85, 0.7);
  animation: pulse 0.7s infinite alternate;
}

/* ── Lobby ── */
.code-panel {
  align-items: center;
  text-align: center;
}
.room-code {
  font-size: 2.6rem;
  letter-spacing: 0.18em;
  color: var(--neon-orange);
  text-shadow: 0 0 16px rgba(255, 159, 28, 0.45);
}
.members {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.members li {
  --pcolor: #38bdf8;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid color-mix(in srgb, var(--pcolor) 42%, transparent);
  border-radius: 12px;
}
.members .avatar {
  width: 40px;
  height: 40px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--pcolor);
  background: color-mix(in srgb, var(--pcolor) 18%, #120724);
  box-shadow: 0 0 10px color-mix(in srgb, var(--pcolor) 45%, transparent);
  overflow: hidden;
  flex-shrink: 0;
}
.members .avatar .avatar-img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  object-fit: cover;
}
.members .mname {
  flex: 1;
  font-weight: 800;
  color: var(--pcolor);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(160, 107, 255, 0.25);
}
.tag.warn {
  background: rgba(255, 59, 59, 0.28);
  color: #ff9c9c;
}

/* ── Game table (100% single screen fit, zero scroll) ── */
.game {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: clamp(4px, 1vh, 8px);
  overflow: hidden;
}

.opponents {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 4px;
  justify-content: center;
  flex-shrink: 0;
}

.opp {
  --pcolor: #38bdf8;
  background: linear-gradient(180deg, color-mix(in srgb, var(--pcolor) 14%, rgba(22, 11, 42, 0.9)), rgba(16, 8, 32, 0.94));
  border: 1.5px solid color-mix(in srgb, var(--pcolor) 48%, rgba(255, 255, 255, 0.14));
  border-radius: 11px;
  padding: 2px 2px 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.opp.turn {
  border-color: var(--pcolor);
  box-shadow:
    0 0 0 1.5px var(--pcolor),
    0 0 12px color-mix(in srgb, var(--pcolor) 68%, transparent);
}
.opp.pickable {
  border-color: var(--neon-cyan);
  background: rgba(46, 196, 182, 0.22);
  cursor: pointer;
  animation: pulse 0.65s infinite alternate;
}
.opp.dead {
  opacity: 0.45;
}
.opp.dead .opp-avatar {
  filter: grayscale(0.8) brightness(0.65);
  border-color: #64748b;
}
.opp-avatar {
  width: clamp(34px, 5.2vh, 46px);
  height: clamp(34px, 5.2vh, 46px);
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--pcolor);
  background: color-mix(in srgb, var(--pcolor) 22%, #130726);
  box-shadow: 0 0 8px color-mix(in srgb, var(--pcolor) 50%, transparent);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.opp-avatar .avatar-img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  object-fit: cover;
}
.badge-off,
.badge-bot {
  font-style: normal;
  font-size: 0.65rem;
  position: absolute;
  right: 1px;
  bottom: 1px;
  background: rgba(15, 6, 30, 0.92);
  border-radius: 4px;
  padding: 1px 2px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  line-height: 1;
  z-index: 2;
}
.opp-name {
  font-size: 0.64rem;
  font-weight: 800;
  color: var(--pcolor);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.opp-cards {
  font-size: 0.64rem;
  color: #fff;
  font-weight: 800;
}
.opp-target {
  position: absolute;
  top: 2px;
  right: 2px;
}

/* ── Center Table (Card Back Deck + Discard) ── */
.table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 50%, rgba(160, 107, 255, 0.16), rgba(16, 9, 30, 0.85));
  border: 1.5px solid rgba(160, 107, 255, 0.35);
  flex-shrink: 0;
  height: clamp(96px, 15.5vh, 126px);
  max-height: clamp(96px, 15.5vh, 126px);
}

.deck-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.deck-card-stack {
  position: relative;
  height: clamp(86px, 14vh, 114px);
  width: calc(clamp(86px, 14vh, 114px) * 0.71);
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}
.deck-card-stack::before,
.deck-card-stack::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: #1c0c36;
  border: 1.5px solid rgba(255, 159, 28, 0.45);
  z-index: 0;
}
.deck-card-stack::before {
  transform: translate(3px, 3px) rotate(2deg);
}
.deck-card-stack::after {
  transform: translate(1.5px, 1.5px) rotate(1deg);
}
.deck-card-stack.ready {
  filter: drop-shadow(0 0 14px rgba(255, 159, 28, 0.65));
  animation: pulse 0.9s infinite alternate;
}
.deck-card-stack:disabled {
  cursor: default;
  opacity: 0.88;
}
.deck-back-img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
}
.deck-badge-top {
  position: absolute;
  z-index: 2;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  background: #140726;
  border: 1.5px solid var(--neon-orange);
  color: #fff;
  font-weight: 900;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}
.deck-badge-bottom {
  position: absolute;
  z-index: 2;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  background: #140726;
  border: 1.5px solid var(--neon-cyan);
  color: var(--text);
  font-weight: 800;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}
.deck-badge-bottom.hot {
  border-color: var(--danger);
  background: #3b0714;
  color: #ffb3b3;
}

.discard {
  height: clamp(86px, 14vh, 114px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.discard-card {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.center-feed {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status {
  flex: 1;
  margin: 0;
  text-align: center;
  font-weight: 800;
  font-size: clamp(0.72rem, 1.4vh, 0.82rem);
  padding: 4px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.center-log {
  width: 100%;
  text-align: left;
  background: rgba(14, 7, 27, 0.78);
  border: 1px solid rgba(160, 107, 255, 0.3);
  border-radius: 9px;
  padding: 3px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
.center-log-line {
  font-size: clamp(0.66rem, 1.25vh, 0.72rem);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.center-log-line.latest {
  color: #fff;
  font-weight: 700;
}

/* ── Pending / Nope bar ── */
.pending {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(255, 45, 149, 0.14);
  border: 1.5px solid var(--neon-pink);
  flex-shrink: 0;
}
.pending-card {
  position: relative;
}
.nope-stamp {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.1rem;
  color: #fff;
  background: rgba(255, 0, 68, 0.65);
  border-radius: 10px;
  transform: rotate(-12deg);
}
.pending-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.timer {
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  overflow: hidden;
}
.timer > div {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-orange), var(--neon-pink));
  animation: shrink linear forwards;
}
@keyframes shrink {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

/* ── Cards (Restored comfortable dimensions from web version) ── */
.card {
  --accent: #ff9f1c;
  width: 120px;
  height: 168px;
  border-radius: 14px;
  border: 2px solid var(--accent);
  background: linear-gradient(180deg, #24153f 0%, #120924 100%);
  padding: 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.55);
  flex-shrink: 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
  user-select: none;
}
.card-sm {
  width: 92px;
  height: 124px;
  padding: 4px;
  border-radius: 11px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 3px;
  overflow: hidden;
}
.card.selected {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 8px 18px rgba(255, 159, 28, 0.55);
}
.card-title {
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.15;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 4px;
  border-radius: 6px;
  white-space: normal;
  word-break: normal;
  text-align: center;
  min-height: 2.3em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-sm .card-title {
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1.12;
  padding: 2px 3px;
  border-radius: 5px;
  white-space: normal;
  word-break: normal;
  text-align: center;
  min-height: 2.3em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-art {
  width: 100%;
  height: 84px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}
.card-sm .card-art {
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}
.card-text {
  font-size: 0.62rem;
  line-height: 1.14;
  color: #e4dbff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-shrink: 0;
}

/* ── Hand & Actionbar ── */
.actionbar {
  min-height: 34px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.sel-rule {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.hand {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px 6px 12px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  height: 192px;
  box-sizing: border-box;
}
.hand.tight .card:not(:first-child) {
  margin-left: -20px;
}

/* ── Modals (Centrally positioned fixed overlays) ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 3, 18, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: env(safe-area-inset-top, 14px) 14px env(safe-area-inset-bottom, 14px);
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  animation: fadeIn 0.18s ease-out;
}
.modal {
  border: 1.5px solid var(--panel-border);
  border-radius: 20px;
  background: #1a0f30;
  color: var(--text);
  padding: 16px;
  width: min(92vw, 400px);
  max-height: min(84dvh, 560px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(160, 107, 255, 0.2);
  display: flex;
  flex-direction: column;
  margin: auto;
  box-sizing: border-box;
  overflow-y: auto;
}
.modal h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}
.modal-title-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.game-over-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 10px 0 14px;
}
.game-over-avatar-wrap {
  position: relative;
  width: clamp(64px, 11vh, 82px);
  height: clamp(64px, 11vh, 82px);
  border-radius: 16px;
  border: 3px solid var(--neon-orange);
  box-shadow: 0 0 20px rgba(255, 159, 28, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #15082a;
}
.game-over-avatar-wrap .avatar-img {
  border-radius: 13px;
}
.game-over-crown {
  position: absolute;
  top: -18px;
  filter: drop-shadow(0 0 8px #ffd166);
  animation: floatBounce 1.5s ease-in-out infinite alternate;
}
@keyframes floatBounce {
  0% { transform: translateY(0) rotate(-3deg); }
  100% { transform: translateY(-5px) rotate(3deg); }
}
.game-over-tagline {
  font-size: 1.1rem;
  font-weight: 900;
  color: #ffe169;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  margin: 0;
  text-align: center;
}
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 10px 0;
}
.future {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 12px 0;
}
.future-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.rules {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rules li {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.82rem;
}
.log {
  padding-left: 18px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.range {
  width: 100%;
  margin: 10px 0;
}
.defuse-art {
  display: flex;
  justify-content: center;
}

/* ── Helpers & Overlays ── */
.row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.row.between {
  justify-content: space-between;
}
.row.wrap {
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.78rem;
}
.center {
  text-align: center;
}
.big-emoji {
  font-size: 3rem;
  text-align: center;
  margin: 8px 0;
}

.toasts {
  position: fixed;
  bottom: 220px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 50;
  pointer-events: none;
  width: min(92vw, 400px);
}
.toast {
  background: rgba(20, 11, 39, 0.95);
  border: 1px solid var(--panel-border);
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}
.toast.bad {
  border-color: var(--danger);
}
.toast.good {
  border-color: var(--neon-green);
}

/* ── Comic "BOOM" Explosion Animation ── */
.comic-boom-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px);
  pointer-events: auto;
  overflow-y: auto;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.comic-boom-overlay.dead {
  background: radial-gradient(circle at center, rgba(239, 68, 68, 0.52) 0%, rgba(20, 5, 30, 0.96) 75%);
  animation: flashRed 0.4s ease-out;
}
.comic-boom-overlay.saved {
  background: radial-gradient(circle at center, rgba(34, 197, 94, 0.48) 0%, rgba(10, 25, 20, 0.96) 75%);
  animation: flashGreen 0.4s ease-out;
}

@keyframes flashRed {
  0% { background-color: rgba(255, 255, 255, 0.92); }
  30% { background-color: rgba(255, 60, 0, 0.75); }
  100% { background-color: transparent; }
}
@keyframes flashGreen {
  0% { background-color: rgba(255, 255, 255, 0.92); }
  30% { background-color: rgba(34, 197, 94, 0.75); }
  100% { background-color: transparent; }
}

/* Screen shake during bomb explosion */
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-7px, 4px) rotate(-1.5deg); }
  20%, 40%, 60%, 80% { transform: translate(7px, -4px) rotate(1.5deg); }
}
.game.shake {
  animation: screenShake 0.7s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Rotating comic sunburst rays */
.comic-starburst-spin {
  position: absolute;
  width: 170vmax;
  height: 170vmax;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 200, 0, 0.18) 0deg 12deg,
    transparent 12deg 24deg
  );
  animation: starburstSpin 14s linear infinite;
  pointer-events: none;
}
.comic-boom-overlay.saved .comic-starburst-spin {
  background: repeating-conic-gradient(
    from 0deg,
    rgba(52, 211, 153, 0.2) 0deg 12deg,
    transparent 12deg 24deg
  );
}
@keyframes starburstSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Shockwave expanding ring */
.comic-shockwave-ring {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 6px solid #ffcc00;
  box-shadow: 0 0 35px #ff5500, inset 0 0 30px #ffcc00;
  animation: shockwaveExpand 1.1s cubic-bezier(0.15, 0.9, 0.25, 1) forwards;
  pointer-events: none;
}
@keyframes shockwaveExpand {
  0% { transform: scale(0.2); opacity: 1; border-width: 12px; }
  70% { opacity: 0.85; border-width: 6px; }
  100% { transform: scale(14); opacity: 0; border-width: 1px; }
}

/* Comic content container */
.comic-boom-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: min(92vw, 420px);
  width: 100%;
  margin: auto;
  animation: comicContentPop 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes comicContentPop {
  0% { transform: scale(0.2) rotate(-8deg); opacity: 0; }
  70% { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.comic-boom-graphic-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 40vh;
}
.comic-boom-art {
  width: min(74vw, 290px);
  max-height: 36vh;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  filter: drop-shadow(0 0 25px rgba(255, 110, 0, 0.85)) drop-shadow(0 12px 28px rgba(0, 0, 0, 0.95));
  animation: boomPulse 1.2s ease-in-out infinite alternate;
}
@keyframes boomPulse {
  0% { transform: scale(1) rotate(-1.5deg); }
  100% { transform: scale(1.06) rotate(1.5deg); }
}

/* Action word badges popping out around BOOM */
.comic-burst-words {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.comic-word {
  position: absolute;
  font-family: inherit;
  font-weight: 900;
  font-size: 1.1rem;
  padding: 4px 10px;
  border-radius: 8px;
  border: 3px solid #111;
  box-shadow: 4px 4px 0 #111;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: popSpark 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.comic-word.w1 {
  top: -8px;
  left: -12px;
  background: #ffeb3b;
  color: #111;
  transform: rotate(-16deg);
  animation-delay: 0.12s;
}
.comic-word.w2 {
  top: -10px;
  right: -10px;
  background: #ff5722;
  color: #fff;
  transform: rotate(14deg);
  animation-delay: 0.18s;
}
.comic-word.w3 {
  bottom: 8px;
  left: -12px;
  background: #e91e63;
  color: #fff;
  transform: rotate(-10deg);
  animation-delay: 0.22s;
}
.comic-word.w4 {
  bottom: 6px;
  right: -10px;
  background: #00e676;
  color: #111;
  transform: rotate(14deg);
  animation-delay: 0.26s;
}
.comic-word.w5 {
  top: 45%;
  left: -18px;
  background: #00e5ff;
  color: #111;
  transform: rotate(-8deg);
  animation-delay: 0.3s;
}
@keyframes popSpark {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.25); opacity: 1; }
  100% { opacity: 1; }
}

/* Character & Outcome banner card */
.comic-boom-banner {
  --pcolor: #ff3b3b;
  width: 100%;
  background: rgba(18, 7, 34, 0.95);
  border: 3px solid color-mix(in srgb, var(--pcolor) 65%, #fff);
  box-shadow:
    0 0 0 2px #110424,
    0 8px 30px rgba(0, 0, 0, 0.8),
    0 0 24px color-mix(in srgb, var(--pcolor) 50%, transparent);
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comic-boom-player {
  display: flex;
  align-items: center;
  gap: 12px;
}
.comic-boom-avatar {
  width: 56px;
  height: 56px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 2.5px solid var(--pcolor);
  box-shadow: 0 0 12px color-mix(in srgb, var(--pcolor) 55%, transparent);
  flex-shrink: 0;
}
.comic-boom-avatar .avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 9px;
  object-fit: cover;
}
.comic-boom-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.comic-boom-pname {
  font-size: 1.05rem;
  font-weight: 900;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.comic-boom-subtitle {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--pcolor);
  letter-spacing: 0.04em;
}
.comic-banner-badge {
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
}
.comic-banner-badge.saved-badge {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.25), rgba(16, 185, 129, 0.15));
  border: 2px solid #22c55e;
}
.comic-banner-badge.dead-badge {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.28), rgba(220, 38, 38, 0.15));
  border: 2px solid #ef4444;
}
.badge-title {
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.02em;
}
.badge-desc {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.3;
}
.comic-boom-action-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}
.comic-boom-action-btn {
  width: 100%;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
}
.comic-boom-action-btn.btn-primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: #4ade80;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.55);
}
.comic-boom-tap-hint {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  letter-spacing: 0.02em;
}

@keyframes pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.04);
  }
}

/* ── Rules Button & Full Illustrated Rules Modal ── */
.btn-rules {
  background: linear-gradient(135deg, rgba(160, 107, 255, 0.28), rgba(46, 196, 182, 0.25));
  border: 1.5px solid rgba(160, 107, 255, 0.55);
  color: #fff;
}

.rules-modal[open] {
  width: min(95vw, 460px);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.rules-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 4px;
  margin-bottom: 12px;
}

.rules-sec {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px;
}
.rules-sec h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--neon-orange);
}
.rules-sec p {
  margin: 0 0 8px;
  font-size: 0.84rem;
  line-height: 1.4;
}
.rules-bullets {
  margin: 0;
  padding-left: 18px;
  font-size: 0.82rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.step-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(0, 0, 0, 0.25);
  padding: 9px 10px;
  border-radius: 11px;
}
.step-num {
  background: var(--neon-pink);
  color: #fff;
  font-weight: 900;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.step-item b {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 3px;
}
.step-item p {
  margin: 0;
  font-size: 0.79rem;
  color: var(--muted);
}

.vs-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.vs-card {
  padding: 9px;
  border-radius: 11px;
  font-size: 0.78rem;
}
.vs-card b {
  display: block;
  margin-bottom: 4px;
}
.vs-card p {
  margin: 0;
  font-size: 0.75rem;
}
.vs-card.good {
  background: rgba(57, 211, 83, 0.12);
  border: 1px solid rgba(57, 211, 83, 0.4);
}
.vs-card.bad {
  background: rgba(255, 59, 59, 0.12);
  border: 1px solid rgba(255, 59, 59, 0.4);
}

.rules-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rules-card-row {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(0, 0, 0, 0.28);
  padding: 8px;
  border-radius: 12px;
}
.rules-card-info {
  flex: 1;
}
.rules-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.rules-cat {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--neon-cyan);
}
.rules-count {
  font-size: 0.68rem;
  color: var(--muted);
}
.rules-card-info h4 {
  margin: 0 0 3px;
  font-size: 0.9rem;
}
.rules-card-info p {
  margin: 0;
  font-size: 0.76rem;
  color: #ddd2f8;
  line-height: 1.32;
}

/* ── Newly Drawn Card in Hand & Bot Turn Pacing ── */
.card {
  position: relative;
}
.card.dim {
  opacity: 0.25;
  transform: scale(0.92);
}
.card.card-new {
  box-shadow:
    0 0 0 2.5px #ffe169,
    0 0 22px rgba(255, 196, 0, 0.75);
  animation: newCardLand 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.card-new-badge {
  position: absolute;
  top: -9px;
  right: -5px;
  z-index: 3;
  background: linear-gradient(135deg, #ffe169, #ff9f1c);
  color: #1a0933;
  font-weight: 900;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}
@keyframes newCardLand {
  0% {
    transform: translateY(-28px) scale(1.12);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.opp-thinking {
  font-size: 0.66rem;
  color: #ffe169;
  font-weight: 800;
  background: rgba(255, 159, 28, 0.2);
  border-radius: 999px;
  padding: 1px 6px;
  animation: pulse 0.65s infinite alternate;
}

.deck-wrap {
  position: relative;
}
.bot-draw-fly {
  position: absolute;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  animation: botDrawAnim 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.bot-draw-fly img {
  width: 78px;
  height: 110px;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.75);
  border: 2px solid var(--neon-orange);
}
.bot-draw-fly span {
  background: rgba(20, 9, 38, 0.92);
  border: 1px solid var(--neon-orange);
  color: #ffe169;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
@keyframes botDrawAnim {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
  65% {
    opacity: 1;
    transform: translateY(-95px) scale(0.88) rotate(-8deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-135px) scale(0.55) rotate(-14deg);
  }
}

/* ── 2/3-Screen Card Draw Reveal Overlay (2s hold + fly to hand) ── */
.draw-reveal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 3, 18, 0.76);
  backdrop-filter: blur(5px);
  padding: 16px;
  transition: background 0.38s ease, backdrop-filter 0.38s ease;
  cursor: pointer;
}
.draw-reveal-backdrop.to-hand {
  background: rgba(8, 3, 18, 0);
  backdrop-filter: blur(0px);
  pointer-events: none;
}

.draw-reveal-card {
  --accent: #ff9f1c;
  width: min(86vw, 350px);
  height: 66dvh;
  max-height: 540px;
  min-height: 370px;
  border-radius: 24px;
  border: 3.5px solid var(--accent);
  background: linear-gradient(180deg, #2b174d 0%, #140928 100%);
  box-shadow:
    0 22px 55px rgba(0, 0, 0, 0.85),
    0 0 38px color-mix(in srgb, var(--accent) 60%, transparent);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  gap: 8px;
  transform-origin: center center;
}

.draw-reveal-card.reveal {
  animation: drawFlyFromDeck 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.08) forwards;
}

.draw-reveal-card.to-hand {
  animation: drawFlyToHand 0.46s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes drawFlyFromDeck {
  0% {
    opacity: 0.15;
    transform: translate(-30vw, -12vh) scale(0.25) rotateY(70deg) rotateZ(-12deg);
  }
  60% {
    opacity: 1;
    transform: translate(0, 0) scale(1.05) rotateY(0deg) rotateZ(1deg);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotateY(0deg) rotateZ(0deg);
  }
}

@keyframes drawFlyToHand {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotateZ(0deg);
  }
  40% {
    opacity: 0.9;
    transform: translate(0, 16vh) scale(0.68) rotateZ(2deg);
  }
  100% {
    opacity: 0;
    transform: translate(0, 48vh) scale(0.22) rotateZ(4deg);
  }
}

.draw-reveal-tag {
  background: var(--accent);
  color: #140726;
  font-weight: 900;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 3px 12px;
  border-radius: 999px;
}

.draw-reveal-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.draw-reveal-art-wrap {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: #0d051a;
}

.draw-reveal-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.draw-reveal-rule {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  color: #f2ecff;
  background: rgba(0, 0, 0, 0.38);
  padding: 8px 12px;
  border-radius: 12px;
  width: 100%;
}

.draw-reveal-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.draw-reveal-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #fff);
  animation: shrink 2s linear forwards;
}

/* ── Player Color Tags (in Log, Status & Hand Header) ── */
.p-name-tag {
  --pcolor: #38bdf8;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--pcolor);
  font-weight: 800;
  background: color-mix(in srgb, var(--pcolor) 16%, rgba(12, 5, 24, 0.7));
  border: 1px solid color-mix(in srgb, var(--pcolor) 45%, transparent);
  padding: 0 6px;
  border-radius: 999px;
  margin: 0 2px;
  vertical-align: baseline;
}

.p-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pcolor);
  box-shadow: 0 0 6px var(--pcolor);
  flex-shrink: 0;
}

.my-hand-area {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: auto;
  padding-bottom: 12px;
}

.my-player-bar {
  --pcolor: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px;
  border-radius: 10px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--pcolor) 16%, rgba(20, 10, 40, 0.85)), rgba(20, 10, 40, 0.75));
  border: 1px solid color-mix(in srgb, var(--pcolor) 45%, transparent);
  font-size: 0.74rem;
}

.my-player-id {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.my-avatar-ring {
  width: 28px;
  height: 28px;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--pcolor);
  background: color-mix(in srgb, var(--pcolor) 20%, #120724);
  box-shadow: 0 0 6px color-mix(in srgb, var(--pcolor) 50%, transparent);
  overflow: hidden;
  flex-shrink: 0;
}
.my-avatar-ring .avatar-img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  object-fit: cover;
}

.my-card-count {
  font-weight: 800;
  color: #fff;
}
