/* ─────────────────────────────────────────────
   LUDO GAME — styles.css
   Dark glassmorphism design system
───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* Brand palette */
  --red:    #ff4757;
  --green:  #2ed573;
  --yellow: #ffa502;
  --blue:   #1e90ff;
  --purple: #a855f7;

  /* Neutrals */
  --bg-0:   #0a0b0f;
  --bg-1:   #10121a;
  --bg-2:   #181b27;
  --bg-3:   #22263a;
  --glass:  rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.10);
  --glass-hover:  rgba(255,255,255,0.08);

  /* Text */
  --txt-primary:   #f0f2ff;
  --txt-secondary: #8892b0;
  --txt-muted:     #4a5270;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.6);

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-0);
  color: var(--txt-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Background ambient glow ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(168,85,247,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 80% 80%, rgba(30,144,255,0.10) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 60% 20%, rgba(255,71,87,0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Utility ── */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }

/* ─────────────────────────────────────────────
   LOBBY PAGE
───────────────────────────────────────────── */
#lobby-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

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

.lobby-hero .logo {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 24px rgba(168,85,247,0.6));
  animation: floatBob 3s ease-in-out infinite;
}

@keyframes floatBob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.lobby-hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 900;
  background: linear-gradient(135deg, #f0f2ff 0%, #a855f7 50%, #1e90ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
  line-height: 1.1;
}

.lobby-hero p {
  margin-top: 0.75rem;
  color: var(--txt-secondary);
  font-size: 1.1rem;
}

/* Cards */
.lobby-cards {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 780px;
}

.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  flex: 1;
  min-width: 300px;
  max-width: 360px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.card p {
  color: var(--txt-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ── Inputs ── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--txt-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--purple);
  background: rgba(168,85,247,0.08);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.15);
}

input::placeholder { color: var(--txt-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(168,85,247,0.4);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(168,85,247,0.6); }

.btn-secondary {
  background: linear-gradient(135deg, #1e90ff 0%, #0066cc 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(30,144,255,0.35);
}
.btn-secondary:hover { box-shadow: 0 6px 28px rgba(30,144,255,0.55); }

.btn-danger {
  background: linear-gradient(135deg, #ff4757 0%, #c0392b 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255,71,87,0.35);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--txt-secondary);
}
.btn-ghost:hover { border-color: var(--purple); color: var(--txt-primary); }

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  width: auto;
  border-radius: 6px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--txt-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { border-color: var(--purple); color: var(--txt-primary); }

/* ── Messages ── */
.msg-error {
  color: var(--red);
  font-size: 0.85rem;
  padding: 0.5rem;
  display: none;
}
.msg-error.visible { display: block; }

/* ── Room code display ── */
.room-code-display {
  text-align: center;
  background: rgba(168,85,247,0.1);
  border: 1px solid rgba(168,85,247,0.3);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
}
.room-code-display .code-label { font-size: 0.8rem; color: var(--txt-secondary); margin-bottom: 4px; }
.room-code-display .code-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--purple);
}

/* ── Waiting room ── */
.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.player-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.color-dot.red    { background: var(--red);    box-shadow: 0 0 8px var(--red); }
.color-dot.green  { background: var(--green);  box-shadow: 0 0 8px var(--green); }
.color-dot.yellow { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.color-dot.blue   { background: var(--blue);   box-shadow: 0 0 8px var(--blue); }

.host-badge {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 2px 8px;
  background: rgba(168,85,247,0.2);
  border: 1px solid rgba(168,85,247,0.4);
  border-radius: 99px;
  color: var(--purple);
}

/* ─────────────────────────────────────────────
   GAME PAGE
───────────────────────────────────────────── */
#game-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ── Top bar ── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(10,11,15,0.8);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  flex-shrink: 0;
  gap: 1rem;
}

#top-bar .game-title {
  font-weight: 800;
  font-size: 1.2rem;
  background: linear-gradient(90deg, #a855f7, #1e90ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#room-code-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  padding: 4px 12px;
  background: rgba(168,85,247,0.12);
  border: 1px solid rgba(168,85,247,0.3);
  border-radius: 99px;
  color: var(--purple);
  letter-spacing: 0.15em;
}

/* ── Main layout ── */
#game-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ── Left panel ── */
#left-panel {
  width: 220px;
  flex-shrink: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  border-right: 1px solid var(--glass-border);
  background: rgba(10,11,15,0.5);
}

/* ── Board area ── */
#board-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
  position: relative;
}

#ludo-canvas {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(168,85,247,0.15);
  max-width: 100%;
  max-height: 100%;
  cursor: pointer;
  transition: box-shadow 0.3s;
}

/* ── Right panel ── */
#right-panel {
  width: 220px;
  flex-shrink: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  border-left: 1px solid var(--glass-border);
  background: rgba(10,11,15,0.5);
}

/* ── Section headings ── */
.panel-section {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.panel-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--txt-muted);
  margin-bottom: 0.75rem;
}

/* ── Player cards ── */
.player-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.3s;
  position: relative;
}

.player-card.active {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 20px rgba(255,255,255,0.08);
}
.player-card.active.red    { border-color: rgba(255,71,87,0.5);  background: rgba(255,71,87,0.08);  box-shadow: 0 0 20px rgba(255,71,87,0.2); }
.player-card.active.green  { border-color: rgba(46,213,115,0.5); background: rgba(46,213,115,0.08); box-shadow: 0 0 20px rgba(46,213,115,0.2); }
.player-card.active.yellow { border-color: rgba(255,165,2,0.5);  background: rgba(255,165,2,0.08);  box-shadow: 0 0 20px rgba(255,165,2,0.2); }
.player-card.active.blue   { border-color: rgba(30,144,255,0.5); background: rgba(30,144,255,0.08); box-shadow: 0 0 20px rgba(30,144,255,0.2); }

