/* styles.css — Predichess Web Stylesheet
   Stylised after eboshii.dev (Dark Retro Cosmic Theme)
   Typography: Space Grotesk, Inter, EB Garamond, JetBrains Mono
   Design Tokens: Warm ivory & gold accents on deep cosmic violet / obsidian glass */

/* -----------------------------------------------
   Design Tokens (eboshii.dev palette)
----------------------------------------------- */
:root {
  --bg:              #05030a;
  --bg-card:         rgba(14, 10, 24, 0.78);
  --bg-card-hover:   rgba(22, 16, 38, 0.9);
  --bg-raised:       rgba(28, 18, 48, 0.85);
  --text:            #F5F0E8;
  --muted:           #B3A898;
  --accent:          #F0B365;
  --accent-dim:      #A6753B;
  --accent-glow:     rgba(240, 179, 101, 0.25);
  --border:          rgba(235, 225, 210, 0.18);
  --border-strong:   rgba(235, 225, 210, 0.32);
  --code-bg:         rgba(20, 14, 34, 0.88);
  --max-w:           700px;
  --max-w-wide:      1040px;
  --danger:          #E06C75;
  --success:         #98C379;

  /* Chess Board Tokens (Starlight Lunar Ivory & Deep Celestial Indigo Slate) */
  --board-light:       #E2DCCB;
  --board-dark:        #242D40;
  --coord-light:       #4E4334;
  --coord-dark:        #F5C278;
  --highlight-select:  rgba(240, 179, 101, 0.42);
  --highlight-last:    rgba(240, 179, 101, 0.24);
  --highlight-check:   rgba(224, 108, 117, 0.5);
  --highlight-trap:    rgba(255, 122, 0, 0.7);
  --aura-color:        rgba(230, 224, 214, 0.5);

  /* Fonts matching eboshii.dev */
  --font-serif:   'EB Garamond', Georgia, serif;
  --font-sans:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Mono', monospace;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;

  /* Type Scale */
  --fs-3xs:       0.625rem;
  --fs-2xs:       0.72rem;
  --fs-xs:        0.8rem;
  --fs-sm:        0.875rem;
  --fs-base:      1rem;
  --fs-md:        1.125rem;
  --fs-lg:        1.25rem;
  --fs-xl:        1.5rem;
  --fs-2xl:       2rem;

  /* Bayer Dither Masks matching eboshii.dev */
  --bayer-dither-high: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Crect width='12' height='12' fill='%23000'/%3E%3Crect x='0' y='0' width='3' height='3' fill='none'/%3E%3Crect x='6' y='6' width='3' height='3' fill='none'/%3E%3C/svg%3E");
  --bayer-dither-med:  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Crect x='0' y='0' width='3' height='3' fill='%23000'/%3E%3Crect x='6' y='0' width='3' height='3' fill='%23000'/%3E%3Crect x='3' y='3' width='3' height='3' fill='%23000'/%3E%3Crect x='9' y='3' width='3' height='3' fill='%23000'/%3E%3Crect x='0' y='6' width='3' height='3' fill='%23000'/%3E%3Crect x='6' y='6' width='3' height='3' fill='%23000'/%3E%3Crect x='3' y='9' width='3' height='3' fill='%23000'/%3E%3Crect x='9' y='9' width='3' height='3' fill='%23000'/%3E%3C/svg%3E");
  --bayer-dither-low:  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Crect x='3' y='0' width='3' height='3' fill='%23000'/%3E%3Crect x='0' y='3' width='3' height='3' fill='%23000'/%3E%3Crect x='6' y='6' width='3' height='3' fill='%23000'/%3E%3Crect x='9' y='9' width='3' height='3' fill='%23000'/%3E%3C/svg%3E");
}

/* -----------------------------------------------
   Reset & Base
----------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  background: var(--bg) url('/assets/images/nebula-poster.webp') center / cover no-repeat fixed;
  color: var(--text);
  font-family: var(--font-sans);
  height: 100%;
  overflow-x: hidden;
}

body {
  background: transparent;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.6;
  opacity: 1;
  visibility: visible;
}

/* -----------------------------------------------
   WebGL Nebula Background
----------------------------------------------- */
#nebula-bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  pointer-events: none;
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease-out;
}

