/* ========================================
   🚀 KINGS LANDING POKER - MAIN STYLES
   Base configuration, imports, and design tokens
   ======================================== */

@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700;900&family=Inter:wght@300;400;500;600&display=swap");

@import url("typography.css");
@import url("cards.css");
@import url("forms.css");
@import url("components.css");
@import url("animations.css");

/* ========================================
   🎨 DESIGN TOKENS
   CSS Variables for Branding, Surfaces, Text, and States
   ======================================== */

:root {
  /* Brand */
  --neon-purple: #9d4edd;
  --neon-purple-dark: #7b2cbf;
  --neon-purple-light: #c77dff;
  --neon-pink: #e0aaff;

  --primary: var(--neon-purple);
  --primary-strong: var(--neon-purple-dark);
  --primary-soft: rgba(157, 78, 221, 0.35);

  /* Surfaces */
  --dark-bg: #05040b;
  --dark-surface: #13131a;
  --glass-bg: rgba(19, 19, 26, 0.4);
  --glass-border: rgba(157, 78, 221, 0.3);

  /* Text */
  --text-primary: #ffffff;
  --text-secondary: #b8b8d1;
  --text-muted: #8b89a6;
  --text-soft: #a8a5c7;
  --text-color-light: #f5f3ff;
  /* Used in game-card title/name */

  /* States */
  --success: #10b981;
  --danger: #ef4444;
  --status-closed: #37d28a;
  /* Used for status-pill and profit color */
  --status-loss: #ff6b6b;
  --status-edit: rgba(125, 211, 252, 0.22);
  --status-delete: rgba(248, 113, 113, 0.22);

  /* Shadows */
  --shadow-strong: 0 22px 60px rgba(0, 0, 0, 0.9);

  /* Game Accents (for code/self-name) */
  --accent-player-self: #e093ff;
  --accent-game-meta: #c78dff;
}

/* ========================================
   ⚙️ RESET / BASE STYLES
   Box model, body defaults, and global accessibility
   ======================================== */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

/* Base Body Styles */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--dark-bg);
  background-image: url("../images/bg-space-2.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text-primary);
  position: relative;
  overflow-x: hidden;
}

/* Reduce Motion Accessibility */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus Indicator Accessibility */
*:focus-visible {
  outline: 2px solid var(--neon-purple);
  outline-offset: 3px;
}

/* ========================================
   ✨ BODY OVERLAYS
   Fixed gradient and scanline visual effects
   ======================================== */

/* Gradient overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;

  animation: gradientShift 15s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

/* Scanlines */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      rgba(157, 78, 221, 0.03) 0px,
      transparent 1px,
      transparent 2px,
      rgba(157, 78, 221, 0.03) 3px);
  animation: scanlines 8s linear infinite;
  pointer-events: none;
  z-index: 1;
}

/* ========================================
   📱 APP SHELL & LAYOUT
   Main structure, container, and page-specific tweaks
   ======================================== */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
  /* above overlays */
}

/* Main content block between header/footer */
.container {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 24px clamp(32px, 8vw, 56px) 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* centers splash content */
  align-items: center;
}

@media (max-width: 600px) {
  .container {
    padding: 16px 10px;
    /* smaller outer padding */
  }
}

/* Splash Page (index.html) specific styles */
body.page-index {
  overflow-y: hidden;
  /* remove vertical scroll */
}

body.page-index .container {
  justify-content: flex-end;
  padding-bottom: 148px;
  /* tweak if logo/card heights change */
}

/* Responsive container increase */
@media (min-width: 768px) {
  .container {
    max-width: 600px;
    padding-inline: clamp(40px, 6vw, 64px);
  }
}

/* ========================================
   ⬆️ HEADER
   Global navigation and logo styles
   ======================================== */

.app-header {
  padding-top: 24px;
  padding-bottom: 8px;
  padding-inline: clamp(32px, 7vw, 56px);
  background: transparent;
  z-index: 3;
}

.app-header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-mark img {
  height: 64px;
  width: auto;
  filter: drop-shadow(0 0 18px rgba(157, 78, 221, 0.9));
}

