:root {
  /* Dark Navy Theme Palette */
  --bg-deep: #020617;
  --bg-panel: rgba(15, 23, 42, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.15);

  /* Accents */
  --cyan-primary: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.5);
  --purple-primary: #8b5cf6;
  --amber-primary: #f59e0b;
  --red-danger: #ef4444;
  --green-success: #10b981;

  /* Text */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  /* Fonts */
  --font-main: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  zoom: 0.5;
  margin: 0;
  font-family: var(--font-main);
  background-color: var(--bg-deep);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  /* Subtle mesh gradient background */
  background-image:
    radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.15) 0px, transparent 50%);
}

#root {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* --- Ambient Effects --- */
.scanlines {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.2));
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.15;
}

.app-ambient-glow {
  position: fixed; border-radius: 50%; filter: blur(100px); z-index: 0; opacity: 0.4;
  animation: float 20s infinite ease-in-out;
}
.glow-1 { width: 600px; height: 600px; background: var(--purple-primary); top: -200px; left: -100px; }
.glow-2 { width: 500px; height: 500px; background: var(--cyan-primary); bottom: -100px; right: -100px; animation-delay: -10s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(50px, 30px); }
}

/* --- Header --- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 2rem;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
}

.logo-text {
  font-weight: 900; letter-spacing: 2px; font-size: 1.5rem;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.version { font-size: 0.8rem; color: var(--cyan-primary); vertical-align: super; }

.status-indicator {
  font-family: monospace; font-weight: 700; font-size: 0.9rem;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.status-indicator::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-indicator.online { color: var(--green-success); }
.status-indicator.online::before { background: var(--green-success); box-shadow: 0 0 10px var(--green-success); }

/* --- Common Components --- */
main { flex: 1; padding: 2rem; display: flex; flex-direction: column; overflow: hidden; }

.glass-card, .glass-panel, .glass-sidebar, .glass-container {
  background: var(--bg-panel);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--glass-highlight);
  border-radius: 24px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan-primary), #3b82f6);
  border: none; padding: 16px 40px; border-radius: 12px;
  color: #fff; font-weight: 800; letter-spacing: 2px; cursor: pointer;
  position: relative; overflow: hidden; transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 0 40px rgba(6, 182, 212, 0.6); }
.btn-primary:disabled { filter: grayscale(1); opacity: 0.5; cursor: not-allowed; }

.btn-shine {
  position: absolute; top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.4), transparent);
  transform: skewX(-20deg); transition: 0.5s;
}
.btn-primary:hover .btn-shine { left: 150%; transition: 0.7s; }

/* --- Room Creation --- */
#room-creation-screen { display: flex; justify-content: center; align-items: center; height: 100%; }
.center-card { padding: 4rem; text-align: center; max-width: 800px; width: 100%; display: flex; flex-direction: column; gap: 1.5rem; align-items: center; }
.card-icon { font-size: 4rem; margin-bottom: 1rem; }
.center-card h2 { margin: 0; font-size: 2rem; font-weight: 800; letter-spacing: 1px; }
.card-desc { color: var(--text-muted); font-size: 1.1rem; }
.status-text { margin-top: 1rem; font-family: monospace; color: var(--amber-primary); height: 1.5em; }

/* --- Lobby --- */
#lobby-screen { display: flex; gap: 2rem; height: 100%; }
.lobby-panel { display: flex; flex-direction: column; padding: 2rem; }
.lobby-panel.left { flex: 1; }
.lobby-panel.center { flex: 1; justify-content: center; align-items: center; gap: 3rem; background: none; border: none; box-shadow: none; backdrop-filter: none; }
.lobby-panel.right { flex: 1; }

.panel-header { font-size: 0.8rem; font-weight: 700; letter-spacing: 2px; color: var(--text-muted); margin-bottom: 1.5rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 0.5rem; }

.room-code-container { margin-bottom: 2rem; }
.room-code-container .label { font-size: 0.8rem; font-weight: 700; color: var(--cyan-primary); margin-bottom: 4px; }
.code-display { font-size: 4rem; font-weight: 900; letter-spacing: 8px; color: #fff; text-shadow: 0 0 20px var(--cyan-glow); font-family: monospace; }
.url-display { font-size: 1.5rem; color: var(--text-muted); font-weight: 300; }

.player-list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; overflow-y: auto; max-height: 400px; }
.lobby-player-card { background: rgba(255,255,255,0.05); padding: 1rem; border-radius: 12px; text-align: center; font-weight: 700; border: 1px solid transparent; animation: popIn 0.3s ease; }
.lobby-player-card.new { border-color: var(--green-success); }