#nebula-bg.loaded {
  opacity: 1;
}

/* -----------------------------------------------
   Header / Nav (matching eboshii.dev)
----------------------------------------------- */
header {
  background: rgba(5, 3, 10, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

nav {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1;
}

.site-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.045em;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
}

.logo-name {
  color: var(--text);
  transition: color 0.15s;
}

.logo-tld {
  color: var(--accent);
  transition: color 0.15s;
}

.site-title:hover .logo-name { color: var(--accent); }

.nav-slash {
  color: var(--muted);
  font-weight: 300;
  opacity: 0.5;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1;
  user-select: none;
  display: inline-flex;
  align-items: center;
}

.nav-app-name {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.nav-links {
  display: flex;
  gap: 1.75rem;
  align-items: center;
}

.nav-links a {
  font-size: var(--fs-sm);
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.15s;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  border-bottom-color: var(--accent-dim);
}

/* Nav Dropdown */
.nav-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-dropdown-trigger {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 0;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}

.nav-dropdown:hover .nav-dropdown-trigger,
.nav-dropdown-trigger:hover,
.nav-dropdown-trigger.active {
  color: var(--accent);
  border-bottom-color: var(--accent-dim);
}

.dropdown-chevron {
  transition: transform 0.15s ease;
  opacity: 0.7;
}

.nav-dropdown:hover .dropdown-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  white-space: nowrap;
  background: rgba(14, 10, 24, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  padding: 0.35rem 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
}

.nav-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 12px;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.45rem 1rem;
  font-size: var(--fs-xs);
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
  border: none;
  transition: background 0.12s, color 0.12s;
}

.nav-dropdown-menu a:hover,
.nav-links .nav-dropdown-menu a.active {
  background: rgba(240, 179, 101, 0.12);
  color: var(--accent);
  border: none;
}

/* -----------------------------------------------
   App Root & Screen Transitions (Cosmic 3px Bayer Dither)
----------------------------------------------- */
@keyframes ditherExit {
  0% {
    opacity: 1;
    transform: scale(1);
    -webkit-mask-image: none;
    mask-image: none;
  }
  33% {
    opacity: 0.75;
    transform: scale(0.998);
    -webkit-mask-image: var(--bayer-dither-high);
    mask-image: var(--bayer-dither-high);
    -webkit-mask-size: 12px 12px;
    mask-size: 12px 12px;
  }
  66% {
    opacity: 0.45;
    transform: scale(0.994);
    -webkit-mask-image: var(--bayer-dither-med);
    mask-image: var(--bayer-dither-med);
    -webkit-mask-size: 12px 12px;
    mask-size: 12px 12px;
  }
  90% {
    opacity: 0.15;
    transform: scale(0.990);
    -webkit-mask-image: var(--bayer-dither-low);
    mask-image: var(--bayer-dither-low);
    -webkit-mask-size: 12px 12px;
    mask-size: 12px 12px;
  }
  100% {
    opacity: 0;
    transform: scale(0.988);
    -webkit-mask-image: none;
    mask-image: none;
  }
}

@keyframes ditherEnter {
  0% {
    opacity: 0;
    transform: translateY(3px) scale(0.990);
    -webkit-mask-image: var(--bayer-dither-low);
    mask-image: var(--bayer-dither-low);
    -webkit-mask-size: 12px 12px;
    mask-size: 12px 12px;
  }
  33% {
    opacity: 0.45;
    transform: translateY(2px) scale(0.994);
    -webkit-mask-image: var(--bayer-dither-med);
    mask-image: var(--bayer-dither-med);
    -webkit-mask-size: 12px 12px;
    mask-size: 12px 12px;
  }
  66% {
    opacity: 0.80;
    transform: translateY(1px) scale(0.998);
    -webkit-mask-image: var(--bayer-dither-high);
    mask-image: var(--bayer-dither-high);
    -webkit-mask-size: 12px 12px;
    mask-size: 12px 12px;
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    -webkit-mask-image: none;
    mask-image: none;
  }
}

.dither-exit {
  animation: ditherExit 85ms steps(4) forwards !important;
  pointer-events: none !important;
}

.dither-enter {
  animation: ditherEnter 130ms steps(4) forwards !important;
}

main#app-root,
#app-root {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0;
}