.player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.player-avatar.red    { background: rgba(255,71,87,0.25);  color: var(--red); }
.player-avatar.green  { background: rgba(46,213,115,0.25); color: var(--green); }
.player-avatar.yellow { background: rgba(255,165,2,0.25);  color: var(--yellow); }
.player-avatar.blue   { background: rgba(30,144,255,0.25); color: var(--blue); }

.player-name {
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-indicator {
  margin-left: auto;
  font-size: 0.7rem;
}

/* ── Dice section ── */
#dice-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

#dice-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#dice-face {
  width: 72px;
  height: 72px;
  background: linear-gradient(145deg, #2a2d42, #1a1c2a);
  border: 2px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.1);
  display: grid;
  grid-template-areas:
    "a . b"
    "c g d"
    "e . f";
  padding: 10px;
  gap: 3px;
  cursor: default;
}

.dice-dot {
  width: 10px;
  height: 10px;
  background: var(--txt-primary);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(168,85,247,0.6);
  transition: opacity 0.15s;
}

#dice-face.rolling {
  animation: diceRoll 0.6s cubic-bezier(0.36,0.07,0.19,0.97);
}

@keyframes diceRoll {
  0%   { transform: rotate(0deg) scale(1); }
  15%  { transform: rotate(-20deg) scale(0.9); }
  30%  { transform: rotate(15deg) scale(1.1); }
  50%  { transform: rotate(-10deg) scale(0.95); }
  70%  { transform: rotate(8deg) scale(1.05); }
  85%  { transform: rotate(-5deg) scale(1); }
  100% { transform: rotate(0deg) scale(1); }
}

#dice-result-label {
  font-size: 0.8rem;
  color: var(--txt-muted);
  text-align: center;
}

/* ── Game log ── */
#game-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.log-entry {
  font-size: 0.78rem;
  color: var(--txt-secondary);
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  line-height: 1.4;
}

.log-entry .log-name { font-weight: 600; }
.log-entry .log-name.red    { color: var(--red); }
.log-entry .log-name.green  { color: var(--green); }
.log-entry .log-name.yellow { color: var(--yellow); }
.log-entry .log-name.blue   { color: var(--blue); }

/* ── Status bar ── */
#status-bar {
  padding: 0.5rem 1.5rem;
  background: rgba(10,11,15,0.8);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  font-size: 0.85rem;
  color: var(--txt-secondary);
  text-align: center;
  flex-shrink: 0;
}

#status-bar .status-highlight {
  font-weight: 600;
  color: var(--txt-primary);
}

/* ─────────────────────────────────────────────
   MODALS
───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s;
}
.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--txt-muted);
  font-size: 1.4rem;
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
}
.modal-close:hover { color: var(--txt-primary); }

.modal-body { display: flex; flex-direction: column; gap: 1rem; }

.form-label {
  display: block;
  font-size: 0.82rem;
  color: var(--txt-secondary);
  margin-bottom: 0.35rem;
}

/* ── Cheat panel ── */
#cheat-panel {
  background: rgba(168,85,247,0.08);
  border: 1px solid rgba(168,85,247,0.25);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}
#cheat-panel.active { display: flex; }

#cheat-panel h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--purple);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cheat-dice-btns {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.cheat-dice-btns button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(168,85,247,0.3);
  background: rgba(168,85,247,0.12);
  color: var(--txt-primary);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.cheat-dice-btns button:hover {
  background: rgba(168,85,247,0.35);
  border-color: var(--purple);
  box-shadow: 0 0 12px rgba(168,85,247,0.4);
  transform: scale(1.1);
}
.cheat-dice-btns button.selected {
  background: var(--purple);
  border-color: var(--purple);
  box-shadow: 0 0 16px rgba(168,85,247,0.6);
}

select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--txt-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
select:focus { border-color: var(--purple); }
select option { background: var(--bg-2); }

/* ── Winner overlay ── */
#winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
#winner-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.winner-card {
  text-align: center;
  padding: 3rem;
  background: var(--bg-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: winnerPop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes winnerPop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.winner-trophy { font-size: 4rem; margin-bottom: 1rem; animation: trophySpin 2s ease-in-out infinite; }
@keyframes trophySpin {
  0%,100% { transform: rotate(-10deg) scale(1); }
  50%     { transform: rotate(10deg) scale(1.1); }
}

.winner-card h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.winner-card .winner-name { font-size: 2.5rem; font-weight: 900; margin-bottom: 0.5rem; }
.winner-card .winner-name.red    { color: var(--red); }
.winner-card .winner-name.green  { color: var(--green); }
.winner-card .winner-name.yellow { color: var(--yellow); }
.winner-card .winner-name.blue   { color: var(--blue); }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.2rem;
  font-size: 0.88rem;
  color: var(--txt-primary);
  box-shadow: var(--shadow-md);
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.toast-error  { border-color: var(--red);    background: rgba(255,71,87,0.15); }
#toast.toast-success{ border-color: var(--green);  background: rgba(46,213,115,0.1); }
#toast.toast-info   { border-color: var(--purple); background: rgba(168,85,247,0.1); }

/* ── Responsive ── */
@media (max-width: 900px) {
  #left-panel, #right-panel { width: 180px; }
}

@media (max-width: 680px) {
  #game-main { flex-direction: column; }
  #left-panel, #right-panel { width: 100%; border: none; flex-direction: row; flex-wrap: wrap; }
  #board-area { min-height: 60vw; }
}
