/* Ludo Online: a navy games table, paper panels, and the four classic colours doing the talking. */
:root {
  --table: #203250;
  --table-deep: #172540;
  --paper: #fffdf8;
  --ink: #1a2333;
  --muted: #5d6779;
  --line: #d9dde5;
  --red: #d7263d;
  --green: #1b9e4b;
  --yellow: #f2b705;
  --blue: #1e6fd9;
  --red-l: #fbd5da;
  --green-l: #cfeedb;
  --yellow-l: #fdefc0;
  --blue-l: #d3e3fa;
  --radius: 14px;
  --font: 'Baloo 2', 'Trebuchet MS', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--table) radial-gradient(circle at 50% 0, #2b4268 0, var(--table) 55%, var(--table-deep) 100%) fixed;
  min-height: 100vh;
}
h1, h2 { line-height: 1.15; margin: 0 0 .5rem; font-weight: 800; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.2rem; }
a { color: var(--blue); }
.muted { color: var(--muted); }
small { font-size: .85em; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---------- Chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem clamp(1rem, 3vw, 2rem); color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar nav { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.topbar nav a { opacity: .85; font-weight: 600; }
.topbar nav a:hover { opacity: 1; }
.who { opacity: .65; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.25rem; }
.brand-mark { display: grid; grid-template-columns: 1fr 1fr; width: 26px; height: 26px; border-radius: 6px; overflow: hidden; transform: rotate(45deg); }
.brand-mark i:nth-child(1) { background: var(--red); }
.brand-mark i:nth-child(2) { background: var(--green); }
.brand-mark i:nth-child(3) { background: var(--blue); }
.brand-mark i:nth-child(4) { background: var(--yellow); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 1rem clamp(1rem, 3vw, 2rem) 3rem; }

.panel { background: var(--paper); border-radius: var(--radius); padding: 1.3rem 1.4rem; box-shadow: 0 10px 30px rgba(5, 12, 28, .28); }
.stack { display: grid; gap: .9rem; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; }
label { display: grid; gap: .25rem; font-weight: 600; }
input, select {
  font: inherit; font-weight: 500; padding: .55rem .75rem; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus { border-color: var(--blue); outline: none; }
label.check { display: flex; align-items: center; gap: .5rem; }
label.check input { width: auto; }

.btn {
  font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.2rem; border-radius: 999px; border: 2px solid var(--ink); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; transition: transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--yellow); border-color: var(--yellow); box-shadow: 0 3px 0 #b78700; }
.btn-primary:active { box-shadow: 0 1px 0 #b78700; }
.btn-small { padding: .25rem .8rem; font-size: .9rem; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }

.notice { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; background: var(--blue-l); color: #0f3b78; }
.notice-error { background: var(--red-l); color: #7d1020; }
.notice-success { background: var(--green-l); color: #0c5229; }

/* ---------- Login ---------- */
.page-login .wrap { min-height: 100vh; display: grid; place-items: center; }
.login { display: grid; grid-template-columns: auto minmax(0, 380px); align-items: center; gap: 2.5rem; }
.login-card { background: var(--paper); border-radius: var(--radius); padding: 2rem; box-shadow: 0 20px 50px rgba(5, 12, 28, .4); }
.login-board { width: 220px; aspect-ratio: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; transform: rotate(-8deg); }
.login-board .q { border-radius: 18px; box-shadow: inset 0 0 0 14px rgba(255,255,255,.18); }
.q.red { background: var(--red); } .q.green { background: var(--green); } .q.blue { background: var(--blue); } .q.yellow { background: var(--yellow); }
@media (max-width: 700px) { .login { grid-template-columns: 1fr; } .login-board { width: 120px; margin: 0 auto; } }

/* ---------- Lobby ---------- */
.lobby { display: grid; gap: 1.2rem; max-width: 820px; margin: 0 auto; }
.lobby-intro { color: #fff; padding: 1rem 0 .3rem; }
.lobby-intro h1 { font-size: 2.6rem; }
.lobby-intro .muted { color: #b9c4d8; max-width: 60ch; }
.lobby-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 680px) { .lobby-actions { grid-template-columns: 1fr; } }
.seg { border: 0; padding: 0; margin: 0; display: flex; gap: .5rem; }
.seg legend { font-weight: 600; margin-bottom: .3rem; }
.seg label { display: block; flex: 1; }
.seg input { position: absolute; opacity: 0; width: 1px; }
.seg span { display: block; text-align: center; padding: .45rem; border: 2px solid var(--line); border-radius: 10px; font-weight: 800; font-size: 1.2rem; cursor: pointer; }
.seg input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--yellow); }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 800; font-size: 1.3rem; }
.resume { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; border-left: 8px solid var(--yellow); }
.rooms { display: grid; gap: .5rem; }
.room { display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center; padding: .6rem .8rem; border: 2px solid var(--line); border-radius: 12px; }
.room .muted { display: block; font-size: .9rem; }
.seats { font-weight: 700; color: var(--muted); }

/* ---------- Waiting room ---------- */
.waiting { display: grid; place-items: center; padding-top: 2rem; }
.waiting-card { width: min(480px, 100%); text-align: center; }
.room-code { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: .3rem 0 1.2rem; flex-wrap: wrap; }
.room-code span { font-size: 2.6rem; font-weight: 800; letter-spacing: .2em; }
.w-players { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; text-align: left; }
.w-players li { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; border-radius: 10px; background: #f1f3f7; font-weight: 600; }
.w-players li.empty { background: none; border: 2px dashed var(--line); color: var(--muted); font-weight: 500; }
.w-players small { background: var(--ink); color: #fff; border-radius: 6px; padding: 0 .4rem; }
.waiting-card .row { justify-content: center; }

/* ---------- Game table ---------- */
.table { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .table { grid-template-columns: 1fr; } }
.board-wrap { display: grid; place-items: center; }
.board { position: relative; width: min(100%, 78vh, 680px); aspect-ratio: 1; border-radius: 18px; overflow: hidden; box-shadow: 0 0 0 10px #fff, 0 24px 60px rgba(0, 0, 0, .45); background: #fff; }
.board-svg { display: block; width: 100%; height: 100%; }
.b-bg { fill: #fff; }
.b-cell { fill: #fff; stroke: #c9ced8; stroke-width: .035; }
.b-yard-in { fill: #fff; }
.b-slot { stroke-width: .07; }
.f-red { fill: var(--red); } .f-green { fill: var(--green); } .f-yellow { fill: var(--yellow); } .f-blue { fill: var(--blue); }
.s-red { fill: var(--red-l); stroke: var(--red); } .s-green { fill: var(--green-l); stroke: var(--green); }
.s-yellow { fill: var(--yellow-l); stroke: var(--yellow); } .s-blue { fill: var(--blue-l); stroke: var(--blue); }
.b-cell.f-red { fill: var(--red); } .b-cell.f-green { fill: var(--green); } .b-cell.f-yellow { fill: var(--yellow); } .b-cell.f-blue { fill: var(--blue); }
.b-star { fill: #aab2c0; }
.b-star.on-color { fill: rgba(255, 255, 255, .85); }
.b-tri { stroke: #fff; stroke-width: .04; }

.tokens { position: absolute; inset: 0; pointer-events: none; }
.token {
  /* A pawn seen from above at an angle: a glossy base dome with a raised head on top. */
  position: absolute; width: 5.4%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.9) 0 7%, var(--tc-l) 22%, var(--tc) 55%, var(--tc-d) 100%);
  box-shadow:
    0 3px 0 var(--tc-d),                    /* the base's edge */
    0 6px 7px rgba(0, 0, 0, .45),           /* shadow cast on the board */
    inset 0 -3px 4px rgba(0, 0, 0, .3),     /* shading under the dome */
    inset 0 2px 2px rgba(255, 255, 255, .5);
  transition: left .35s cubic-bezier(.3, 1.4, .5, 1), top .35s cubic-bezier(.3, 1.4, .5, 1), width .2s;
  cursor: default; pointer-events: auto;
}
.token::after {
  content: ""; position: absolute; left: 24%; right: 24%; top: 12%; bottom: 30%; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #fff 0 10%, var(--tc-l) 32%, var(--tc) 72%, var(--tc-d) 100%);
  box-shadow: 0 3px 3px rgba(0, 0, 0, .4), 0 1px 0 var(--tc-d);
}
.token.stacked { width: 4.2%; }
.t-red    { --tc: var(--red);    --tc-l: #ff7586; --tc-d: #8c1223; }
.t-green  { --tc: var(--green);  --tc-l: #63d890; --tc-d: #0b5e2c; }
.t-yellow { --tc: var(--yellow); --tc-l: #ffe58a; --tc-d: #a67a00; }
.t-blue   { --tc: var(--blue);   --tc-l: #74b0ff; --tc-d: #0d3f88; }
.token.movable {
  cursor: pointer; z-index: 5; animation: bob .8s ease-in-out infinite;
  box-shadow:
    0 3px 0 var(--tc-d), 0 0 0 3px #fff, 0 0 0 6px var(--ink),
    0 10px 10px rgba(0, 0, 0, .4), inset 0 -3px 4px rgba(0, 0, 0, .3);
}
.token:disabled { opacity: 1; }
@keyframes bob { 50% { transform: translate(-50%, -64%); } }

.side { display: grid; gap: 1rem; }
.turn { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; align-items: center; border-top: 8px solid var(--line); }
.turn-red { border-top-color: var(--red); } .turn-green { border-top-color: var(--green); }
.turn-yellow { border-top-color: var(--yellow); } .turn-blue { border-top-color: var(--blue); }
.turn-text { display: grid; }
.turn-text strong { font-size: 1.15rem; line-height: 1.25; }
.turn-text span { font-size: .85rem; }
.btn-roll { grid-column: 1 / -1; font-size: 1.15rem; padding: .7rem; }
.dice {
  width: 64px; height: 64px; border-radius: 14px; background: #fff; border: 3px solid var(--ink);
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px; gap: 2px;
}
.dice i { display: block; border-radius: 50%; }
.dice i.pip { background: var(--ink); }
.dice.d-red { border-color: var(--red); } .dice.d-red i.pip { background: var(--red); }
.dice.d-green { border-color: var(--green); } .dice.d-green i.pip { background: var(--green); }
.dice.d-yellow { border-color: #c99600; } .dice.d-yellow i.pip { background: #c99600; }
.dice.d-blue { border-color: var(--blue); } .dice.d-blue i.pip { background: var(--blue); }
.dice.shake { animation: shake .45s; }
@keyframes shake { 20% { transform: rotate(-18deg) scale(1.05); } 45% { transform: rotate(14deg); } 70% { transform: rotate(-8deg); } 100% { transform: none; } }

.players { list-style: none; margin: 0; padding: .6rem; display: grid; gap: .3rem; }
.pl { display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; padding: .45rem .6rem; border-radius: 10px; }
.pl.current { background: #f1f3f7; box-shadow: inset 4px 0 0 var(--ink); }
.pl.gone { opacity: .5; }
.pl-name { font-weight: 700; line-height: 1.2; }
.pl-name small { display: block; font-weight: 500; color: var(--muted); }
.pl-name em, .w-players em, .results-list em { font-style: normal; color: var(--muted); font-weight: 500; }
.chip { width: 20px; height: 20px; border-radius: 50%; display: inline-block; flex: none; box-shadow: inset 0 0 0 3px rgba(255,255,255,.5); }
.c-red { background: var(--red); } .c-green { background: var(--green); } .c-yellow { background: var(--yellow); } .c-blue { background: var(--blue); } .c-wait { background: var(--ink); }
.net { font-size: .75rem; font-weight: 700; }
.net.on { color: var(--green); } .net.off { color: var(--muted); }

.log-panel h2 { font-size: 1rem; }
.log { margin: 0; padding: 0 0 0 1.1rem; font-size: .9rem; color: var(--muted); max-height: 210px; overflow-y: auto; }
.log li:first-child { color: var(--ink); font-weight: 600; }

.results { position: fixed; inset: 0; background: rgba(10, 18, 34, .7); display: grid; place-items: center; padding: 1rem; z-index: 20; }
.results-card { width: min(420px, 100%); text-align: center; }
.results-card h2 { font-size: 2rem; }
.results-list { text-align: left; display: grid; gap: .4rem; margin: 1rem 0 1.4rem; padding-left: 1.6rem; font-weight: 700; font-size: 1.1rem; }
.results-list li { padding-left: .3rem; }
.results-list .chip { width: 14px; height: 14px; margin-right: .5rem; vertical-align: -1px; }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1.2rem; border-radius: 999px; font-weight: 600; z-index: 30; }

/* ---------- Admin ---------- */
.page-admin h1 { font-size: 1.5rem; }
.admin-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1rem; }
.stats div { background: rgba(255,255,255,.08); color: #fff; border-radius: 12px; padding: .7rem 1rem; }
.stats b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stats span { font-size: .85rem; color: #b9c4d8; }
@media (max-width: 600px) { .stats { grid-template-columns: 1fr 1fr; } }
.filters { display: flex; gap: .6rem; margin-bottom: .8rem; }
.filters input { flex: 1; }
.filters select { width: auto; }
.table-scroll { overflow-x: auto; background: var(--paper); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data th { text-align: left; font-size: .85rem; color: var(--muted); font-weight: 700; padding: .7rem 1rem; border-bottom: 2px solid var(--line); }
.data td { padding: .6rem 1rem; border-bottom: 1px solid #eceef2; vertical-align: middle; }
.badge { display: inline-block; padding: .05rem .6rem; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.badge-on { background: var(--green-l); color: #0c5229; }
.badge-soon { background: var(--yellow-l); color: #7a5a00; }
.badge-off { background: var(--red-l); color: #7d1020; }
.narrow { max-width: 520px; margin: 0 auto; }

@media (prefers-reduced-motion: reduce) {
  .token, .token.movable, .dice.shake { animation: none; transition: none; }
}