.screen {
  display: none;
  opacity: 0;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

#screen-lobby.screen.active {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding-top: clamp(2.5rem, 9vh, 6rem);
  padding-bottom: 2.5rem;
  overflow-y: auto;
}

/* -----------------------------------------------
   Buttons
----------------------------------------------- */
.btn-primary {
  background: rgba(240, 179, 101, 0.15);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:hover {
  background: var(--accent);
  color: #05030a;
  box-shadow: 0 0 16px rgba(240, 179, 101, 0.4);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(20, 14, 34, 0.7);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(240, 179, 101, 0.1);
}

.btn-outline-gold {
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--accent);
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline-gold:hover {
  background: rgba(240, 179, 101, 0.12);
}

.btn-large {
  width: 100%;
  padding: 14px 24px;
  font-size: 0.95rem;
}

/* -----------------------------------------------
   Lobby Screen (Vertical Menu)
----------------------------------------------- */
.lobby-container {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
}

.lobby-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.8);
}

.vertical-menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.menu-section {
  position: relative;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  isolation: isolate;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.menu-section:hover {
  border-color: var(--border-strong);
}

/* Inner dither veil - identical to crypto-panel & tip jar on eboshii.dev */
.menu-section::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(150deg,
      rgba(81, 22, 59, 0.45) 0%,
      rgba(32, 16, 56, 0.35) 45%,
      rgba(14, 63, 82, 0.15) 100%);
  -webkit-mask-image: var(--bayer-dither-med);
  mask-image: var(--bayer-dither-med);
  -webkit-mask-size: 12px 12px;
  mask-size: 12px 12px;
  pointer-events: none;
  opacity: 0.9;
  transition: background 0.25s ease, opacity 0.25s ease;
}

.menu-section:hover::before {
  -webkit-mask-image: var(--bayer-dither-high);
  mask-image: var(--bayer-dither-high);
  opacity: 1;
}

/* Selected state: border turns orange/gold and glows */
.menu-section.open {
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(240, 179, 101, 0.25);
}

.menu-section.open::before {
  background:
    linear-gradient(150deg,
      rgba(174, 93, 29, 0.55) 0%,
      rgba(81, 22, 59, 0.40) 45%,
      rgba(240, 179, 101, 0.22) 100%);
  -webkit-mask-image: var(--bayer-dither-high);
  mask-image: var(--bayer-dither-high);
  opacity: 1;
}

.menu-btn {
  width: 100%;
  background: transparent;
  border: none;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  cursor: pointer;
  outline: none;
  transition: color 0.18s ease;
}

.menu-btn-text {
  width: 100%;
  text-align: center;
}

.menu-btn:hover {
  color: var(--accent);
}

.menu-section.open .menu-btn {
  color: var(--accent);
  background: rgba(240, 179, 101, 0.05);
}

.menu-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.menu-section.open .menu-content {
  grid-template-rows: 1fr;
}

.menu-inner {
  min-height: 0;
  overflow: hidden;
  padding: 0 22px;
  border-top: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: padding 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

.menu-section.open .menu-inner {
  padding: 16px 22px 22px;
  border-top-color: rgba(235, 225, 210, 0.12);
}

.menu-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 4px 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
}

.menu-divider::before,
.menu-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.menu-divider span {
  padding: 0 10px;
}

.join-code-form {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.code-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.code-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0 12px;
  outline: none;
  box-sizing: border-box;
  transition: all 0.15s;
}