/* Bigger logo on splash */
body.page-index .logo-mark img {
  height: 80px;
}

/* Header nav link */
.nav-link {
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);

  color: var(--neon-purple-light);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-decoration: none;

  transition: background 0.2s, color 0.2s, transform 0.2s;
}

/* Allow .nav-link to be used on <button> elements */
button.nav-link {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.08);
  /* match link */
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--neon-purple);
}

.nav-link:active {
  transform: scale(0.96);
}

.app-header-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ========================================
   HAMBURGER MENU
   ======================================== */

.kl-burger {
  width: 46px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(157, 78, 221, 0.35);
  background: rgba(20, 10, 40, 0.35);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 1px rgba(157, 78, 221, 0.12),
    0 10px 26px rgba(0, 0, 0, 0.45);
}

.kl-burger:hover {
  border-color: rgba(157, 78, 221, 0.55);
  box-shadow: 0 0 0 1px rgba(157, 78, 221, 0.18),
    0 14px 34px rgba(0, 0, 0, 0.55);
}

.kl-burger-lines {
  width: 20px;
  height: 14px;
  position: relative;
  display: block;
}

.kl-burger-lines span {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 999px;
  background: rgba(205, 160, 255, 0.95);
  box-shadow: 0 0 14px rgba(157, 78, 221, 0.55);
  transition: transform 220ms ease, top 220ms ease, opacity 220ms ease,
    width 220ms ease;
}

.kl-burger-lines span:nth-child(1) {
  top: 0;
}

.kl-burger-lines span:nth-child(2) {
  top: 6px;
  width: 70%;
}

.kl-burger-lines span:nth-child(3) {
  top: 12px;
}

body.kl-menu-open .kl-burger-lines span:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}

body.kl-menu-open .kl-burger-lines span:nth-child(2) {
  opacity: 0;
  width: 100%;
}

body.kl-menu-open .kl-burger-lines span:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

/* Overlay container */
.kl-menu {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

body.kl-menu-open .kl-menu {
  opacity: 1;
  pointer-events: auto;
}

.kl-menu-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(8, 4, 16, 0.72);
  backdrop-filter: blur(8px);
}

/* Panel */
.kl-menu-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  width: min(420px, calc(100vw - 28px));
  border-radius: 22px;
  padding: 18px 18px 14px;
  background: rgba(18, 8, 34, 0.78);
  border: 1px solid rgba(157, 78, 221, 0.4);
  box-shadow: 0 0 0 1px rgba(157, 78, 221, 0.12),
    0 28px 80px rgba(0, 0, 0, 0.62);
  transform: translateY(-10px) scale(0.98);
  opacity: 0;
  overflow: hidden;
}

body.kl-menu-open .kl-menu-panel {
  animation: kl-menu-pop 220ms ease-out forwards;
}

/* Top row */
.kl-menu-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
}

.kl-menu-title {
  font-family: "Orbitron", system-ui, sans-serif;
  letter-spacing: 0.12em;
  color: rgba(205, 160, 255, 0.92);
  font-weight: 800;
  text-transform: uppercase;
}

.kl-menu-close {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 84, 130, 0.35);
  background: rgba(255, 84, 130, 0.1);
  color: rgba(255, 200, 220, 0.95);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.kl-menu-close span {
  transform: translateY(-1px);
}

.kl-menu-links {
  display: grid;
  gap: 10px;
  padding: 8px 2px 10px;
}

.kl-menu-link {
  font-family: "Inter", Arial, sans-serif;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 16px;
  padding: 14px 14px;
  text-decoration: none;
  color: rgba(240, 230, 255, 0.92);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(157, 78, 221, 0.22);
  box-shadow: 0 0 0 1px rgba(157, 78, 221, 0.08);
  position: relative;
  overflow: hidden;
  transform: translateY(6px);
  opacity: 0;
}

body.kl-menu-open .kl-menu-link {
  animation: kl-menu-item-in 240ms ease-out forwards;
}

body.kl-menu-open .kl-menu-link:nth-child(1) {
  animation-delay: 40ms;
}

