:root {
  --ink: #f7fbff;
  --muted: rgba(247, 251, 255, 0.72);
  --panel: rgba(6, 28, 48, 0.78);
  --line: rgba(255, 255, 255, 0.14);
  --gold: #ffd24a;
  --gold-deep: #e0a820;
  --red: #e5252a;
  --green: #1db954;
  --yellow: #f5c400;
  --blue: #1a9fe0;
  --sky0: #07263d;
  --sky1: #0d3f66;
  --sky2: #12608f;
  --board: #ffffff;
  --font-display: "Fredoka", sans-serif;
  --font-body: "Nunito", sans-serif;
}

* { box-sizing: border-box; }
html {
  margin: 0;
  min-height: 100%;
  width: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
}
body.ludo-body {
  font-family: var(--font-body);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(900px 480px at 12% -8%, rgba(255, 210, 74, 0.22), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(26, 159, 224, 0.28), transparent 50%),
    linear-gradient(165deg, var(--sky0), var(--sky1) 48%, var(--sky2));
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Chrome / PWA —— */
.ludo-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 38, 61, 0.88);
}
.ludo-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.ludo-brand::after {
  content: "";
}
.ludo-top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.ludo-home-link {
  color: var(--gold);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.9rem;
}
.install-app-btn {
  border: 1px solid rgba(255, 210, 74, 0.55);
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #1a1205;
  font: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.install-app-btn[hidden] { display: none !important; }
.install-app-btn--hero {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 1rem auto 0;
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
}
.ios-install-tip {
  margin: 0.75rem 1rem 0;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  background: rgba(255, 210, 74, 0.12);
  border: 1px solid rgba(255, 210, 74, 0.35);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.ios-install-tip[hidden] { display: none !important; }
.ios-install-tip p { margin: 0; font-size: 0.9rem; color: var(--ink); font-weight: 700; }
.ludo-main {
  padding: 0;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  min-height: 0;
}
.pwa-standalone .ludo-top { padding-top: max(0.55rem, env(safe-area-inset-top)); }
.build-tag {
  text-align: center;
  font-size: 0.68rem;
  color: rgba(247, 251, 255, 0.28);
  margin: 0.35rem 0 0.75rem;
  padding-bottom: env(safe-area-inset-bottom);
  font-weight: 700;
}

/* Hide site header on room — game-bar replaces it */
body.is-room .ludo-top { display: none; }
body.is-room .build-tag { display: none; }
body.is-lobby .ludo-top { display: none; }

/* —— Lobby / Home —— */
.ludo-lobby {
  max-width: 480px;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1.1rem max(1.5rem, env(safe-area-inset-bottom));
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.home-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 36vh;
  position: relative;
  margin-bottom: 0.5rem;
}
.home-hero.is-compact {
  min-height: 0;
  flex: 0;
  margin-bottom: 0.85rem;
}
.home-hero.is-compact .home-mark {
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.4rem;
}
.home-hero.is-compact h1 { font-size: 1.8rem; }
.home-hero.is-compact p { display: none; }
.home-hero::before {
  content: "";
  position: absolute;
  inset: 8% 5% 18%;
  background:
    radial-gradient(ellipse at 50% 70%, rgba(0,0,0,.25), transparent 65%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Ccircle cx='10' cy='10' r='2' fill='rgba(255,255,255,0.06)'/%3E%3C/svg%3E");
  pointer-events: none;
}
.home-mark {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 1.1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  box-shadow: 0 14px 28px rgba(0,0,0,.3);
  animation: floaty 3.2s ease-in-out infinite;
  position: relative;
  z-index: 1;
}
.home-mark i:nth-child(1) { background: var(--red); }
.home-mark i:nth-child(2) { background: var(--green); }
.home-mark i:nth-child(3) { background: var(--blue); }
.home-mark i:nth-child(4) { background: var(--yellow); }
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 11vw, 3.8rem);
  margin: 0;
  position: relative;
  z-index: 1;
  text-shadow: 0 3px 0 rgba(0,0,0,.15);
  letter-spacing: 0.02em;
}
.home-hero h1 span { color: var(--gold); }
.home-hero p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-weight: 700;
  max-width: 18rem;
  position: relative;
  z-index: 1;
}

