/* ============================================================================
   KORİDOR (QUORIDOR) — MOBILE-FIRST DARK OBSIDIAN UI
   ============================================================================ */

:root {
  --bg-obsidian: #0B0E14;
  --bg-elevated: #121722;
  --bg-card: rgba(20, 26, 38, 0.88);
  --bg-board: #101520;
  --bg-tile: #1A2232;
  --bg-tile-hover: #212B3F;

  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;

  --p1: #F59E0B;
  --p2: #06B6D4;
  --c1: #F59E0B;
  --c2: #06B6D4;

  --emerald: #10B981;
  --danger: #EF4444;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.16);

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background-color: var(--bg-obsidian);
  background-image:
    radial-gradient(circle at 50% 0%, rgba(245, 158, 11, 0.07) 0%, transparent 50%),
    radial-gradient(circle at 50% 100%, rgba(6, 182, 212, 0.07) 0%, transparent 50%);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}

body.in-game {
  overflow: hidden;
  position: fixed;
  inset: 0;
}

button, input {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.42;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* ============================================================================
   SVG ICONS & PLAYER DISCS
   ============================================================================ */
.ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.ico-lg {
  width: 22px;
  height: 22px;
}

.disc,
.disc-sm {
  --pc: var(--p1);
  display: inline-block;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #ffffff 0%, var(--pc) 42%, rgba(0, 0, 0, 0.45) 100%);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.55),
    0 0 10px color-mix(in srgb, var(--pc) 50%, transparent),
    inset 0 1px 2px rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}

.disc {
  width: 26px;
  height: 26px;
}

.disc-sm {
  width: 22px;
  height: 22px;
}

/* ============================================================================
   APP CONTAINER & SCREENS
   ============================================================================ */
.app-container {
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
}

.screen.active {
  display: flex;
  animation: screenFade 0.18s ease-out;
}

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

/* ============================================================================
   1. MAIN MENU & LOBBY
   ============================================================================ */
#screen-menu,
#screen-lobby {
  padding: calc(var(--safe-top) + 12px) 14px calc(var(--safe-bottom) + 12px);
  gap: 10px;
  overflow-y: auto;
  scrollbar-width: none;
}
#screen-menu::-webkit-scrollbar,
#screen-lobby::-webkit-scrollbar {
  display: none;
}

.corner-btn {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: transform 0.12s, background 0.15s, color 0.15s;
}
.corner-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.menu-hero {
  text-align: center;
  padding-top: 2px;
}

.logo-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--p1);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.28);
  margin-bottom: 3px;
}