body.kl-menu-open .kl-menu-link:nth-child(2) {
  animation-delay: 70ms;
}

body.kl-menu-open .kl-menu-link:nth-child(3) {
  animation-delay: 100ms;
}

body.kl-menu-open .kl-menu-link:nth-child(4) {
  animation-delay: 130ms;
}

body.kl-menu-open .kl-menu-link:nth-child(5) {
  animation-delay: 160ms;
}

.kl-menu-link:hover {
  border-color: rgba(157, 78, 221, 0.45);
  background: rgba(157, 78, 221, 0.1);
}

.kl-menu-link.is-button {
  text-align: left;
  cursor: pointer;
}

/* Neon scan line effect on links */
.kl-menu-link::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
      transparent,
      rgba(157, 78, 221, 0.14),
      transparent);
  transform: translateX(-120%);
  animation: kl-scan 2.8s linear infinite;
  pointer-events: none;
}

.kl-menu-divider {
  height: 1px;
  background: rgba(157, 78, 221, 0.2);
  margin: 6px 4px;
  border-radius: 999px;
}

.kl-menu-audio {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(157, 78, 221, 0.22);
  background: rgba(255, 255, 255, 0.05);
}

.kl-menu-audio-label {
  font-family: "Inter", Arial, sans-serif;
  color: rgba(240, 230, 255, 0.82);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
}

/* Footer */
.kl-menu-foot {
  position: relative;
  margin-top: 8px;
  padding-top: 10px;
}