.mode-grid {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.mode-card {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 1.15rem;
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  text-align: left;
  transition: transform .15s ease, border-color .15s ease;
  backdrop-filter: blur(8px);
  width: 100%;
}
.mode-card:hover { transform: translateY(-2px); border-color: rgba(255,210,74,.45); }
.mode-card:active { transform: scale(.98); }
.mode-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.9rem;
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  background: linear-gradient(145deg, rgba(255,255,255,.14), rgba(255,255,255,.04));
}
.mode-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}
.mode-card small {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  margin-top: 0.15rem;
}
.mode-card .chev { color: var(--gold); font-size: 1.3rem; font-weight: 800; }

.setup-flow {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  animation: rise 0.35s ease both;
}
.setup-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}
.back-btn {
  border: 1px solid var(--line);
  background: rgba(0,0,0,.2);
  color: var(--ink);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  text-decoration: none;
}
.setup-top h2 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 1.5rem;
}
.setup-panel,
.lobby-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1.15rem;
  display: grid;
  gap: 0.85rem;
  backdrop-filter: blur(8px);
}
.setup-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field-hint {
  margin: -0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}
.field-full {
  display: grid;
  gap: 0.35rem;
}
.btn-block { width: 100%; min-height: 48px; }
.how-steps {
  list-style: none;
  margin: 1.1rem auto 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  width: 100%;
  max-width: 420px;
}
.how-steps li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}
.how-steps span {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: rgba(255, 210, 74, 0.18);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  font-weight: 800;
}
.code-input {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 800;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.07);
  color: var(--ink);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  font-size: 16px;
  width: 100%;
  outline: none;
}
.code-input:focus { border-color: rgba(255,210,74,.55); }

/* Avatar + name */
.name-avatar-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: end;
}
.name-field {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}
.name-field span {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.name-field input {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.07);
  color: var(--ink);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  font-weight: 700;
  outline: none;
  font-size: 16px;
  width: 100%;
}
.name-field input:focus { border-color: rgba(255,210,74,.55); }
.avatar-picker { position: relative; }
.avatar-preview {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.06) center/cover no-repeat;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.avatar-preview.has-photo {
  border-style: solid;
  border-color: var(--gold);
}
.avatar-preview.has-photo .avatar-cam-icon { display: none; }
.avatar-cam-icon { line-height: 1; display: grid; place-items: center; }
.avatar-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 30;
  min-width: 8.5rem;
  background: #0e3a5c;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.3rem;
  display: grid;
  gap: 0.15rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.avatar-menu[hidden] { display: none !important; }
