:root {
  /* Player colours (ludo-champ palette). Engine index: c0 green, c1 yellow, c2 blue, c3 red. */
  --green: #2BB673;
  --yellow: #F4C430;
  --blue: #3A86FF;
  --red: #E63946;
  --panel: #1b1f33;
  --panel2: #262c47;
  --text: #f2f4ff;
  --muted: #9aa3c7;
  --accent: #7c5cff;
  --cell: 26px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: rgba(10, 12, 24, 0.55); /* dim the voice room behind, stay see-through */
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
}
#app { width: 100%; max-width: 420px; }
.hidden { display: none !important; }

/* Cards / screens */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border-radius: 20px; padding: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}
.card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 18px; }
.card-head h2 { margin: 0 0 0 8px; font-size: 22px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-r { background: var(--red);} .dot-g { background: var(--green);}
.dot-y { background: var(--yellow);} .dot-b { background: var(--blue);}

.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }

.seg { display: flex; background: #12152a; border-radius: 12px; padding: 4px; }
.seg-btn {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 11px; border-radius: 9px; font-size: 15px; font-weight: 600;
}
.seg-btn.active { background: var(--accent); color: #fff; }

.switch { width: 52px; height: 30px; border-radius: 20px; border: 0; background: #3a3f5e; position: relative; }
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .18s; }
.switch[aria-pressed="true"] { background: var(--green); }
.switch[aria-pressed="true"] span { left: 25px; }

.btn { border: 0; border-radius: 12px; font-size: 16px; font-weight: 700; padding: 13px 18px; color: #fff; }
.btn-primary { background: linear-gradient(180deg, #8a6bff, #6b46ff); }
.btn-ghost { background: #2c3352; color: var(--text); }
.btn-lg { width: 100%; padding: 15px; font-size: 17px; }
.btn:disabled { opacity: .45; }

/* Waiting room */
.wait-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wait-top .spacer { flex: 1; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: #2c3352; color: #fff; font-size: 17px; }
.icon-btn.danger { background: #4a2230; color: #ff8a9b; }
#waitTitle { text-align: center; margin: 6px 0 16px; font-size: 17px; }
.seat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.seat {
  background: #12152a; border-radius: 14px; padding: 14px 8px; text-align: center;
  border: 2px solid transparent; min-height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.seat.c0 { border-color: var(--green);} .seat.c1 { border-color: var(--yellow);}
.seat.c2 { border-color: var(--blue);} .seat.c3 { border-color: var(--red);}
.seat.empty { border-style: dashed; border-color: #3a3f5e; color: var(--muted); cursor: pointer; }
.seat .avatar { width: 48px; height: 48px; border-radius: 50%; background: #2c3352 center/cover; }
.seat .plus { font-size: 34px; color: #4a5178; }
.seat .nm { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .st { font-size: 11px; color: var(--muted); }
.wait-actions { display: flex; gap: 12px; }
.wait-actions .btn { flex: 1; }
.hint { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 0; }

/* Board */
#screenBoard { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.board-top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.turn-pill { background: var(--panel2); padding: 9px 16px; border-radius: 20px; font-weight: 700; font-size: 14px; }
.board {
  position: relative;
  width: calc(var(--cell) * 15); height: calc(var(--cell) * 15);
  background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 16px 46px rgba(0,0,0,0.55);
}
.cell { position: absolute; width: var(--cell); height: var(--cell); }
.cell.path { background: #fdfdfd; border: 1px solid #e7e7ef; }
.cell.safe::after { content: "★"; color: #b9b9c8; font-size: 12px; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cell.home-r { background: var(--red);} .cell.home-g { background: var(--green);}
.cell.home-y { background: var(--yellow);} .cell.home-b { background: var(--blue);}
.cell.base-r { background: #fdecea;} .cell.base-g { background: #e9f9f0;}
.cell.base-y { background: #fef9e3;} .cell.base-b { background: #eaf4fc;}
.cell.center { background: #ececf2; }
.cell.start-r { background: var(--red);} .cell.start-g { background: var(--green);}
.cell.start-y { background: var(--yellow);} .cell.start-b { background: var(--blue);}

.token {
  position: absolute; width: calc(var(--cell) - 6px); height: calc(var(--cell) - 6px);
  border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,.4);
  transition: left .28s ease, top .28s ease; z-index: 5;
}
.token.c0 { background: var(--green);} .token.c1 { background: var(--yellow);}
.token.c2 { background: var(--blue);} .token.c3 { background: var(--red);}
.token.movable { cursor: pointer; box-shadow: 0 0 0 3px rgba(124,92,255,.9); animation: bob 0.7s infinite alternate; }
@keyframes bob { to { transform: translateY(-3px); } }

.board-bottom { display: flex; align-items: center; gap: 16px; }
.dice { width: 52px; height: 52px; border-radius: 12px; background: #fff; color: #222; font-size: 28px; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(0,0,0,.4); }
.dice.rolling { animation: shake .4s; }
@keyframes shake { 25% { transform: rotate(-18deg);} 75% { transform: rotate(18deg);} }

/* Overlays */
.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 50; }
.overlay { position: fixed; inset: 0; background: rgba(6,8,18,.7); display: flex; align-items: center; justify-content: center; z-index: 40; }
.result-card { background: var(--panel); border-radius: 20px; padding: 28px; text-align: center; width: 84%; max-width: 320px; }
.result-card .trophy { font-size: 52px; }
.result-card h2 { margin: 10px 0 4px; }
.result-card p { color: var(--muted); margin: 0 0 20px; }
.result-card .btn { width: 100%; }