.game-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1.05;
  background: linear-gradient(135deg, #FFFFFF 20%, #CBD5E1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-subtitle {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 11px 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-preview {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid var(--p1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

#player-name-input {
  width: 100%;
  background: rgba(9, 13, 22, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
#player-name-input:focus {
  border-color: var(--p1);
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
   opacity: 0.65;
  transition: transform 0.15s, opacity 0.15s, border-color 0.15s;
}
.color-dot.active {
  opacity: 1;
  transform: scale(1.16);
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 13px;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 14px;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active {
  transform: scale(0.97);
}

.btn-lg {
  padding: 12px 16px;
  justify-content: flex-start;
  gap: 12px;
}

.btn-text-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.btn-main-text {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.15;
}

.btn-sub-text {
  font-size: 0.73rem;
  font-weight: 500;
  opacity: 0.86;
}

.btn-primary {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #090D16;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.25);
}
.btn-primary.searching {
  background: linear-gradient(135deg, #06B6D4 0%, #0284C7 100%);
  color: #06131F;
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.28);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.85);
  color: var(--text-main);
  border: 1px solid var(--border-bright);
}

.btn-outline {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-danger {
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-sm {
  padding: 8px 11px;
  font-size: 0.8rem;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
  padding: 12px;
}

.btn-grid-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-grid-card {
  padding: 11px 12px;
  font-size: 0.88rem;
}

/* AI Difficulty Selector */
.ai-level {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 5px 8px;
}

.ai-level-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 6px;
  margin-right: auto;
}

.level-chip {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.level-chip.active {
  background: rgba(245, 158, 11, 0.18);
  color: var(--p1);
  border: 1px solid rgba(245, 158, 11, 0.38);
}

/* Live Open Rooms */
.rooms-lobby-card {
  flex: 1;
  min-height: 115px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rooms-title-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}

.rooms-title-wrap h3 {
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.live-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.rooms-count-badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s, background 0.15s;
}
.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.12);
}

.icon-btn-sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.public-rooms-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rooms-empty-state {
  margin: auto 0;
  text-align: center;
  padding: 10px 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.rooms-empty-state small {
  display: block;
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 0.72rem;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(11, 15, 25, 0.65);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}
.room-item:active {
  transform: scale(0.98);
}

.room-item-info {
  flex: 1;
  min-width: 0;
}

.room-host-name {
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-code-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
}

.btn-join-quick {
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.16);
  color: var(--p1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 0.76rem;
  font-weight: 800;
}

.footer-info {
  text-align: center;
  padding-top: 2px;
}

.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ============================================================================
   LOBBY SCREEN
   ============================================================================ */
.lobby-header {
  text-align: center;
}

.lobby-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.12);
  color: var(--p2);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.lobby-subtitle {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.room-code-card {
  text-align: center;
}

.room-code-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.room-code-display {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--p1);
  margin: 4px 0 10px;
}

.lobby-share-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.qr-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.qr-title {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.qr-wrapper {
  padding: 8px;
  background: #ffffff;
  border-radius: 12px;
  display: inline-flex;
}

#lobby-qr-img {
  width: 132px;
  height: 132px;
  display: block;
}

.players-roster {
  display: flex;
  align-items: center;
  gap: 8px;
}

.roster-slot {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.slot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pulse-avatar {
  animation: softPulse 1.6s infinite ease-in-out;
}

.slot-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.slot-name {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-status {
  font-size: 0.68rem;
  font-weight: 700;
}
.badge-ready { color: var(--emerald); }
.badge-waiting { color: var(--text-muted); }

.roster-vs {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--text-dim);
}

.lobby-footer {
  margin-top: auto;
}

/* ============================================================================
   4. GAME SCREEN — ZERO-CLUTTER 3-ELEMENT MOBILE ERGONOMICS
   ============================================================================ */
#screen-game {
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 10px calc(var(--safe-bottom) + 8px);
  gap: 6px;
  overflow: hidden;
  position: relative;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
}

.player-card {
  --pc: var(--p1);
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 14px;
  background: rgba(18, 24, 36, 0.92);
  border: 1.5px solid var(--border-subtle);
  transition: opacity 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.player-card.active {
  opacity: 1;
  border-color: var(--pc);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--pc) 35%, transparent),
    0 4px 18px color-mix(in srgb, var(--pc) 22%, transparent);
}

.player-card.idle {
  opacity: 0.48;
}

.pc-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pc-name {
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-sub {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 10 Segmented Wall-Inventory Bars */
.slats {
  display: flex;
  align-items: center;
  gap: 3px;
}

.slats i {
  display: block;
  width: 6px;
  height: 11px;
  border-radius: 2px;
  background: var(--pc);
  box-shadow: 0 0 5px color-mix(in srgb, var(--pc) 45%, transparent);
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
}

.slats i.used {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  opacity: 0.35;
  transform: scaleY(0.75);
}

.pc-steps {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.pc-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pc) 18%, rgba(15, 23, 42, 0.9));
  color: var(--pc);
  border: 1px solid color-mix(in srgb, var(--pc) 42%, transparent);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.pc-badge:empty {
  display: none;
}

.pc-badge.think {
  animation: badgePulse 1.1s infinite ease-in-out;
}

.pc-badge.warn {
  background: rgba(239, 68, 68, 0.16);
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, 0.4);
}