.avatar-menu button {
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}
.avatar-menu button:hover { background: rgba(255, 255, 255, 0.08); }
.avatar-cam-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(3, 14, 24, 0.78);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.avatar-cam-modal[hidden] { display: none !important; }
.avatar-cam-card {
  width: min(100%, 360px);
  background: linear-gradient(180deg, #0e3a5c, #0a2a44);
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  padding: 1.1rem;
  display: grid;
  gap: 0.75rem;
}
.avatar-cam-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
}
.avatar-cam-card video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 0.9rem;
  background: #000;
  transform: scaleX(-1);
}
.avatar-cam-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-ghost {
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1.2rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  text-align: center;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #1a1205;
  box-shadow: 0 10px 24px rgba(0,0,0,.28);
  font-size: 1.05rem;
}
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  border-radius: 999px;
  padding: 0.85rem 1.1rem;
}
.form-msg { margin: 0; font-size: 0.9rem; font-weight: 700; }
.form-msg.err { color: #ffb4b4; }

/* —— Game room —— */
.ludo-room {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(0.65rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  position: relative;
  box-sizing: border-box;
}
.game-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.game-bar h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  letter-spacing: 0.04em;
}
.game-bar h1 span { color: var(--gold); }
.icon-btn {
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
  color: var(--ink);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  text-decoration: none;
  flex-shrink: 0;
  padding: 0;
}
.install-app-btn--icon { font-weight: 800; }

.invite-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.55rem 0.75rem;
  backdrop-filter: blur(8px);
}
.invite-box.is-playing,
.invite-box[hidden] { display: none !important; }
.invite-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  padding: 0.2rem 0;
}
.invite-toggle strong {
  font-family: var(--font-display);
  color: var(--gold);
  letter-spacing: 0.12em;
}
.invite-toggle .chev { transition: transform 0.2s ease; opacity: 0.7; }
.invite-toggle.is-open .chev { transform: rotate(180deg); }
.invite-body { margin-top: 0.65rem; display: grid; gap: 0.55rem; }
.invite-body[hidden] { display: none !important; }
.share-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
}
.btn-share {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  border-radius: 0.7rem;
  padding: 0.6rem 0.35rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  min-height: 40px;
  display: grid;
  place-items: center;
}
.btn-wa {
  background: #1f9e57;
  border-color: transparent;
  color: #fff;
}
.invite-hint {
  color: var(--gold);
  font-size: 0.85rem;
  margin: 0;
  text-align: center;
  font-weight: 800;
}
.wait-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  font-weight: 700;
}

