/* ==========================================================================
   BUCKSHOT ROULETTE — Dark Industrial Horror & Cyberpunk CRT Stylesheet
   ========================================================================== */

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

:root {
  --bg-0: #060709;
  --bg-1: #0e1014;
  --bg-2: #181b22;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f0f0f3;
  --text-dim: #8b8e99;
  --accent: #ff6a00;
  --accent-glow: rgba(255, 106, 0, 0.45);
  --live: #ff3333;
  --blank: #38b6ff;
  --defib-on: #2cf07d;
  --defib-off: rgba(255, 255, 255, 0.12);
  --defib-crit: #ff2233;
}

html, body {
  height: 100%;
  background: #060709;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* ---------------- CRT Scanlines & Screen Atmosphere ---------------- */
.crt-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.28) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.03)
  );
  background-size: 100% 4px, 6px 100%;
  opacity: 0.85;
}

.damage-flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: radial-gradient(circle, transparent 35%, rgba(255, 0, 0, 0.6) 80%, rgba(120, 0, 0, 0.9) 100%);
  opacity: 0;
  transition: opacity 0.08s ease-out;
}
.damage-flash-overlay.active {
  animation: damage-strobe 0.45s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}
@keyframes damage-strobe {
  0% { opacity: 1; transform: scale(1.04); }
  40% { opacity: 0.8; }
  100% { opacity: 0; transform: scale(1); }
}

.muzzle-flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 85;
  background: rgba(255, 240, 200, 0.4);
  opacity: 0;
  transition: opacity 0.05s ease-out;
}
.muzzle-flash-overlay.active {
  animation: muzzle-strobe 0.22s ease-out forwards;
}
@keyframes muzzle-strobe {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(10, 11, 14, 0.75);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
  backdrop-filter: blur(10px);
}
.brand {
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 1.15rem;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}
.brand-sub {
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 3px;
  font-weight: 700;
}
.round-pill {
  background: rgba(255, 106, 0, 0.15);
  border: 1px solid rgba(255, 106, 0, 0.5);
  color: var(--accent);
  padding: 4px 16px;
  border-radius: 20px;
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 2px;
  box-shadow: 0 0 16px var(--accent-glow);
}
.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.08);
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s;
}
.btn:active { transform: translateY(3px); }
.btn-arcade {
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.8);
}
.btn-arcade:active {
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.8);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ff8f3d);
  color: #0d0600;
  border: 1px solid #ffb27a;
  box-shadow: 0 6px 20px rgba(255, 106, 0, 0.4);
}
.btn-primary:hover {
  box-shadow: 0 8px 30px rgba(255, 106, 0, 0.65);
  filter: brightness(1.1);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}
.btn-big {
  padding: 16px 36px;
  font-size: 1.1rem;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------------- Screens ---------------- */
.screen { display: none; flex: 1; }
.screen.show { display: flex; }

/* ---------------- Home Screen ---------------- */
#screen-home {
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #161820 0%, #050608 75%);
}
.home-wrap {
  text-align: center;
  max-width: 580px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.home-badge {
  background: rgba(255, 106, 0, 0.12);
  border: 1px solid rgba(255, 106, 0, 0.4);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 3px;
  padding: 6px 14px;
  border-radius: 20px;
}
.home-title {
  font-size: 4.6rem;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(255, 106, 0, 0.35);
}
.home-title .accent { color: var(--accent); }
.home-sub {
  color: var(--text-dim);
  line-height: 1.6;
  font-size: 1.05rem;
  margin-bottom: 8px;
}
.mode-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.join-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.join-input {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 4px;
  width: 170px;
  text-align: center;
  font-weight: 900;
  font-size: 1.1rem;
}
.join-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}
.home-footer-links { margin-top: 12px; }
.home-error { color: var(--live); font-size: 0.88rem; min-height: 1.2em; font-weight: 700; }