.pc-badge .time {
  font-family: var(--font-display);
  font-weight: 900;
  padding-left: 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.pc-badge .time.danger {
  color: var(--danger);
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ============================================================================
   CENTERPIECE BOARD & TOUCH GROOVES
   ============================================================================ */
.board-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
}

.board-wrap {
  position: relative;
  width: min(94vw, calc(100dvh - 148px), 436px);
  height: min(94vw, calc(100dvh - 148px), 436px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board {
  width: 100%;
  height: 100%;
  padding: 8px;
  border-radius: 18px;
  background: var(--bg-board);
  border: 1.5px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.board-inner {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* Tiles */
.cell {
  position: absolute;
  border-radius: 6px;
  background: var(--bg-tile);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

/* Refined, Non-Distracting Goal Line Aesthetics (matte baseline accent) */
.cell.goal-1 {
  background: color-mix(in srgb, var(--c1) 7%, var(--bg-tile));
  border-bottom: 1.5px dashed color-mix(in srgb, var(--c1) 38%, transparent);
}

.cell.goal-2 {
  background: color-mix(in srgb, var(--c2) 7%, var(--bg-tile));
  border-top: 1.5px dashed color-mix(in srgb, var(--c2) 38%, transparent);
}

.cell.last-from {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Legal Move Target Highlight */
.cell.target {
  z-index: 4;
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.55);
  box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.18);
}

.cell.target::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: targetPulse 1.3s infinite ease-in-out;
}

@keyframes targetPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.85; }
  50% { transform: scale(1.12); opacity: 1; }
}

/* Groove Junction Pins */
.pin {
  position: absolute;
  pointer-events: none;
}
.pin::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

/* Shortest-Path SVG Overlay */
.path-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

.route-line {
  --rc: var(--p1);
  fill: none;
  stroke: var(--rc);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 13 11;
  opacity: 0.65;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--rc) 55%, transparent));
  transition: d 0.12s ease;
}

.route-line.is-mine {
  stroke-width: 7.5;
  stroke-dasharray: 15 10;
  opacity: 0.88;
}

.route-dot {
  --rc: var(--p1);
  fill: var(--rc);
  stroke: var(--bg-board);
  stroke-width: 3;
  filter: drop-shadow(0 0 6px var(--rc));
}

/* Pawns */
.pawn {
  --pc: var(--p1);
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: left 0.18s cubic-bezier(0.22, 1, 0.36, 1), top 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.pawn i {
  width: 74%;
  height: 74%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffffff 0%, var(--pc) 42%, color-mix(in srgb, var(--pc) 55%, #000) 100%);
  border: 2px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.65),
    0 0 12px color-mix(in srgb, var(--pc) 48%, transparent);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pawn.active i {
  transform: scale(1.06);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.7),
    0 0 0 3px color-mix(in srgb, var(--pc) 28%, transparent),
    0 0 16px var(--pc);
}

/* Placed Walls */
.wall {
  --wc: var(--p1);
  position: absolute;
  z-index: 5;
  border-radius: 999px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--wc) 88%, #ffffff), var(--wc));
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.7),
    0 0 8px color-mix(in srgb, var(--wc) 40%, transparent);
  pointer-events: none;
}

.wall.last {
  box-shadow:
    0 0 0 1.5px #ffffff,
    0 2px 10px color-mix(in srgb, var(--wc) 75%, transparent);
}