.code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.code-input-wrapper .btn-secondary {
  height: 42px;
  padding: 0 20px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.form-error {
  color: var(--danger);
  font-size: 0.78rem;
  margin-top: 6px;
  font-family: var(--font-sans);
}

/* ELO Chips */
.difficulty-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.group-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

.elo-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.elo-chip {
  background: rgba(20, 14, 34, 0.7);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.elo-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.elo-chip.active {
  background: rgba(240, 179, 101, 0.18);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.lobby-footer {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.lobby-footer a {
  color: var(--accent);
  text-decoration: none;
}

.lobby-footer a:hover {
  text-decoration: underline;
}

/* -----------------------------------------------
   Game Screen Layout
----------------------------------------------- */
#screen-game {
  width: 100%;
  height: calc(100vh - 3.5rem);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 1.5rem 2rem;
  overflow: hidden;
}

#screen-game.active {
  display: flex;
}

.game-layout {
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  width: 100%;
  height: 100%;
  max-height: 85vh;
  align-items: center;
  justify-content: center;
}

.game-board-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Opponent and Player bars */
.opponent-bar-top {
  width: min(62vh, 75vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  font-family: var(--font-display);
  gap: 6px;
  box-sizing: border-box;
}

.opp-info-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.opponent-dot {
  background: var(--muted);
  box-shadow: 0 0 8px rgba(179, 168, 152, 0.4);
}

.my-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.opponent-text-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-back-text {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-back-text:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-resign-text {
  background: transparent;
  border: 1px solid rgba(224, 108, 117, 0.4);
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-resign-text:hover {
  background: rgba(224, 108, 117, 0.15);
  border-color: var(--danger);
}

/* -----------------------------------------------
   3D Flip Confirmation Buttons (Horizontal Axis)
----------------------------------------------- */
.flip-confirm-wrapper {
  perspective: 600px;
  -webkit-perspective: 600px;
  display: inline-block;
  vertical-align: middle;
  height: 28px;
  width: 86px;
  flex-shrink: 0;
  position: relative;
  transition: width 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-confirm-wrapper.is-flipped {
  width: 146px;
}

.flip-confirm-card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.38s cubic-bezier(0.34, 1.35, 0.64, 1);
}

.flip-confirm-wrapper.is-flipped .flip-confirm-card {
  transform: rotateX(180deg);
}

.flip-confirm-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.flip-confirm-front {
  transform: rotateX(0deg);
  z-index: 2;
}

.flip-confirm-wrapper.is-flipped .flip-confirm-front {
  pointer-events: none;
}

.flip-confirm-front .btn-back-text,
.flip-confirm-front .btn-resign-text {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-sizing: border-box;
  white-space: nowrap;
}

.flip-confirm-back {
  transform: rotateX(180deg);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(18, 14, 28, 0.96);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
}

.flip-confirm-wrapper:not(.is-flipped) .flip-confirm-back {
  pointer-events: none;
}

.flip-back-resign {
  border-color: rgba(224, 108, 117, 0.6);
  background: rgba(28, 12, 18, 0.96);
  box-shadow: 0 4px 12px rgba(224, 108, 117, 0.2);
}

.flip-back-exit {
  border-color: rgba(240, 179, 101, 0.6);
  background: rgba(20, 16, 28, 0.96);
  box-shadow: 0 4px 12px rgba(240, 179, 101, 0.15);
}

.flip-confirm-prompt {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.flip-back-resign .flip-confirm-prompt {
  color: var(--danger);
}

.flip-back-exit .flip-confirm-prompt {
  color: var(--accent);
}

.flip-confirm-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-flip-action {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0 7px;
  height: 20px;
  line-height: 20px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.btn-flip-no {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border-color: var(--border);
}

.btn-flip-no:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-flip-yes {
  background: var(--accent);
  color: #05030a;
  border-color: var(--accent);
}

.btn-flip-yes:hover {
  background: #ffc978;
  border-color: #ffc978;
}

.btn-flip-yes.danger {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.btn-flip-yes.danger:hover {
  background: #ff7b85;
  border-color: #ff7b85;
}

.room-pill-badge {
  background: rgba(240, 179, 101, 0.12);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 3px 10px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.room-pill-badge:hover {
  background: var(--accent);
  color: #05030a;
}

.badge-tag {
  opacity: 0.75;
  font-size: 0.65rem;
}

/* -----------------------------------------------
   Chess Board Styles
----------------------------------------------- */
/* -----------------------------------------------
   Chess Board Stage & Dithered Gradient Aura
   (Dissolves square colors into the background nebula)
----------------------------------------------- */
.board-stage {
  position: relative;
  width: min(62vh, 75vw);
  height: min(62vh, 75vw);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The Dithered Gradient Aura:
   Screened through eboshii's 12px Bayer ordered dither mask, dissolving outward into the live background nebula */
.board-dither-aura {
  position: absolute;
  inset: -48px;
  pointer-events: none;
  z-index: 0;
  -webkit-mask-image: var(--bayer-dither-med);
  mask-image: var(--bayer-dither-med);
  -webkit-mask-size: 12px 12px;
  mask-size: 12px 12px;
  opacity: 0.95;
}

/* Seamless Rounded Dither Aura
   Concentric with the chessboard's 8px rounded corners, dissolving outward into the nebula without any seams or sharp edges */
.board-dither-aura::before {
  content: '';
  position: absolute;
  inset: 48px;
  border-radius: 8px;
  pointer-events: none;
  background: transparent;
  box-shadow:
    0 0 0 1px var(--aura-color),
    0 0 8px 2px rgba(230, 224, 214, 0.45),
    0 0 20px 6px rgba(230, 224, 214, 0.30),
    0 0 34px 10px rgba(230, 224, 214, 0.16),
    0 0 46px 14px rgba(230, 224, 214, 0.05);
}

.aura-edge,
.aura-corner {
  display: none;
}

.board-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  border: 1px solid rgba(240, 179, 101, 0.32);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.9),
    0 0 1px rgba(240, 179, 101, 0.4),
    inset 0 0 0 1px rgba(240, 179, 101, 0.12);
  z-index: 1;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
}

.square {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.square.light {
  background-color: var(--board-light);
  background-image: linear-gradient(135deg, #ECE6D5 0%, #DBD3BE 100%);
}

.square.dark {
  background-color: var(--board-dark);
  background-image:
    radial-gradient(1px 1px at 28% 32%, rgba(240, 179, 101, 0.18), transparent 100%),
    radial-gradient(1px 1px at 74% 68%, rgba(215, 205, 235, 0.14), transparent 100%),
    linear-gradient(135deg, #2D374D 0%, #1E2536 100%);
}

/* Coordinate labels (astrogation telemetry style) */
.coord-label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  pointer-events: none;
  line-height: 1;
}

.coord-label.rank {
  top: 3px;
  left: 4px;
}

.coord-label.file {
  bottom: 3px;
  right: 4px;
}

.light .coord-label {
  color: var(--coord-light);
}

.dark .coord-label {
  color: var(--coord-dark);
  text-shadow: 0 0 4px rgba(240, 179, 101, 0.4);
}

/* Highlights */
.square.selected {
  background-color: var(--highlight-select) !important;
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 14px rgba(240, 179, 101, 0.35);
}

.square.last-move {
  background-color: var(--highlight-last) !important;
  box-shadow: inset 0 0 8px rgba(240, 179, 101, 0.18);
}

.square.check {
  background-color: var(--highlight-check) !important;
  box-shadow: inset 0 0 0 2px var(--danger), 0 0 16px rgba(224, 108, 117, 0.45);
}

.square.trap {
  background-color: var(--highlight-trap) !important;
  animation: trapPulse 1s ease infinite alternate;
}

@keyframes trapPulse {
  from { box-shadow: inset 0 0 12px var(--accent), 0 0 16px rgba(240, 179, 101, 0.4); }
  to { box-shadow: inset 0 0 24px #FF7A00, 0 0 28px rgba(255, 122, 0, 0.6); }
}

/* Piece shredding, shattering & explosion system */
.piece-shatter-container {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 20;
  overflow: visible;
}

.piece-shard {
  position: absolute;
  width: 86%;
  height: 86%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  animation: shardShred 0.72s cubic-bezier(0.12, 0.85, 0.35, 1) forwards;
  will-change: transform, opacity, filter;
  filter: drop-shadow(0 0 8px #FF7A00) brightness(2);
}

.piece-shard svg {
  width: 100%;
  height: 100%;
}

@keyframes shardShred {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
    filter: drop-shadow(0 0 10px #ffffff) brightness(3);
  }
  15% {
    opacity: 1;
    filter: drop-shadow(0 0 18px #FF7A00) brightness(2.4);
  }
  45% {
    opacity: 0.95;
    filter: drop-shadow(0 0 24px #FF3B30) brightness(1.8);
  }
  75% {
    opacity: 0.6;
    filter: drop-shadow(0 0 12px #E06C75) brightness(1.2);
  }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(var(--scale, 0.2));
    opacity: 0;
    filter: brightness(0.1);
  }
}

/* Radiant ember sparks */
.explosion-spark {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 20%, #ffb300 55%, #ff3b30 100%);
  box-shadow: 0 0 8px #ff7a00, 0 0 16px #ff3b30;
  pointer-events: none;
  z-index: 25;
  animation: sparkBurst 0.65s cubic-bezier(0.08, 0.85, 0.35, 1) forwards;
  will-change: transform, opacity;
}

@keyframes sparkBurst {
  0% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 1;
  }
  50% {
    opacity: 0.95;
  }
  100% {
    transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(0.05);
    opacity: 0;
  }
}

/* Screen rumble / board shake */
.board-shaking {
  animation: boardRumble 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes boardRumble {
  0% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-3px, 2px) rotate(-0.3deg); }
  30% { transform: translate(3px, -2px) rotate(0.3deg); }
  45% { transform: translate(-2px, -1.5px) rotate(-0.15deg); }
  60% { transform: translate(2px, 1px) rotate(0.1deg); }
  75% { transform: translate(-1px, 0.5px) rotate(0deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* Square explosion flash and expanding cosmic shockwave ring */
.square.exploding {
  position: relative;
  z-index: 18;
}

.square.exploding::after {
  content: '';
  position: absolute;
  inset: -30%;
  border-radius: 50%;
  border: 2px solid #FF7A00;
  box-shadow: 0 0 32px rgba(255, 122, 0, 0.95), inset 0 0 24px rgba(224, 108, 117, 0.85);
  background: radial-gradient(circle, rgba(255, 255, 230, 0.98) 0%, rgba(255, 122, 0, 0.8) 35%, rgba(224, 50, 50, 0.45) 65%, transparent 100%);
  animation: shockwaveRing 0.7s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
  pointer-events: none;
  z-index: 19;
}

@keyframes shockwaveRing {
  0% {
    transform: scale(0.15);
    opacity: 1;
  }
  40% {
    opacity: 0.92;
  }
  100% {
    transform: scale(2.6);
    opacity: 0;
  }
}

/* Move target dots & capture rings (crisp solid geometry, zero soft blur) */
.move-target-dot {
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
}

/* Crisp solid dark dot with defined ivory/gold ring on white squares */
.square.light .move-target-dot {
  background: #1C2333;
  border: 2px solid #F0B365;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* Crisp solid gold dot with defined starlight ring on dark squares */
.square.dark .move-target-dot {
  background: #F0B365;
  border: 2px solid #FFF8EC;
  box-shadow: 0 0 8px rgba(240, 179, 101, 0.45);
}

.move-target-capture {
  position: absolute;
  width: 86%;
  height: 86%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
}

.square.light .move-target-capture {
  border: 3px solid #1C2333;
  outline: 1.5px solid #F0B365;
  outline-offset: -5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.square.dark .move-target-capture {
  border: 3px solid #F0B365;
  outline: 1.5px solid #FFF8EC;
  outline-offset: -5px;
  box-shadow: 0 0 10px rgba(240, 179, 101, 0.4);
}

/* Pieces (crisp vector edges, high complimentary contrast) */
.chess-board {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.piece {
  width: 86%;
  height: 86%;
  cursor: grab;
  z-index: 5;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.08s ease;
}

.piece-white svg,
.promo-option .piece-white svg {
  filter: drop-shadow(0 2px 3px rgba(10, 6, 20, 0.45)) drop-shadow(0 0 1px rgba(255, 255, 255, 0.65));
}

.piece-black svg,
.promo-option .piece-black svg {
  filter: drop-shadow(0 2px 4px rgba(10, 6, 20, 0.85)) drop-shadow(0 0 1px rgba(10, 6, 20, 0.95)) drop-shadow(0 0 2.5px rgba(240, 179, 101, 0.45));
}

.piece:active {
  cursor: grabbing;
  transform: scale(1.08);
}

.piece.is-dragging-source {
  opacity: 0.22;
}

.piece-drag-clone {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%) scale(1.15);
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.75));
  cursor: grabbing;
  will-change: transform, left, top;
}

.piece-drag-clone svg {
  width: 100%;
  height: 100%;
}


/* Pawn Promotion Overlay */
.promotion-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 3, 10, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.promotion-overlay.active {
  display: flex;
}

.promotion-box {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 6px;
  display: flex;
  gap: 12px;
  padding: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8);
}

.promo-option {
  width: 54px;
  height: 54px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.15s;
}

.promo-option:hover {
  border-color: var(--accent);
  background: rgba(240, 179, 101, 0.15);
  transform: scale(1.08);
}

/* Pass and play blindfold */
.pass-play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 3, 10, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 25;
  padding: 20px;
}

.pass-play-card {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 24px;
  text-align: center;
  max-width: 320px;
}

.pass-play-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.pass-play-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.pass-play-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}

/* My Info Bar */
.my-info-bar-bottom {
  width: min(62vh, 75vw);
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.my-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.my-name-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.my-name-display {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.turn-status-text-display {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

.game-end-stats {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 3px;
  text-transform: uppercase;
}

.game-end-stats strong {
  color: var(--accent);
  font-weight: 700;
}

.captured-pieces-box {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: 8px;
  min-height: 24px;
  flex-shrink: 0;
}

.captured-piece-mini {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: -5px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.captured-piece-mini:first-child {
  margin-left: 0;
}

.captured-piece-mini:hover {
  transform: translateY(-2px) scale(1.25);
  z-index: 3;
}

.captured-piece-mini svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.material-advantage-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(240, 179, 101, 0.14);
  border: 1px solid rgba(240, 179, 101, 0.35);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 5px;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

/* Navigation controls */
.navigation-controls-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  width: min(62vh, 75vw);
  justify-content: center;
}

.btn-game-control {
  background: rgba(20, 14, 34, 0.75);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-game-control:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-game-live {
  background: rgba(240, 179, 101, 0.12);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-game-live:hover {
  background: var(--accent);
  color: #05030a;
}

/* -----------------------------------------------
   Move Log & Predictions Panel
----------------------------------------------- */
.game-log-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 320px;
  height: min(68vh, 85vw);
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.move-log-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.conn-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(152, 195, 121, 0.6);
}

.conn-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(224, 108, 117, 0.6);
}

.move-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.move-row {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.1s;
}

.move-row:hover {
  background: rgba(240, 179, 101, 0.08);
}

.move-row.active {
  background: rgba(240, 179, 101, 0.16);
  color: var(--accent);
}

.move-num {
  width: 36px;
  color: var(--muted);
  font-size: 0.75rem;
}

.move-white, .move-black {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.move-event-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 4px;
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.12s;
}

.move-event-item:hover {
  background: rgba(240, 179, 101, 0.15);
}

.move-event-item.active {
  background: rgba(240, 179, 101, 0.25);
  color: var(--accent);
  font-weight: 600;
}

.trap-badge {
  background: rgba(224, 108, 117, 0.2);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
}

.pred-badge {
  color: var(--accent);
  font-size: 0.7rem;
}

/* -----------------------------------------------
   Modals & Dialogs
----------------------------------------------- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 10, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 1rem;
}

.dialog-overlay.active {
  display: flex;
}

.dialog-box {
  background: rgba(14, 10, 24, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
}

.dialog-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.dialog-message {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Host Room specifics (Inline card & legacy box) */
/* --- OPEN GAMES LOBBY LIST --- */

.open-games {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 168px;
  overflow-y: auto;
}

.open-games-empty {
  padding: 10px 2px;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.4);
}

.open-game-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-family: inherit;
  color: var(--text, #F5F0E8);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(235, 225, 210, 0.16);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.open-game-row:hover {
  background: rgba(240, 179, 101, 0.1);
  border-color: rgba(240, 179, 101, 0.55);
  transform: translateX(2px);
}

.open-game-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: #F0B365;
}

.open-game-meta {
  flex: 1;
  text-align: left;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.45);
}

.open-game-join {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: rgba(245, 240, 232, 0.55);
}

.open-game-row:hover .open-game-join { color: #F0B365; }

.host-room-card {
  background: rgba(14, 10, 24, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 1.25rem 1rem;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  animation: fadeInHost 0.2s ease;
}

@keyframes fadeInHost {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.host-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.host-room-box {
  text-align: center;
  max-width: 440px;
}

.invite-code-container {
  margin: 1.5rem 0 1.25rem;
  background: var(--code-bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 18px 24px;
  box-shadow: inset 0 0 20px rgba(240, 179, 101, 0.1);
}

.invite-code-display {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-glow);
}

.invite-actions-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.btn-action-pill {
  background: rgba(240, 179, 101, 0.12);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 20px;
  padding: 8px 16px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-action-pill:hover {
  background: var(--accent);
  color: #05030a;
}

.host-waiting-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.pulsing-amber-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulseDot 1.4s infinite ease-in-out;
}

@keyframes pulseDot {
  0% { transform: scale(0.85); opacity: 0.4; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.4; }
}

.dialog-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-dialog {
  padding: 9px 18px;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-dialog-confirm {
  background: var(--accent);
  color: #05030a;
  border: 1px solid var(--accent);
}

.btn-dialog-confirm:hover {
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-dialog-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-dialog-cancel:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-dialog-danger {
  background: rgba(224, 108, 117, 0.15);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-dialog-danger:hover {
  background: var(--danger);
  color: #05030a;
}

/* Form input */
.form-input {
  width: 100%;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 10px 12px;
  outline: none;
  transition: all 0.15s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* -----------------------------------------------
   Toast Notifications
----------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: rgba(14, 10, 24, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 22px;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s ease;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  border-color: var(--accent);
  color: var(--accent);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

/* -----------------------------------------------
   Mobile & Responsive Adjustments
----------------------------------------------- */
@media (max-width: 900px) {
  .game-layout {
    flex-direction: column;
    height: auto;
    max-height: none;
    gap: 1rem;
    overflow-y: auto;
  }

  #screen-game {
    height: auto;
    min-height: calc(100vh - 3.5rem);
    overflow-y: auto;
  }

  .game-log-panel {
    width: min(62vh, 75vw);
    height: 240px;
  }
}

/* -----------------------------------------------
   Footer (matching eboshii.dev)
----------------------------------------------- */
footer {
  background: rgba(5, 3, 10, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 0.35rem 2rem;
  min-height: 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  line-height: 1.4;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-xs);
  margin-top: auto;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

/* Ensure global kofi host iframe never renders on Predichess */
#global-kofi-host {
  display: none !important;
}

.footer-inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.footer-sep {
  color: var(--muted);
  opacity: 0.6;
}

.footer-copy {
  opacity: 0.45;
}

.footer-tip-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
}

.footer-slash {
  color: var(--muted);
  opacity: 0.5;
}

.footer-stats-link {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-bottom-color 0.15s;
}

.footer-stats-link:hover,
.footer-stats-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent-dim);
}

@media (max-width: 640px) {
  /* Same root size as desktop rather than smaller -- the layout itself
     already works at this width, it was just rendering everything a size
     down from it. */
  html { font-size: 18px; }

  /* The board, the name bars above/below it, the nav-control row, and the
     move log all share this one width so the column stays aligned -- every
     one of them has to move together, or the board drifts out from under
     the bars framing it. Kept as a single variable so that stays true.
     A modest bump from the shared 62vh/75vw they all used before: the board
     has a decorative glow that extends about 60px past its own edge, which
     only has safe room to fade out at a size close to this one. */
  :root {
    --mobile-board-col: min(63vh, 79vw);
  }

  .board-stage,
  .opponent-bar-top,
  .my-info-bar-bottom,
  .navigation-controls-row,
  .game-log-panel {
    width: var(--mobile-board-col);
  }

  .board-stage {
    height: var(--mobile-board-col);
  }

  header { padding: 0 1rem; }
  footer { padding: 0.35rem 1rem; }

  nav {
    height: auto;
    padding: 0.75rem 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .nav-links {
    flex-wrap: wrap;
    gap: 1.25rem;
  }

  .nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: auto;
  }
}