.game-logo h1 { font-size: 5rem; font-weight: 900; margin: 0; background: linear-gradient(to bottom, #fff, #94a3b8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -2px; }
.btn-large { font-size: 1.5rem; padding: 24px 64px; border-radius: 16px; }

.instruction-item { display: flex; gap: 1rem; margin-bottom: 1.5rem; align-items: flex-start; }
.instruction-item .icon { font-size: 2rem; background: rgba(255,255,255,0.05); padding: 10px; border-radius: 12px; }
.instruction-item strong { color: var(--cyan-primary); display: block; margin-bottom: 4px; letter-spacing: 1px; }
.instruction-item p { margin: 0; color: var(--text-muted); font-size: 1.2rem; line-height: 1.4; }

/* --- Game Layout --- */
#game-layout { display: flex; gap: 1.5rem; height: 100%; position: relative; }

/* Board Area */
#board-area { flex: 1; position: relative; overflow: hidden; display: flex; }
#board-container { width: 100%; height: 100%; padding: 1.5rem; display: flex; flex-direction: column; }
#board-grid { display: grid; gap: 8px; width: 100%; height: 100%; }

/* Tiles */
.board-tile {
  background: rgba(9, 11, 23, 0.4);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  position: relative;
  transition: all 0.3s ease;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Undiscovered */
.board-tile.undiscovered { background: rgba(9, 11, 23, 0.6); border-color: rgba(255,255,255,0.02); }
.board-tile.undiscovered::after { content: ''; position: absolute; top:0; left:0; width:100%; height:100%; background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px); background-size: 8px 8px; opacity: 0.3; }
.tile-unknown { font-size: 1.5rem; opacity: 0.2; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

/* Discovered */
.board-tile.discovered {
  background: rgba(9, 11, 23, 0.7);
  border-color: rgba(255,255,255,0.1);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}
.board-tile.discovered:hover { border-color: var(--cyan-primary); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }

/* Current Player Highlight */
.board-tile.active-turn {
  border: 2px solid var(--amber-primary);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.tile-emoji {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 66.67%;
  width: 80%;
  height: 80%;
  margin: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.3));
}
.tile-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.4));
  padding: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-main);
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Player Badges on Tile */
.tile-players {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
}
.player-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 800;
  color: #000;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Custom View Container (Overlay) */
#custom-view-container {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 10;
  background: rgba(2, 6, 23, 0.8); /* Dim background */
  backdrop-filter: blur(5px);
  display: none;
}

/* Sidebar: Players */
#players-column { width: 450px; display: flex; flex-direction: column; padding: 1.5rem; }
.sidebar-header { font-size: 0.8rem; font-weight: 700; letter-spacing: 2px; color: var(--text-muted); margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; }
.pulse-dot { width: 8px; height: 8px; background: var(--green-success); border-radius: 50%; box-shadow: 0 0 8px var(--green-success); animation: blink 2s infinite; }

.sidebar-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }

/* Sidebar Player Card */
.sidebar-player-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  transition: all 0.3s ease;
}
.sidebar-player-card.active-turn {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.1), transparent);
  border-left: 3px solid var(--amber-primary);
}

.sp-header { display: flex; align-items: center; gap: 10px; }
.sp-dot { width: 10px; height: 10px; border-radius: 50%; }
.sp-name { font-weight: 700; font-size: 1rem; color: #fff; }

.sp-stats { display: flex; justify-content: space-between; background: rgba(0,0,0,0.2); padding: 6px 10px; border-radius: 6px; }
.stat-item { font-size: 1rem; color: var(--text-muted); display: flex; gap: 4px; align-items: center; }
.stat-item strong { color: #fff; }

/* Host Messages (Toast) */
#host-messages-container {
  position: fixed; top: 100px; left: 50%; transform: translateX(-50%);
  z-index: 9999; width: auto; max-width: 80%;
  pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}

.host-message {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--cyan-primary);
  backdrop-filter: blur(12px);
  padding: 1rem 3rem;
  border-radius: 50px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cyan-primary);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(-20px);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.host-message.show { opacity: 1; transform: translateY(0); }
.host-message.hide { opacity: 0; transform: translateY(-10px); }

/* Utilities */
.hidden { display: none !important; }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes blink { 50% { opacity: 0.5; } }