.wall.drop {
  animation: wallSnap 0.15s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes wallSnap {
  from { transform: scale(0.85); opacity: 0.5; }
  to { transform: scale(1); opacity: 1; }
}

/* Ghost Wall Preview */
.ghost {
  --wc: var(--p1);
  position: absolute;
  z-index: 8;
  border-radius: 999px;
  pointer-events: none;
  transition: left 0.09s ease, top 0.09s ease, width 0.09s ease, height 0.09s ease;
}

.ghost.ok {
  background: linear-gradient(135deg, #34D399, #10B981);
  border: 1.5px solid #A7F3D0;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.8);
}

.ghost.bad {
  background: linear-gradient(135deg, #F87171, #EF4444);
  border: 1.5px solid #FECACA;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.8);
}

/* ============================================================================
   FLOATING 2-TAP WALL CONFIRMATION DOCK
   ============================================================================ */
.dock {
  position: absolute;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px;
  border-radius: 999px;
  background: rgba(11, 14, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.dock-info {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0 7px;
  color: var(--text-muted);
  white-space: nowrap;
}
.dock-info.good {
  color: #34D399;
}
.dock-info.bad {
  color: #F87171;
}

.dock-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}
.dock-btn:active {
  transform: scale(0.9);
}

.dock-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.dock-rotate {
  background: rgba(6, 182, 212, 0.18);
  color: var(--p2);
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.dock-confirm {
  background: var(--emerald);
  color: #052E16;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.45);
}

/* ============================================================================
   SLIDE-UP MENU SHEET & EMOTES
   ============================================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.65);
  backdrop-filter: blur(3px);
  z-index: 40;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 12px);
  transform: translateX(-50%);
  width: min(92vw, 380px);
  background: #141B29;
  border: 1px solid var(--border-bright);
  border-radius: 18px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 45;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.75);
}

.sheet-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: left;
}
.sheet-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.sheet-item.danger {
  color: #FCA5A5;
}
.sheet-item.danger.armed {
  background: rgba(239, 68, 68, 0.18);
  color: #FECACA;
}

.emotes-drawer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px;
  background: rgba(9, 13, 22, 0.65);
  border-radius: 12px;
}

.emote-btn {
  font-size: 1.35rem;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.emote-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.12);
}

.emote-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 35;
}

.emote-bubble {
  position: absolute;
  left: 50%;
  font-size: 2.1rem;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.6));
  animation: emotePop 2.2s ease-out forwards;
}
.emote-bubble.me {
  bottom: 84px;
}
.emote-bubble.opp {
  top: 84px;
}

@keyframes emotePop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
  80% { opacity: 1; transform: translate(-50%, -14px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -26px) scale(0.85); }
}

/* ============================================================================
   MODALS & TOAST
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 15, 0.78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 370px;
  background: #141B29;
  border: 1px solid var(--border-bright);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.75);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted);
}

.modal-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.large-code-input {
  width: 100%;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 11px;
  border-radius: 12px;
  background: rgba(9, 13, 22, 0.85);
  border: 1.5px solid var(--border-bright);
  color: var(--p1);
  margin-bottom: 12px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

/* Game Over Card */
.win-card {
  text-align: center;
}

.win-trophy {
  font-size: 2.8rem;
  margin-bottom: 4px;
}

#game-over-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 900;
}
#game-over-title.is-win { color: var(--p1); }
#game-over-title.is-loss { color: #F87171; }

.win-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.game-stats-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
  padding: 10px;
  border-radius: 13px;
  background: rgba(9, 13, 22, 0.65);
  border: 1px solid var(--border-subtle);
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 900;
}

.stat-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Rules Modal */
.rules-card {
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
}

.rules-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.rule-section h4 {
  color: var(--text-main);
  font-size: 0.88rem;
  margin-bottom: 3px;
}

.rule-section ul {
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.highlight-rule {
  padding: 10px;
  border-radius: 11px;
  background: rgba(245, 158, 11, 0.09);
  border: 1px solid rgba(245, 158, 11, 0.28);
}

/* Non-intrusive Toast */
.toast {
  position: fixed;
  top: calc(var(--safe-top) + 64px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  border: 1px solid var(--border-bright);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 80;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.error {
  border-color: rgba(239, 68, 68, 0.55);
  color: #FECACA;
}
.toast.success {
  border-color: rgba(16, 185, 129, 0.55);
  color: #A7F3D0;
}

@keyframes softPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Compact screen adjustments (e.g., 360x640) */
@media (max-height: 680px) {
  .game-title { font-size: 1.65rem; }
  .card { padding: 9px 11px; }
  .btn-lg { padding: 10px 14px; }
  .btn-grid-card { padding: 9px 10px; }
  .board-wrap {
    width: min(94vw, calc(100dvh - 132px), 420px);
    height: min(94vw, calc(100dvh - 132px), 420px);
  }
}