/* Players strip */
.players-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
}
.p-pill {
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.22));
  border: 1.5px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.5rem 0.3rem 0.45rem;
  text-align: center;
  opacity: .42;
  transition: .2s ease;
  min-width: 0;
  position: relative;
}
.p-pill.is-on { opacity: 1; }
.p-pill.is-empty { opacity: .38; }
.p-pill.is-me {
  border-color: rgba(255,255,255,.28);
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(0,0,0,.18));
}
.p-pill.is-turn {
  opacity: 1;
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px rgba(255,210,74,.28),
    0 8px 18px rgba(0,0,0,.22);
  transform: translateY(-2px);
}
.p-pill.is-turn::after {
  content: "TURN";
  position: absolute;
  top: -0.45rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #1a1205;
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  line-height: 1;
}
.p-pill .dot {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  margin: 0 auto 0.28rem;
  display: block;
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
}
.p-pill .face {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.28rem;
  display: block;
  border: 2px solid currentColor;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
}
.p-pill[data-color="red"] .dot { background: var(--red); }
.p-pill[data-color="green"] .dot { background: var(--green); }
.p-pill[data-color="yellow"] .dot { background: var(--yellow); }
.p-pill[data-color="blue"] .dot { background: var(--blue); }
.p-pill[data-color="red"] .face { border-color: var(--red); }
.p-pill[data-color="green"] .face { border-color: var(--green); }
.p-pill[data-color="yellow"] .face { border-color: var(--yellow); }
.p-pill[data-color="blue"] .face { border-color: var(--blue); }
.p-pill .nm {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p-pill .home-count,
.p-pill .ptag {
  font-size: 0.6rem;
  color: var(--gold);
  font-weight: 800;
  display: block;
  margin-top: 0.12rem;
}
.p-pill .ptag { color: var(--muted); font-style: normal; text-transform: uppercase; letter-spacing: 0.03em; }

.action-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--line);
  min-height: 2rem;
}
.action-banner[data-mode="roll"] {
  background: linear-gradient(135deg, rgba(255,210,74,.22), rgba(255,210,74,.08));
  border-color: rgba(255,210,74,.55);
  animation: actionPulse 1.2s ease-in-out infinite;
}
.action-banner[data-mode="move"] {
  background: linear-gradient(135deg, rgba(29,185,84,.22), rgba(29,185,84,.08));
  border-color: rgba(29,185,84,.5);
  animation: actionPulse 1.2s ease-in-out infinite;
}
.action-banner[data-mode="wait"] {
  background: rgba(0,0,0,.22);
}
.action-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255,210,74,.18);
}
.action-banner[data-mode="move"] .action-dot { background: #1db954; box-shadow: 0 0 0 3px rgba(29,185,84,.2); }
.action-banner[data-mode="wait"] .action-dot { background: #7f93a8; box-shadow: none; }
.banner {
  text-align: center;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--ink);
  margin: 0;
  line-height: 1.25;
}
.action-banner[data-mode="roll"] .banner { color: var(--gold); }
.action-banner[data-mode="move"] .banner { color: #b8f5cc; }

.nudge-toast {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0 auto;
  width: fit-content;
  max-width: min(100%, 22rem);
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1.25;
  text-align: center;
  animation: nudgePop 0.35s cubic-bezier(.2,.9,.2,1);
  z-index: 6;
}
.nudge-toast[hidden] { display: none !important; }
.nudge-toast[data-level="1"] {
  background: linear-gradient(135deg, #fff3bf, #ffe27a);
  color: #5a3d00;
  border: 1px solid rgba(224, 168, 32, 0.65);
  box-shadow: 0 8px 18px rgba(0,0,0,.22);
}
.nudge-toast[data-level="2"] {
  background: linear-gradient(135deg, #ff8a8a, #ff4d4d);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  box-shadow: 0 8px 20px rgba(255, 60, 60, 0.35);
  animation: nudgePop 0.35s cubic-bezier(.2,.9,.2,1), nudgeShake 0.55s ease-in-out infinite;
}
.nudge-icon { font-size: 1rem; line-height: 1; }
.p-pill.is-nudge {
  animation: pillNudge 0.9s ease-in-out infinite;
}
.p-pill.is-nudge-sleep {
  animation: pillNudgeSleep 0.7s ease-in-out infinite;
  border-color: #ff6b6b !important;
  box-shadow: 0 0 0 2px rgba(255,80,80,.35), 0 8px 18px rgba(0,0,0,.22);
}

/* Board */
.board-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.board {
  width: min(100%, 94vw, 560px);
  aspect-ratio: 1;
  background: #f4f6f8;
  border-radius: 0.75rem;
  box-shadow:
    0 0 0 5px rgba(255,255,255,.22),
    0 0 0 7px rgba(0,0,0,.18),
    0 18px 40px rgba(0,0,0,.4);
  position: relative;
  overflow: hidden;
  image-rendering: auto;
}
.board-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  width: 100%;
  height: 100%;
  padding: 1.4%;
  gap: 0;
  background: #fff;
}
.cell {
  position: relative;
  border: 1px solid #b8bec6;
  background: #fff;
  min-width: 0;
  min-height: 0;
}
.cell.yard-red { background: var(--red); border-color: rgba(0,0,0,.12); }
.cell.yard-green { background: var(--green); border-color: rgba(0,0,0,.12); }
.cell.yard-yellow { background: var(--yellow); border-color: rgba(0,0,0,.12); }
.cell.yard-blue { background: var(--blue); border-color: rgba(0,0,0,.12); }
.cell.yard-nest {
  background: #fff !important;
  border-color: rgba(0,0,0,.1);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.06);
}
.cell.track { background: #fff; }
.cell.safe { color: #6b7280; }
.cell.start-red, .cell.stretch-red { background: #ffb8bb; }
.cell.start-green, .cell.stretch-green { background: #9fe8b5; }
.cell.start-yellow, .cell.stretch-yellow { background: #ffe27a; }
.cell.start-blue, .cell.stretch-blue { background: #9ed9f5; }
.cell.stretch-red, .cell.stretch-green, .cell.stretch-yellow, .cell.stretch-blue {
  border-color: rgba(0,0,0,.14);
}
.star-icon {
  position: absolute;
  inset: 14%;
  width: 72%;
  height: 72%;
  opacity: .95;
  pointer-events: none;
  z-index: 1;
  color: #8a93a0;
}
.start-arrow {
  position: absolute;
  inset: 16%;
  width: 68%;
  height: 68%;
  opacity: 1;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.55));
}
.start-arrow.arrow-down {
  background: var(--red);
  clip-path: polygon(50% 100%, 0 20%, 100% 20%);
}
.start-arrow.arrow-left {
  background: var(--green);
  clip-path: polygon(0 50%, 80% 0, 80% 100%);
}
.start-arrow.arrow-up {
  background: var(--yellow);
  clip-path: polygon(50% 0, 0 80%, 100% 80%);
}
.start-arrow.arrow-right {
  background: var(--blue);
  clip-path: polygon(100% 50%, 20% 0, 20% 100%);
}
.token-well {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid rgba(0,0,0,.16);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
  z-index: 2;
}
.center-home {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 0 0.5px rgba(0,0,0,.35));
}
.center-home .tri { position: absolute; inset: 0; }
.tri-top { background: var(--red); clip-path: polygon(0 0, 100% 0, 50% 50%); }
.tri-right { background: var(--green); clip-path: polygon(100% 0, 100% 100%, 50% 50%); }
.tri-bottom { background: var(--yellow); clip-path: polygon(0 100%, 100% 100%, 50% 50%); }
.tri-left { background: var(--blue); clip-path: polygon(0 0, 0 100%, 50% 50%); }

/* Tokens — cartoon human pawns */
.token {
  position: absolute;
  width: 104%;
  height: 104%;
  left: -2%;
  top: -14%;
  border: 0;
  padding: 0;
  background: transparent;
  z-index: 5;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,.35));
  transition: transform .12s ease;
  cursor: default;
}
.token .pin-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.token .pawn-shadow { fill: rgba(0, 0, 0, 0.28); }
.token .pawn-outline { fill: #fff; }
.token .pawn-body {
  stroke: rgba(0,0,0,.35);
  stroke-width: 1.1;
  paint-order: stroke fill;
}
.token-red .pawn-body { fill: #ff2d33; }
.token-green .pawn-body { fill: #14c95a; }
.token-yellow .pawn-body { fill: #ffcc00; }
.token-blue .pawn-body { fill: #1aadef; }
.token .pawn-shoe { fill: #1a120c; }
.token .pawn-head {
  fill: #ffc089;
  stroke: #fff;
  stroke-width: 1.6;
  paint-order: stroke fill;
}
.token .pawn-face-disc,
.token .pin-eye { fill: #ffe7cb; }
.token .pawn-eye-white { fill: #fff; stroke: rgba(0,0,0,.15); stroke-width: 0.4; }
.token .pawn-eye { fill: #1a1410; }
.token .pawn-cheek { fill: #ff8fa0; opacity: 0.9; }
.token .pawn-smile { stroke: #1a1410; stroke-width: 1.7; }
.token-red .pawn-hair { fill: #8b1518; }
.token-green .pawn-hair { fill: #0f5a2c; }
.token-yellow .pawn-hair { fill: #7a5c00; }
.token-blue .pawn-hair { fill: #0f3f7a; }
.token .pin-face {
  position: absolute;
  top: 5%;
  left: 50%;
  width: 48%;
  height: 31%;
  transform: translateX(-50%);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.2);
  pointer-events: none;
  z-index: 2;
  background: #fff;
}
.token.has-avatar .pawn-face-disc,
.token.has-avatar .pin-eye { fill: transparent; }
.token.has-avatar .pawn-face { opacity: 0; }
.token.movable {
  animation: tokenPulse 0.9s ease-in-out infinite;
  z-index: 8;
  cursor: pointer;
}
.token.movable:hover { transform: scale(1.12); }
.token.is-walking {
  z-index: 12;
  pointer-events: none;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.4));
}
.token.is-flying {
  z-index: 14;
  pointer-events: none;
  filter:
    drop-shadow(0 6px 4px rgba(0,0,0,.35))
    drop-shadow(0 0 10px rgba(255, 210, 74, 0.55));
}
.token.hop {
  animation: tokenHop 0.15s ease;
}
.token.fly-hop {
  animation: tokenFlyHop 0.095s ease;
}
.token.is-captured {
  animation: tokenCapture 0.18s ease forwards;
  z-index: 12;
  pointer-events: none;
}
.token.is-hurt {
  z-index: 16;
  animation: tokenHurt 0.7s ease;
  filter: saturate(0.7) drop-shadow(0 0 6px rgba(255,60,60,.7));
}
.token.is-slashing {
  z-index: 15;
  animation: tokenSlashPose 0.7s ease;
}
.token .pain-face {
  position: absolute;
  left: 50%;
  top: -8%;
  transform: translateX(-50%);
  font-size: 0.95rem;
  line-height: 1;
  z-index: 5;
  animation: painFacePop 0.7s ease;
  pointer-events: none;
}
.capture-fx {
  position: absolute;
  inset: -20%;
  z-index: 20;
  pointer-events: none;
  overflow: visible;
}
.talwar {
  position: absolute;
  left: 50%;
  top: 8%;
  width: 0.42rem;
  height: 2.4rem;
  transform: translate(-50%, -20%) rotate(-35deg);
  transform-origin: 50% 90%;
  animation: talwarSlash 0.55s cubic-bezier(.2,.8,.2,1) both;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.45));
}
.talwar-blade {
  position: absolute;
  left: 50%;
  top: 0;
  width: 0.34rem;
  height: 1.55rem;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #f8fafc, #94a3b8 40%, #64748b);
  border-radius: 0.2rem 0.2rem 0.05rem 0.05rem;
  border: 1px solid rgba(255,255,255,.7);
}
.talwar-blade::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8%;
  width: 1px;
  height: 75%;
  background: rgba(255,255,255,.75);
  transform: translateX(-50%);
}
.talwar-guard {
  position: absolute;
  left: 50%;
  top: 1.45rem;
  width: 1.05rem;
  height: 0.22rem;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #b45309, #fbbf24, #b45309);
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.25);
}
.talwar-hilt {
  position: absolute;
  left: 50%;
  top: 1.65rem;
  width: 0.28rem;
  height: 0.7rem;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #7c2d12, #431407);
  border-radius: 0.1rem;
}
.capture-cry {
  position: absolute;
  inset: 0;
  z-index: 21;
  pointer-events: none;
}
.capture-cry span {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  color: #ff4d4d;
  text-shadow:
    0 1px 0 #fff,
    0 0 8px rgba(255, 80, 80, 0.7),
    0 2px 4px rgba(0,0,0,.35);
  white-space: nowrap;
  animation: cryFloat 0.75s ease forwards;
}
.capture-cry span:nth-child(1) {
  left: 8%;
  top: 10%;
  font-size: 0.95rem;
  transform: rotate(-12deg);
}
.capture-cry span:nth-child(2) {
  right: 4%;
  top: 28%;
  font-size: 1.15rem;
  animation-delay: 0.08s;
  transform: rotate(10deg);
}
.capture-cry span:nth-child(3) {
  left: 28%;
  top: 0;
  font-size: 0.8rem;
  animation-delay: 0.16s;
  transform: rotate(-6deg);
}
.capture-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: rgba(255, 80, 80, 0.85);
  transform: translate(-50%, -50%);
  animation: captureBurst 0.55s ease-out forwards;
  box-shadow: 0 0 0 0 rgba(255,80,80,.5);
}
.board.board-hit {
  animation: boardHit 0.45s ease;
}
.pawn-wings {
  position: absolute;
  left: 50%;
  top: 28%;
  width: 0;
  height: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
}
.token.is-flying .pawn-wings,
.token.wings-pop .pawn-wings,
.token.wings-land .pawn-wings { opacity: 1; }
.wing {
  position: absolute;
  top: 0;
  width: 1.05rem;
  height: 0.7rem;
  background: linear-gradient(160deg, #fff7c2, #ffd24a 55%, #e0a820);
  border: 1.5px solid rgba(255,255,255,.85);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.wing-l {
  right: 0.15rem;
  border-radius: 85% 15% 40% 60%;
  transform-origin: 100% 60%;
  clip-path: ellipse(90% 70% at 60% 50%);
}
.wing-r {
  left: 0.15rem;
  border-radius: 15% 85% 60% 40%;
  transform-origin: 0% 60%;
  clip-path: ellipse(90% 70% at 40% 50%);
}
.token.is-flying .wing-l { animation: wingFlapL 0.16s ease-in-out infinite; }
.token.is-flying .wing-r { animation: wingFlapR 0.16s ease-in-out infinite; }
.token.wings-pop .pawn-wings { animation: wingsPop 0.12s ease-out; }
.token.wings-land .wing-l,
.token.wings-land .wing-r { animation: none; transform: scale(0.7); opacity: 0.7; }
.cell .token:nth-child(2) { transform: translate(-18%, 10%) scale(.9); }
.cell .token:nth-child(3) { transform: translate(18%, 10%) scale(.9); }
.cell .token:nth-child(4) { transform: translate(0, 22%) scale(.85); }
.token-well .token { width: 108%; height: 108%; left: -4%; top: -18%; }

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.55rem;
  background: linear-gradient(180deg, rgba(10,40,66,.92), rgba(6,28,48,.9));
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 0.7rem 0.8rem 0.8rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
}
.controls.is-live.is-my-turn {
  border-color: rgba(255,210,74,.45);
  box-shadow:
    0 0 0 1px rgba(255,210,74,.18),
    0 10px 28px rgba(0,0,0,.28);
}
.event-line, .turn-line {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
}
.event-line { color: var(--muted); }
.turn-line {
  text-align: right;
  color: var(--gold);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}
.turn-line .turn-name { color: var(--ink); }
.turn-line .turn-color {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: .9;
}
.dice-wrap {
  display: grid;
  justify-items: center;
  gap: 0.28rem;
}
.dice-tip {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 0.85rem;
}
.dice-wrap.is-ready .dice-tip { color: var(--gold); }
.dice-wrap.is-pick .dice-tip { color: #8dffb0; }
.dice-btn {
  width: 4.7rem;
  height: 4.7rem;
  border-radius: 1.15rem;
  border: 3px solid rgba(255,255,255,.45);
  background: linear-gradient(160deg, #fff, #e8eef5);
  color: #122;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  box-shadow:
    0 10px 20px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.9);
  transition: transform .12s ease;
  display: grid;
  place-items: center;
  padding: 0;
}
.dice-btn:disabled { opacity: .62; cursor: default; }
.dice-btn.pulse-ready {
  animation: diceReady 1s ease-in-out infinite;
  border-color: var(--gold);
}
.dice-btn.rolling { animation: diceRoll .45s linear infinite; }
.board-stage.is-pick .board {
  box-shadow:
    0 0 0 5px rgba(29,185,84,.28),
    0 0 0 7px rgba(0,0,0,.18),
    0 18px 40px rgba(0,0,0,.4);
}
.board-stage.is-roll .board {
  box-shadow:
    0 0 0 5px rgba(255,210,74,.28),
    0 0 0 7px rgba(0,0,0,.18),
    0 18px 40px rgba(0,0,0,.4);
}

/* Overlays */
.join-overlay, .winner-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 14, 24, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.join-overlay[hidden], .winner-overlay[hidden] { display: none !important; }
.join-card, .win-card, .winner-card {
  width: min(100%, 380px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  padding: 1.6rem 1.3rem;
  backdrop-filter: blur(10px);
  animation: winPop .55s cubic-bezier(.2,.9,.2,1) both;
  display: grid;
  gap: 0.75rem;
  text-align: center;
}
.join-card h2, .win-card h2, .winner-card h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin: 0;
}
.join-code { margin: 0; color: var(--muted); font-weight: 700; }
.join-code strong { color: var(--gold); letter-spacing: 0.12em; }
.win-trophy, .win-emoji {
  font-size: 3.4rem;
  animation: crownBob 1.4s ease-in-out infinite;
  line-height: 1;
}
.win-card p, .winner-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}
.win-actions { display: grid; gap: 0.6rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(-3deg); }
}
@keyframes crownBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes tokenPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)) drop-shadow(0 0 0 transparent); }
  50% { transform: scale(1.12); filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)) drop-shadow(0 0 8px var(--gold)); }
}
@keyframes tokenHop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-28%) scale(1.12); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes tokenFlyHop {
  0% { transform: translateY(-18%) scale(1.05) rotate(-4deg); }
  45% { transform: translateY(-55%) scale(1.18) rotate(4deg); }
  100% { transform: translateY(-18%) scale(1.05) rotate(-2deg); }
}
@keyframes wingFlapL {
  0%, 100% { transform: rotate(18deg) scaleX(1); }
  50% { transform: rotate(-28deg) scaleX(1.08); }
}
@keyframes wingFlapR {
  0%, 100% { transform: rotate(-18deg) scaleX(1); }
  50% { transform: rotate(28deg) scaleX(1.08); }
}
@keyframes wingsPop {
  from { transform: scale(0.2); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes tokenCapture {
  0% { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(0.35) rotate(-25deg); opacity: 0.35; }
}
@keyframes tokenHurt {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  15% { transform: translate(-12%, -6%) rotate(-12deg) scale(1.08); }
  30% { transform: translate(14%, 4%) rotate(10deg); }
  45% { transform: translate(-10%, 8%) rotate(-8deg); }
  60% { transform: translate(10%, -4%) rotate(6deg); }
  80% { transform: translate(-4%, 2%) rotate(-3deg); }
}
@keyframes tokenSlashPose {
  0% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.15) rotate(-8deg) translateY(-10%); }
  60% { transform: scale(1.08) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes talwarSlash {
  0% { transform: translate(-120%, -80%) rotate(-110deg); opacity: 0; }
  25% { opacity: 1; }
  55% { transform: translate(-50%, -10%) rotate(-20deg); opacity: 1; }
  100% { transform: translate(40%, 50%) rotate(55deg); opacity: 0; }
}
@keyframes cryFloat {
  0% { opacity: 0; transform: translateY(8px) scale(0.6); }
  25% { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-28px) scale(1); }
}
@keyframes painFacePop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.4); }
  30% { opacity: 1; transform: translateX(-50%) scale(1.25); }
  100% { opacity: 0.85; transform: translateX(-50%) translateY(-6px) scale(1); }
}
@keyframes captureBurst {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; box-shadow: 0 0 0 0 rgba(255,80,80,.55); }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; box-shadow: 0 0 0 18px rgba(255,80,80,0); }
}
@keyframes boardHit {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -1px); }
  80% { transform: translate(2px, 1px); }
}
@keyframes diceReady {
  0%, 100% { transform: scale(1); box-shadow: 0 10px 20px rgba(0,0,0,.25), 0 0 0 0 rgba(255,210,74,.4); }
  50% { transform: scale(1.06); box-shadow: 0 10px 20px rgba(0,0,0,.25), 0 0 0 8px rgba(255,210,74,0); }
}
@keyframes actionPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}
@keyframes nudgePop {
  from { opacity: 0; transform: translateY(-8px) scale(0.92); }
  to { opacity: 1; transform: none; }
}
@keyframes nudgeShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px) rotate(-1deg); }
  75% { transform: translateX(3px) rotate(1deg); }
}
@keyframes pillNudge {
  0%, 100% { transform: translateY(-2px) scale(1); }
  50% { transform: translateY(-4px) scale(1.03); }
}
@keyframes pillNudgeSleep {
  0%, 100% { transform: translateY(-2px) scale(1); }
  50% { transform: translateY(-5px) scale(1.05); }
}
@keyframes diceRoll {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}
@keyframes winPop {
  from { opacity: 0; transform: scale(.85) translateY(16px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 780px) {
  .ludo-room {
    max-width: 720px;
  }
  .players-strip,
  .controls,
  .invite-box {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .dice-btn { width: 3.8rem; height: 3.8rem; font-size: 1.5rem; }
  .ios-install-tip { flex-direction: column; align-items: stretch; }
}

@media (hover: none) and (pointer: coarse) {
  .btn-primary, .btn-secondary { min-height: 48px; }
  .dice-btn { min-width: 52px; min-height: 52px; }
}