/* ---------------- Rules Screen ---------------- */
#screen-rules {
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background: #0a0b0e;
}
.rules-wrap {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0 40px;
}
.rules-header h2 { font-size: 2rem; font-weight: 900; }
.rules-sub { color: var(--accent); font-weight: 700; font-size: 0.88rem; letter-spacing: 1px; }
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
}
.rules-list li {
  background: var(--bg-1);
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 0.94rem;
}
.items-title {
  font-size: 1.3rem;
  font-weight: 900;
  margin-top: 8px;
  color: var(--accent);
}
.rules-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.rule-item-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.rule-item-card .ri-icon { font-size: 2rem; margin-bottom: 4px; }
.rule-item-card .ri-name { font-weight: 900; font-size: 0.92rem; color: #fff; }
.rule-item-card .ri-desc { color: var(--text-dim); font-size: 0.78rem; margin-top: 6px; line-height: 1.4; }

/* ---------------- Character Creator ---------------- */
#screen-creator { flex-direction: row; }
.creator-wrap { display: flex; width: 100%; flex: 1; }
.creator-preview { flex: 1; position: relative; background: radial-gradient(circle at 50% 35%, #181b22, #060709 80%); }
.creator-preview canvas { width: 100%; height: 100%; display: block; }
.creator-panel {
  width: 400px;
  max-width: 44vw;
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.creator-panel h2 { font-size: 1.4rem; font-weight: 900; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 0.8rem; color: var(--text-dim); font-weight: 800; text-transform: uppercase; }
.field input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-weight: 700;
}
.swatch-group { display: flex; flex-direction: column; gap: 8px; }
.swatch-label { font-size: 0.8rem; color: var(--text-dim); font-weight: 800; text-transform: uppercase; }
.swatch-row, .option-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.swatch:hover { transform: scale(1.15); }
.swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: scale(1.1);
}
.option-chip {
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  text-transform: capitalize;
  transition: all 0.12s;
}
.option-chip:hover { color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.option-chip.selected {
  border-color: var(--accent);
  color: #fff;
  background: rgba(255, 106, 0, 0.18);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ---------------- Lobby Screen ---------------- */
#screen-lobby { align-items: center; justify-content: center; background: #060709; }
.lobby-wrap {
  text-align: center;
  max-width: 520px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}
.lobby-wrap h2 { font-size: 2rem; font-weight: 900; }
.room-code-box {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 24px;
}
.room-code-box span { font-size: 0.75rem; color: var(--text-dim); letter-spacing: 2px; font-weight: 800; }
.room-code-box strong { font-size: 2rem; letter-spacing: 6px; color: var(--accent); }
.lobby-seats { display: flex; gap: 20px; }
.lobby-seat {
  width: 130px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.lobby-seat .seat-avatar { width: 54px; height: 54px; border-radius: 50%; box-shadow: 0 0 16px rgba(0, 0, 0, 0.8); }
.lobby-seat span { font-weight: 800; font-size: 0.95rem; }
.lobby-seat.empty { opacity: 0.4; border-style: dashed; }
.lobby-hint { color: var(--text-dim); font-size: 0.9rem; max-width: 360px; line-height: 1.5; }

/* ---------------- Game Screen ---------------- */
#screen-game {
  flex-direction: column;
  position: relative;
  padding: 10px 20px 16px;
  gap: 8px;
  background: #06070a;
}
.opp-row, .me-row {
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 10;
}
.me-row { flex-direction: row-reverse; }

/* ---------------- Retro CRT Defibrillator Monitors ---------------- */
.crt-monitor {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
  background: linear-gradient(135deg, #091a12, #040906);
  border: 2px solid rgba(44, 240, 125, 0.4);
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: inset 0 0 20px rgba(44, 240, 125, 0.15), 0 0 18px rgba(44, 240, 125, 0.2);
  position: relative;
  overflow: hidden;
}
.crt-monitor.mine {
  border-color: rgba(255, 106, 0, 0.45);
  background: linear-gradient(135deg, #1c0e06, #090502);
  box-shadow: inset 0 0 20px rgba(255, 106, 0, 0.15), 0 0 18px var(--accent-glow);
}
.crt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.crt-label {
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  color: #a4f5c5;
  font-weight: 900;
  text-transform: uppercase;
}
.crt-monitor.mine .crt-label { color: #ffc299; }
.crt-status {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--defib-on);
  letter-spacing: 1px;
}
.crt-charges {
  display: flex;
  gap: 6px;
  align-items: center;
}
.charge-cell {
  width: 22px;
  height: 26px;
  border-radius: 4px;
  background: var(--defib-on);
  border: 1px solid #7affb5;
  box-shadow: 0 0 10px rgba(44, 240, 125, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #003311;
  font-weight: 900;
  transition: all 0.2s;
}
.charge-cell.lost {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: none;
  color: rgba(255, 255, 255, 0.2);
}

/* ---------------- Item Trays ---------------- */
.item-tray {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-height: 52px;
  align-items: center;
}
.item-chip {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-1);
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  position: relative;
  cursor: default;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.item-chip.usable {
  cursor: pointer;
  border-color: rgba(255, 106, 0, 0.6);
  background: linear-gradient(135deg, rgba(255, 106, 0, 0.15), var(--bg-1));
  box-shadow: 0 4px 12px rgba(255, 106, 0, 0.2);
}
.item-chip.usable:hover {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 8px 24px rgba(255, 106, 0, 0.5);
  border-color: #ff9d4d;
}
.item-chip.disabled { opacity: 0.35; }
.item-chip .item-tooltip {
  position: absolute;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
  background: #060709;
  border: 1px solid var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 40;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.8);
}
.item-chip:hover .item-tooltip { opacity: 1; }

.cuffed-badge {
  background: #2a0f05;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 900;
  padding: 6px 12px;
  border-radius: 10px;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 0.2s;
}
.cuffed-badge.show { opacity: 1; }

/* ---------------- 3D Table Scene Container ---------------- */
.table-scene {
  flex: 1;
  position: relative;
  min-height: 320px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.9);
}
.table-scene canvas { width: 100%; height: 100%; display: block; }

/* ---------------- Shell Counter HUD ---------------- */
.shell-counter {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 15;
}
.shell-pip {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 1px;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}
.shell-pip.live {
  background: rgba(255, 40, 40, 0.25);
  color: #ff6666;
  border: 1.5px solid rgba(255, 60, 60, 0.6);
}
.shell-pip.blank {
  background: rgba(40, 160, 255, 0.25);
  color: #66ccff;
  border: 1.5px solid rgba(60, 180, 255, 0.6);
}
.shell-pip.total {
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.shell-pip.sudden {
  background: rgba(255, 0, 0, 0.4);
  color: #ff9999;
  border: 1.5px solid #ff3333;
  animation: pulse-sudden 1.4s infinite alternate;
}
@keyframes pulse-sudden {
  0% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 0, 0, 0.4); }
  100% { transform: scale(1.06); box-shadow: 0 0 24px rgba(255, 0, 0, 0.8); }
}

.known-banner {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 8, 5, 0.85);
  border: 2px solid var(--accent);
  color: #fff;
  padding: 8px 24px;
  border-radius: 30px;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 15;
  box-shadow: 0 0 30px var(--accent-glow);
}
.known-banner.show { opacity: 1; }

/* ---------------- Action Row (Shoot Self vs Opponent) ---------------- */
.action-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 8px 0;
  z-index: 15;
}
.action-btn {
  flex: 1;
  max-width: 280px;
  padding: 16px 20px;
  font-size: 1.05rem;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  border: 2px solid transparent;
}
.action-target-icon { font-size: 1.8rem; }
.action-text { display: flex; flex-direction: column; text-align: left; }
.action-text strong { font-size: 1.05rem; letter-spacing: 0.5px; }
.action-text small { font-size: 0.72rem; opacity: 0.8; font-weight: 700; }

.shoot-self {
  background: linear-gradient(135deg, #0e2a3a, #06131c);
  color: #99e6ff;
  border-color: rgba(56, 182, 255, 0.4);
}
.shoot-self:hover {
  background: linear-gradient(135deg, #153c52, #0a1e2b);
  border-color: #38b6ff;
  box-shadow: 0 10px 30px rgba(56, 182, 255, 0.35);
}

.shoot-dealer {
  background: linear-gradient(135deg, #3a1010, #1c0505);
  color: #ffb3b3;
  border-color: rgba(255, 51, 51, 0.4);
}
.shoot-dealer:hover {
  background: linear-gradient(135deg, #521818, #2b0808);
  border-color: #ff3333;
  box-shadow: 0 10px 30px rgba(255, 51, 51, 0.35);
}

.action-row.disabled {
  pointer-events: none;
  opacity: 0.35;
  filter: grayscale(0.6);
}

.turn-banner {
  text-align: center;
  font-weight: 900;
  letter-spacing: 3px;
  font-size: 1rem;
  color: var(--accent);
  padding: 4px;
  text-shadow: 0 0 16px var(--accent-glow);
}
.log-feed {
  max-height: 86px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
  backdrop-filter: blur(8px);
}
.log-feed div:last-child { color: #fff; font-weight: 700; }

/* ---------------- Overlays & Modals ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 8, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  backdrop-filter: blur(8px);
}
.overlay.show { display: flex; }
.overlay-card {
  background: var(--bg-1);
  border: 1.5px solid var(--line);
  border-radius: 24px;
  padding: 38px 32px;
  text-align: center;
  max-width: 460px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.9);
}
.overlay-card h1 { font-size: 2rem; font-weight: 900; letter-spacing: 2px; }
.overlay-card p { color: var(--text-dim); line-height: 1.6; font-size: 0.95rem; }
.overlay-icon { font-size: 3rem; }
.overlay-card.win { border-color: rgba(44, 240, 125, 0.6); box-shadow: 0 0 50px rgba(44, 240, 125, 0.25); }
.overlay-card.lose { border-color: rgba(255, 51, 51, 0.6); box-shadow: 0 0 50px rgba(255, 51, 51, 0.25); }
.modal-btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; width: 100%; }

/* ---------------- Adrenaline Steal Grid ---------------- */
.adrenaline-item-list {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0;
}
.steal-chip {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.steal-chip:hover {
  transform: scale(1.15);
  box-shadow: 0 0 24px var(--accent-glow);
}

@media (max-width: 640px) {
  .home-title { font-size: 3rem; }
  .action-row { flex-direction: column; align-items: stretch; }
  .action-btn { max-width: 100%; }
  .creator-wrap { flex-direction: column; }
  .creator-panel { width: 100%; max-width: 100%; }
}