.kl-menu-foot-text {
  text-align: center;
  font-size: 12px;
  color: rgba(220, 210, 245, 0.55);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.kl-menu-foot-glow {
  position: absolute;
  left: 50%;
  top: 0;
  width: 260px;
  height: 120px;
  transform: translateX(-50%);
  background: radial-gradient(circle,
      rgba(157, 78, 221, 0.22),
      transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}

/* Prevent background scroll */
body.kl-menu-open {
  overflow: hidden;
}

/* iOS tap reliability fixes */
.kl-burger,
.kl-menu-backdrop,
.kl-menu-close,
.kl-menu-link,
.kl-menu-audio {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Make sure burger is actually tappable above everything */
.app-header {
  position: relative;
  z-index: 10000;
}

.kl-burger {
  position: relative;
  z-index: 10001;
}

/* Ensure menu overlay sits above all content */
.kl-menu {
  z-index: 20000;
  display: block;
}

/* Hard-disable overlay when hidden (prevents iOS tap blocking) */
.kl-menu[hidden] {
  display: none !important;
}

/* iOS: backdrop-filter can cause click issues, keep it but ensure it's not blocking */
.kl-menu-backdrop {
  /* CHANGE THIS from auto to none */
  pointer-events: none;
}

body.kl-menu-open .kl-menu-backdrop {
  pointer-events: auto;
}

/* iOS: sometimes panel intercepts taps oddly if transform is present */
body.kl-menu-open .kl-menu-panel {
  will-change: transform, opacity;
}

/* Re-usable pill button for icons */
.icon-pill {
  min-width: 44px;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 15, 28, 0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: #f5f3ff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.icon-pill:hover {
  background: rgba(40, 22, 80, 0.95);
  transform: translateY(-1px);
}

.icon-pill:active {
  transform: translateY(0);
  opacity: 0.85;
}

/* Audio toggle button */
.audio-toggle {
  padding-inline: 10px;
}

/* Icon image */
.audio-toggle-icon {
  display: block;
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* Muted state tint */
.audio-toggle.is-muted {
  background: rgba(64, 0, 32, 0.9);
  border-color: rgba(255, 80, 80, 0.7);
}

/* ========================================
   ⬇️ FOOTER
   Global footer and copyright/text styles
   ======================================== */

.app-footer {
  padding-top: 8px;
  padding-inline: clamp(32px, 7vw, 56px);
  padding-bottom: 16px;
  background: transparent;
  z-index: 3;
}

.app-footer-inner {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.footer-text {
  font-size: 0.5rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  opacity: 0.9;
}

.spectate-link-wrap {
  margin-top: 25px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
}

.spectate-link-wrap a {
  color: var(--neon-purple-light, #9f7aff);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.spectate-link-wrap a:hover {
  color: #c9a6ff;
  /* lighter neon hover */
  opacity: 1;
}

.spectate-link-wrap a:active {
  color: #e3c7ff;
}

/* ========================================
   🃏 GAME & PLAYER UI COMPONENTS
   Shared styles for players, status, and actions
   ======================================== */

/* General button styles for Hero section */
.btn-hero {
  width: 90%;
  max-width: 90%;
  margin-inline: auto;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
}

/* Full-width button inside cards (e.g., game footer) */
.btn-full {
  width: 100%;
}

/* Player Name Styles (used in host and game views) */
.player-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-color-muted);
  opacity: 0.7;
}

.player-name.you {
  color: var(--accent-player-self);
}

.player-edit-wrap {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

/* Shared CLOSED pill (host + game) */
.status-pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(55, 210, 138, 0.18);
  color: var(--status-closed);
  border: 1px solid rgba(55, 210, 138, 0.4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Shared Net Profit/Loss Styles (used in host and game views) */
.net-profit {
  font-size: 14px;
  /* Default for host view */
  font-weight: 600;
}

.page-game .net-profit {
  font-size: 13px;
  /* Smaller for game view */
  margin-left: 6px;
}

.net-profit.profit {
  color: var(--status-closed);
}

.net-profit.loss {
  color: var(--status-loss);
}

.net-profit.neutral {
  color: var(--text-muted);
}

/* Player Avatar */
.player-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(5, 4, 11, 0.9);
}

/* Player row left block (name + avatar) */
.player-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Closed player styling (host + game) */
.player-row.closed,
.player-card.closed {
  opacity: 0.7;
  background: rgba(0, 0, 0, 0.45);
}

.player-card-status-row {
  position: absolute;
  top: 10px;
  right: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 2;
}

.player-card-status-right {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* Base pill style */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 12, 26, 0.9);
  color: rgba(255, 255, 255, 0.7);
}

/* Closed pill */
.closed-pill {
  font-weight: 600;
}

/* Paid pill – base (off) */
.paid-status-pill {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
}

/* Paid pill – ON state (glow purple) */
.paid-status-pill.paid-status-pill--active {
  background: radial-gradient(circle at 0 0,
      #9f7bff 0,
      #6b4eff 40%,
      #2d1f63 100%);
  box-shadow: 0 0 12px rgba(155, 106, 255, 0.75);
  color: #ffffff;
  border-color: rgba(194, 156, 255, 0.9);
}

.status-icon {
  width: 9px;
  height: 9px;
  margin-right: 6px;
  display: inline-block;
  filter: brightness(0) invert(1);
  /* makes the svg appear white */
}

/* ========================================
   🕹️ HOST VIEW STYLES (Player Card & Summary)
   Specific layouts for the host/game management interface
   ======================================== */

/* Host Summary Bar */
.host-summary {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.host-summary-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.host-summary-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.host-summary-value {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}

.host-summary-sub {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Player Card (Host View) */
.player-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-info-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-info-bottom {
  display: flex;
  flex-direction: column;
  /* stack rows */
  align-items: flex-start;
  /* left align everything */
  gap: 4px;
  /* breathing room between summary and pills */
}

.player-cashout {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.player-cashout .cashout-amount {
  font-size: 14px;
  font-weight: 600;
}

.player-cashout .net-profit {
  font-size: 13px;
}

.cash-out-player-name {
  margin-bottom: 15px;
}

.host-label {
  font-size: 11px;
  margin-left: 4px;
  opacity: 0.8;
}

/* Cash-out Summary on closed players (Host View) */
.player-cashout {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cashout-amount {
  font-size: 14px;
  color: #fff;
}

/* pill-style buy-ins */

.buyins-pill-row,
.player-buyins-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.buyin-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #7cf5b2;
  white-space: nowrap;
}

.buyin-pill.total {
  background: rgba(157, 78, 221, 0.15);
  border-color: rgba(157, 78, 221, 0.55);
  color: var(--neon-purple-light);
}

.connection-banner {
  width: 100%;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 999px;

  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;

  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.55);

  display: flex;
  align-items: center;
  justify-content: center;

  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.connection-banner.connected {
  background: rgba(16, 185, 129, 0.18);
  color: #bbf7d0;
  border-color: rgba(16, 185, 129, 0.55);
}

.connection-banner.connection-banner--hidden {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

/* Player Action Buttons (Host View) */
.player-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.action-btn {
  height: 48px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: var(--card-bg-dark);
  /* defined in cards.css */
  box-shadow: var(--btn-shadow, inset 0 0 0 1px rgba(255, 255, 255, 0.06));
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
  flex-direction: column;
}

.action-btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.btn-help-text {
  color: var(--text-color-light);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 400;
}

.action-icon {
  width: 22px;
  height: 22px;
  pointer-events: none;
  filter: brightness(0) invert(1);
}

/* Theme colors for action buttons */
/* BUY-IN (purple) */
/* Buy-in (green) */
/* ---------- BUY-IN (Purple) ---------- */
.action-buyin {
  background: #7c4dff;
  transition: background 0.15s ease, transform 0.1s ease;
}

.action-buyin:hover {
  background: #8c5dff;
}

.action-buyin:active {
  background: #6d3eef;
  transform: scale(0.97);
}

/* ---------- CASH OUT (Aqua) ---------- */
.action-cashout {
  background: #009ca6;
  transition: background 0.15s ease, transform 0.1s ease;
}

.action-cashout:hover {
  background: #00b8c4;
}

.action-cashout:active {
  background: #00838c;
  transform: scale(0.97);
}

/* ---------- REMOVE (Red) ---------- */
.action-remove {
  background: #e84c47;
  transition: background 0.15s ease, transform 0.1s ease;
}

.action-remove:hover {
  background: #f25650;
}

.action-remove:active {
  background: #c93d39;
  transform: scale(0.97);
}

/* ========================================
   HOST: JOIN QR BLOCK
   ======================================== */

.join-qr-block {
  margin-top: 12px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}

/* Toggle header */

.join-qr-toggle {
  width: 100%;
  padding: 8px 14px 6px;
  border: none;
  background: transparent;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.join-qr-toggle-label {
  opacity: 0.9;
}

.join-qr-toggle-chevron {
  font-size: 14px;
  transition: transform 0.15s ease;
  opacity: 0.8;
}

/* Content area */

.join-qr-content {
  padding: 6px 14px 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.join-qr-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.join-qr-subtitle {
  font-size: 12px;
  color: var(--text-muted, #9ca3af);
}

.join-qr-link {
  font-size: 12px;
  color: #e5e7eb;
  word-break: break-all;
  opacity: 0.9;
  margin-bottom: 5px;
}

.join-qr-right {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.join-qr-right img {
  width: 100%;
  height: auto;
}

.join-qr {
  width: 80px;
  height: 80px;
}

/* Collapsed state */

.join-qr-block.collapsed .join-qr-content {
  display: none;
}

.join-qr-block.collapsed .join-qr-toggle-chevron {
  transform: rotate(-90deg);
}

/* Narrow screens */

@media (max-width: 420px) {
  .join-qr-content {
    flex-direction: row;
    align-items: flex-start;
  }
}

/* ========================================
   🖥️ GAME VIEW STYLES (game.html)
   Layout and display for the game-in-progress screen
   ======================================== */

.page-game .game-card {
  padding: 24px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.game-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.game-card-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.game-card-title {
  font-size: 24px;
  line-height: 1;
  margin-bottom: 20px;
  color: var(--text-color-light);
}

.game-card-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.game-card-meta {
  text-align: right;
}

.game-meta-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.game-meta-value {
  display: block;
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-game-meta);
}

/* Game ID + Timer inline row */
.game-code-block {
  text-align: left;
  padding: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.game-code-inline,
.game-timer-inline {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.game-timer-value {
  display: inline;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.9);
}

.game-code-label {
  display: inline;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.game-code-value {
  display: inline;
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--accent-player-self);
}

/* Players section */
.players-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.players-header-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* List of players in game view */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-row {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* History rows only: restore spacing when expanded */
.page-history .history-game-card {
  gap: 0;
  transition: gap 0.25s ease;
}

.page-history .history-game-card.expanded {
  gap: 6px;
}

.player-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.player-row-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.you-label {
  font-size: 12px;
  color: var(--text-muted);
}

.player-buyins-count {
  font-size: 12px;
  color: var(--text-muted);
}

.player-total {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
}

/* Buy-in history inside each player row */
.player-buyins-list {
  display: flex;
  flex-direction: column;
  gap: 2px;

  /* Collapsed state spacing (no snap) */
  max-height: 0;
  overflow: hidden;

  padding-top: 0;
  margin-top: 0;

  border-top: 1px solid transparent;

  /* Smooth transition for height AND spacing */
  transition: max-height 0.3s ease, padding-top 0.3s ease, margin-top 0.3s ease,
    border-top-color 0.3s ease;
}

.buyins-empty {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

.buyin-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}

.buyin-amount {
  font-weight: 500;
}

.buyin-time {
  opacity: 1;
}

/* Game View Cashout Details for closed players */
.page-game .cashout-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.page-game .cashout-amount {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}

.game-footer {
  margin-top: 8px;
}

/* ========================================
   📋 MODAL STYLES
   Generic modal and Edit Buy-in Specific Styles
   ======================================== */
.player-edit-link {
  margin-top: 2px;
  padding: 0;
  border: none;
  background: none;
  font-size: 11px;
  color: var(--text-muted, #9ca3af);
  text-decoration: underline;
  cursor: pointer;
  align-self: flex-start;
}

.player-edit-link:hover {
  color: var(--neon-purple-light, #c77dff);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top,
      rgba(0, 0, 0, 0.8),
      rgba(0, 0, 0, 0.95));
  backdrop-filter: blur(6px);
  z-index: 50;
}

.modal-content {
  width: 100%;
  max-width: 360px;
  padding: 18px 20px;
  border-radius: 20px;
  box-shadow: var(--shadow-strong);
}

.modal-title {
  font-size: 18px;
  margin-bottom: 8px;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-subtitle {
  margin-bottom: 6px;
}

.history-editable {
  cursor: pointer;
}

.history-editable:hover {
  text-decoration: underline;
}

/* ================================
   TOAST NOTIFICATIONS
   ================================ */

.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;

  display: flex;
  flex-direction: column;
  gap: 8px;

  pointer-events: none;
  /* clicks pass through except on toast itself */
}

.toast-container {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(9, 9, 20, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: #e5e7eb;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(15, 23, 42, 0.8);
  opacity: 0;
  transform: translateY(10px);
  animation: toast-in 0.18s ease-out forwards;
  pointer-events: auto;
}

.toast.toast--success {
  border-color: rgba(45, 212, 191, 0.7);
  background: radial-gradient(circle at top,
      rgba(45, 212, 191, 0.18),
      rgba(9, 9, 20, 0.98));
  color: #bbf7d0;
}

.toast.toast--error {
  border-color: rgba(248, 113, 113, 0.8);
  background: radial-gradient(circle at top,
      rgba(248, 113, 113, 0.18),
      rgba(9, 9, 20, 0.98));
  color: #fecaca;
}

.toast.toast--hide {
  animation: toast-out 0.18s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

/* Edit buy-ins modal list */
.edit-buyins-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.edit-buyin-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  column-gap: 10px;
  align-items: center;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.edit-buyin-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.edit-buyin-actions {
  display: flex;
  gap: 6px;
}

.edit-buyin-btn {
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.edit-buyin-btn.edit {
  background: var(--status-edit);
}

.edit-buyin-btn.delete {
  background: var(--status-delete);
}

.edit-buyin-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.edit-buyin-btn:active {
  transform: scale(0.95);
  opacity: 0.85;
}

.edit-summary-row {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

/* ========================================
   📜 HISTORY PAGE STYLES
   Specific layouts for history/archived games
   ======================================== */

/* History page header centering */
.page-history .game-card-header {
  justify-content: center;
  text-align: center;
}

.page-history .game-card-title-wrap {
  align-items: center;
}

.page-history .container {
  justify-content: flex-start;
  padding-top: 60px;
}

/* History layout: per-game player rows */
.history-date-row {
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
  font-weight: 700;
}

.history-header-row {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.history-header-name {
  font-weight: 500;
}

.history-player-row {
  display: flex;
  align-items: center;
  padding: 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Name takes remaining space */
.history-player-row .buyin-amount {
  flex: 1 1 auto;
  min-width: 0;
}

/* Grid so In / Out / Net line up perfectly */
.history-player-numbers {
  display: grid;
  grid-template-columns: 40px 40px 60px;
  /* tweak these values */
  /* 3 equal columns */
  column-gap: 18px;
  width: auto;
  /* tweak this to what looks right */
  flex-shrink: 0;
  /* do not shrink on long names */
  justify-items: end;
  text-align: right;
}

.history-col {
  font-size: 12px;
}

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0;
}

/* History dealer summary */

.history-summary {
  margin-top: 10px;
  margin-bottom: 0;
  /* was 15px, causes clipped bottom */
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
  font-size: 11px;
}

.history-summary-item-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
  margin-bottom: 2px;
}

.history-summary-item-value {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #ffffff);
}

.history-summary-item-value.profit {
  color: #37d28a;
}

.history-summary-item-value.loss {
  color: #ff6b6b;
}

/* ===== History Dealer Summary ===== */

.history-game-card {
  background: rgba(8, 6, 26, 0.9);
  cursor: pointer;
}

/* keep the editor cells clearly interactive */
.history-game-card .history-editable {
  cursor: pointer;
}

.history-game-card.expanded {
  max-height: 1000px;
}

.history-game-card.expanded .player-buyins-list {
  padding-top: 6px;
  padding-bottom: 14px;
  /* add this */
  margin-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.history-game-card .player-name {
  color: var(--neon-purple-light);
  font-weight: 700;
  opacity: 1;
}

/* three compact stat blocks in a row */
.history-summary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.history-summary-stat {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-summary-label {
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 400px;
}

.history-summary-value {
  font-weight: 600;
  font-size: 14px;
  color: #ffffff;
}

/* winner / loser line under the stats */

.history-summary-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.history-meta-item {
  opacity: 0.95;
  flex: 1;
}

.history-summary-positive,
.history-meta-item.history-summary-positive {
  color: #37d28a;
}

.history-summary-negative,
.history-meta-item.history-summary-negative {
  color: #ff6b6b;
}

/* highlight rows in the player table (unchanged) */

.history-player-row.top-winner {
  background: linear-gradient(90deg,
      rgba(55, 210, 138, 0.14),
      rgba(55, 210, 138, 0.02));
}

.history-player-row.top-loser {
  background: linear-gradient(90deg,
      rgba(255, 107, 107, 0.14),
      rgba(255, 107, 107, 0.02));
}

/* Keep invisible reCAPTCHA badge out of the UI */
.grecaptcha-badge {
  position: fixed !important;
  right: 12px !important;
  bottom: 12px !important;
  z-index: 9999 !important;
  transform: scale(0.95);
  transform-origin: bottom right;
}

/* On very small screens, shrink it a bit more */
@media (max-width: 480px) {
  .grecaptcha-badge {
    transform: scale(0.85);
  }
}

/* If reCAPTCHA ever renders a visible widget, keep it pinned and out of the card */
#recaptcha-container {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 9999;
}

/* Profile stats under Save button */
.profile-stats {
  margin-top: 14px;
  text-align: left;
}

#dashSave {
  margin-bottom: 10px;
}

.profile-net {
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.profile-net.profit {
  color: var(--status-closed);
}

.profile-net.loss {
  color: var(--status-loss);
}

.profile-net.neutral {
  color: var(--text-muted);
}

.profile-since {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* --- Profile: net + privacy toggle row --- */
.profile-net-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

.profile-hide-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(157, 78, 221, 0.22);
  box-shadow: 0 0 0 1px rgba(157, 78, 221, 0.08);
}

.profile-hide-toggle-text {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(240, 230, 255, 0.82);
  font-weight: 700;
  white-space: nowrap;
}

.profile-net-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-net-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: left;
}

.profile-hide-toggle {
  align-self: flex-start;
  /* aligns with Net, not Since */
}

/* Neon switch */
.kl-switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
}

.kl-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.kl-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(157, 78, 221, 0.35);
  box-shadow: 0 0 0 1px rgba(157, 78, 221, 0.10),
    0 10px 24px rgba(0, 0, 0, 0.45);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.kl-switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(240, 230, 255, 0.92);
  box-shadow: 0 0 16px rgba(157, 78, 221, 0.55);
  transition: transform 160ms ease, background 160ms ease;
}

.kl-switch input:checked+.kl-switch-slider {
  background: radial-gradient(circle at 0 0, rgba(157, 78, 221, 0.55), rgba(40, 22, 80, 0.75));
  border-color: rgba(199, 125, 255, 0.75);
  box-shadow: 0 0 18px rgba(157, 78, 221, 0.35),
    0 10px 26px rgba(0, 0, 0, 0.55);
}

.kl-switch input:checked+.kl-switch-slider::before {
  transform: translate(18px, -50%);
  background: rgba(255, 255, 255, 0.95);
}

/* --- History: hidden numbers styling --- */
.kl-num-hidden {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(157, 78, 221, 0.18);
  color: rgba(240, 230, 255, 0.75);
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
  /* prevents click-to-edit */
}


/* iOS: kill the fancy stuff that can make fixed overlays fail to render */
@supports (-webkit-touch-callout: none) {
  .kl-menu-backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* If we disable animations on iOS, we MUST force visible states */
  body.kl-menu-open .kl-menu-panel {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  body.kl-menu-open .kl-menu-link {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

body.kl-menu-open .kl-menu-panel {
  opacity: 1;
}

/* --- iOS & TOUCH FIXES --- */

/* 1. Ensure Burger is ALWAYS on top of the invisible menu layer */
/* The menu is 20000, so we set the burger higher */
.kl-burger {
  z-index: 20005 !important;
  /* Disable the "Select All" / Copy text popup on the button */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  /* Remove the purple focus box if it's annoying */
  outline: none !important;
}

/* 2. Fix the "Invisible Shield" issue completely */
/* When menu is closed (no .kl-menu-open class), the backdrop allows clicks through */
body:not(.kl-menu-open) .kl-menu,
body:not(.kl-menu-open) .kl-menu-backdrop {
  pointer-events: none !important;
}

/* 3. Disable text selection on the backdrop too */
.kl-menu-backdrop {
  -webkit-user-select: none;
  user-select: none;
}

/* --- CRITICAL IOS FIXES --- */

/* 1. Force Burger on top of everything (z-index 20005 beats the menu's 20000) */
#klBurger,
.kl-burger {
  position: relative;
  z-index: 20005 !important;
  cursor: pointer;
  /* Disable text selection/highlighting on the button */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 2. Kill the "Invisible Shield" */
/* By default, the menu container allows clicks to pass through */
.kl-menu,
.kl-menu-backdrop {
  pointer-events: none !important;
}

/* 3. Re-enable clicks ONLY when open */
body.kl-menu-open .kl-menu,
body.kl-menu-open .kl-menu-backdrop {
  pointer-events: auto !important;
}

/* ========================================
   🚨 EMERGENCY MENU FIX
   Forces the panel to be visible when open
   ======================================== */

body.kl-menu-open .kl-menu-panel {
  opacity: 1 !important;
  transform: none !important;
  /* Resets any scale/move transforms */
  visibility: visible !important;
  display: block !important;
}

/* Ensure the links inside appear too */
body.kl-menu-open .kl-menu-link {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
  /* Disables the staggered load if it's causing issues */
}