/* Ludo Standalone — emerald 3D theme. Vanilla CSS, no build step. */
:root{
  --emerald-950:#04150e; --emerald-900:#06231a; --emerald-800:#0a3527;
  --emerald-700:#0e4d38; --emerald-600:#12805a; --emerald-500:#17a374;
  --mint:#d9f7e8; --mint-2:#b8ecd2; --surface:#f4fbf7; --card:#ffffff;
  --ink:#0d2b1f; --muted:#5b7a6c; --gold:#f0b90b; --gold-soft:#f8d33a;
  --red:#e5484d; --green:#22a06b; --yellow:#f5b301; --blue:#2f7de1;
  --danger:#d92d20; --radius:18px;
  --shadow:0 10px 30px rgba(4,21,14,.28);
  --shadow-sm:0 4px 14px rgba(4,21,14,.18);
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  background:radial-gradient(1200px 600px at 50% -10%,#0e4d38 0%,var(--emerald-950) 60%);
  color:var(--ink); min-height:100vh;
}
button{font:inherit;cursor:pointer;border:none;background:none;color:inherit}
input,select,textarea{font:inherit;padding:11px 12px;border:1.5px solid #cfe4d8;border-radius:12px;width:100%;background:#fff;color:var(--ink)}
input:focus,select:focus,textarea:focus{outline:2px solid var(--emerald-500);border-color:var(--emerald-500)}
a{color:var(--emerald-600)}
.hidden{display:none!important}
.muted{color:var(--muted);font-size:13px}
.small{font-size:12px}
.center{text-align:center}
.mt{margin-top:12px}.mt2{margin-top:20px}.mb{margin-bottom:12px}

/* ---------- App shell ---------- */
#app{max-width:480px;margin:0 auto;min-height:100vh;display:flex;flex-direction:column;background:var(--surface);box-shadow:0 0 60px rgba(0,0,0,.5)}
@media(min-width:560px){#app{border-left:1px solid #123f2f;border-right:1px solid #123f2f}}
.topbar{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:linear-gradient(135deg,var(--emerald-800),var(--emerald-900));color:#fff;position:sticky;top:0;z-index:20}
.topbar .logo{font-weight:800;font-size:20px;letter-spacing:.5px}
.topbar .logo span{color:var(--gold-soft)}
.topbar .wallet-chip{background:rgba(240,185,11,.18);border:1px solid var(--gold);color:var(--gold-soft);padding:6px 12px;border-radius:999px;font-weight:700;font-size:14px}
.screen{padding:16px 16px 96px;flex:1}
h1{font-size:22px;margin-bottom:4px}
h2{font-size:18px;margin:16px 0 8px}
h3{font-size:15px;margin:12px 0 6px}
.screen p.sub{color:var(--muted);font-size:14px;margin-bottom:14px}

/* ---------- Bottom nav ---------- */
.bottomnav{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:100%;max-width:480px;display:flex;background:#fff;border-top:1px solid #dfeee6;z-index:30;padding-bottom:env(safe-area-inset-bottom)}
.bottomnav button{flex:1;padding:10px 2px 9px;font-size:11px;color:var(--muted);display:flex;flex-direction:column;align-items:center;gap:2px}
.bottomnav button .ic{font-size:20px;line-height:1}
.bottomnav button.active{color:var(--emerald-600);font-weight:700}
.bottomnav button .badge{min-width:17px;height:17px;border-radius:9px;background:var(--red);color:#fff;font-size:10px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;padding:0 4px}

/* ---------- Cards / buttons ---------- */
.card{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:16px;margin-bottom:12px;border:1px solid #e3f1e9}
.card h3{margin-top:0}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;width:100%;padding:13px 16px;border-radius:14px;font-weight:700;font-size:15px;background:linear-gradient(180deg,var(--emerald-500),var(--emerald-600));color:#fff;box-shadow:0 6px 16px rgba(18,128,90,.35);transition:transform .08s}
.btn:active{transform:scale(.98)}
.btn.gold{background:linear-gradient(180deg,var(--gold-soft),var(--gold));color:#3a2b00;box-shadow:0 6px 16px rgba(240,185,11,.35)}
.btn.ghost{background:#eef7f2;color:var(--emerald-700);box-shadow:none;border:1.5px solid #cfe4d8}
.btn.danger{background:linear-gradient(180deg,#f97066,#d92d20);box-shadow:0 6px 16px rgba(217,45,32,.3)}
.btn.sm{width:auto;padding:9px 14px;font-size:13px;border-radius:11px}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btnrow{display:flex;gap:10px}
.btnrow .btn{flex:1}
.grid3{display:grid;grid-template-columns:1fr;gap:12px}
.home-card{position:relative;overflow:hidden;border-radius:20px;padding:20px;color:#fff;box-shadow:var(--shadow);text-align:left;width:100%;min-height:104px;display:flex;flex-direction:column;justify-content:center;gap:4px}
.home-card .t{font-size:20px;font-weight:800}
.home-card .d{font-size:13px;opacity:.92}
.home-card .go{position:absolute;right:16px;top:50%;transform:translateY(-50%);font-size:26px;opacity:.9}
.home-card.offline{background:linear-gradient(135deg,#0e9f6e,#065f46)}
.home-card.online{background:linear-gradient(135deg,#0ea5a5,#0b5e5e)}
.home-card.tourney{background:linear-gradient(135deg,#f0b90b,#b8860b);color:#241a00}
.home-card.tourney .d{opacity:.85}
.home-card.live{background:linear-gradient(135deg,#123f2f,#06231a);border:1px solid var(--gold)}
.live-dot{display:inline-block;width:9px;height:9px;border-radius:50%;background:#ff5a5a;box-shadow:0 0 0 0 rgba(255,90,90,.7);animation:pulse 1.6s infinite;margin-right:6px}
@keyframes pulse{70%{box-shadow:0 0 0 8px rgba(255,90,90,0)}100%{box-shadow:0 0 0 0 rgba(255,90,90,0)}}
.pill{display:inline-block;padding:3px 10px;border-radius:999px;font-size:12px;font-weight:700}
.pill.gold{background:#fff3c4;color:#7a5b00}.pill.green{background:#d9f7e8;color:#065f46}
.pill.grey{background:#eef2f0;color:#5b7a6c}.pill.red{background:#fee4e2;color:#b42318}
.pill.blue{background:#e0eaff;color:#1849a9}
.notice{background:#fff8e1;border:1.5px dashed #e8b400;border-radius:14px;padding:13px 14px;font-size:13.5px;color:#6d4c00;margin-bottom:12px}
.notice b{color:#4a3200}
.err{background:#fee4e2;color:#b42318;border-radius:12px;padding:10px 12px;font-size:13.5px;margin:10px 0}
.ok{background:#d9f7e8;color:#065f46;border-radius:12px;padding:10px 12px;font-size:13.5px;margin:10px 0}
.testing-box{border:2px dashed var(--gold);background:#fffbe6;border-radius:14px;padding:14px;margin:12px 0;text-align:center}
.testing-box .code{font-size:30px;font-weight:800;letter-spacing:8px;color:#7a5b00}
.tabs{display:flex;gap:8px;margin:12px 0;overflow-x:auto}
.tabs button{padding:9px 16px;border-radius:999px;background:#e6f2ec;font-weight:700;font-size:13.5px;white-space:nowrap;color:var(--emerald-800)}
.tabs button.active{background:var(--emerald-700);color:#fff}
.list-row{display:flex;align-items:center;gap:12px;padding:12px 4px;border-bottom:1px solid #eef4f0}
.list-row:last-child{border-bottom:none}
.avatar{width:44px;height:44px;border-radius:50%;background:linear-gradient(135deg,var(--emerald-500),var(--emerald-800));color:#fff;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:18px;flex:none;overflow:hidden}
.avatar img{width:100%;height:100%;object-fit:cover}
.avatar.lg{width:84px;height:84px;font-size:34px}
.row-between{display:flex;align-items:center;justify-content:space-between;gap:10px}
.progress{height:9px;background:#e3efe8;border-radius:6px;overflow:hidden}
.progress>i{display:block;height:100%;background:linear-gradient(90deg,var(--gold-soft),var(--gold));border-radius:6px}
.level-row{padding:12px 0;border-bottom:1px solid #eef4f0}
.level-row:last-child{border-bottom:none}
.switch{position:relative;width:48px;height:28px;flex:none}
.switch input{opacity:0;width:0;height:0}
.switch .sl{position:absolute;inset:0;background:#cfd8d3;border-radius:999px;transition:.2s}
.switch .sl:before{content:"";position:absolute;width:22px;height:22px;left:3px;top:3px;background:#fff;border-radius:50%;box-shadow:0 2px 5px rgba(0,0,0,.25);transition:.2s}
.switch input:checked + .sl{background:var(--emerald-500)}
.switch input:checked + .sl:before{transform:translateX(20px)}

/* ---------- Ludo board ---------- */
.game-wrap{display:flex;flex-direction:column;gap:10px}
.plates{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.plate{display:flex;align-items:center;gap:8px;background:#fff;border-radius:14px;padding:8px 10px;border:2px solid transparent;box-shadow:var(--shadow-sm)}
.plate.active{border-color:var(--gold);box-shadow:0 0 0 3px rgba(240,185,11,.35),var(--shadow-sm)}
.plate .dot{width:14px;height:14px;border-radius:50%;flex:none;box-shadow:inset -2px -3px 4px rgba(0,0,0,.3),0 2px 4px rgba(0,0,0,.25)}
.plate .nm{font-weight:700;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.plate .st{font-size:11px;color:var(--muted)}
.plate .dice-slot{margin-left:auto;width:44px;height:44px;flex:none;display:flex;align-items:center;justify-content:center}
.dice{width:44px;height:44px;border-radius:11px;background:linear-gradient(145deg,#fff,#e8e8e8);box-shadow:0 4px 0 #b9b9b9,0 8px 14px rgba(0,0,0,.3);display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);padding:6px;cursor:pointer}
.dice.rolling{animation:shake .5s}
@keyframes shake{0%,100%{transform:rotate(0)}25%{transform:rotate(-14deg) translateY(-2px)}75%{transform:rotate(12deg) translateY(2px)}}
.dice .pip{width:8px;height:8px;border-radius:50%;background:#1c1c1c;place-self:center}
.dice.idle{opacity:.55;cursor:default;box-shadow:0 3px 0 #b9b9b9,0 5px 9px rgba(0,0,0,.2)}
.board-frame{background:linear-gradient(160deg,#0e4d38,#06231a);border-radius:22px;padding:10px;box-shadow:var(--shadow)}
.board{position:relative;width:100%;aspect-ratio:1/1;border-radius:10px;overflow:hidden;background:#fdfdf6;display:grid;grid-template-columns:repeat(15,1fr);grid-template-rows:repeat(15,1fr)}
.cell{border:1px solid rgba(0,0,0,.08);position:relative;display:flex;align-items:center;justify-content:center;font-size:10px}
.cell.c-red{background:var(--red)}.cell.c-green{background:var(--green)}
.cell.c-yellow{background:var(--yellow)}.cell.c-blue{background:var(--blue)}
.cell.safe::after{content:"★";color:rgba(0,0,0,.35);font-size:11px}
.cell.yard-red{background:#fdecec}.cell.yard-green{background:#e9f7f0}
.cell.yard-yellow{background:#fff8e1}.cell.yard-blue{background:#e9f1fd}
.cell.center-cell{background:conic-gradient(from 45deg,var(--green) 0 25%,var(--yellow) 0 50%,var(--blue) 0 75%,var(--red) 0 100%)}
.token{position:absolute;width:6.4%;aspect-ratio:1/1;border-radius:50% 50% 50% 50%/60% 60% 40% 40%;transform:translate(-50%,-58%);z-index:5;cursor:pointer;transition:left .22s ease,top .22s ease;box-shadow:inset -2px -4px 5px rgba(0,0,0,.35),inset 2px 3px 4px rgba(255,255,255,.55),0 3px 5px rgba(0,0,0,.45)}
.token::after{content:"";position:absolute;left:50%;top:-38%;width:34%;height:38%;background:inherit;border-radius:50%;transform:translateX(-50%);box-shadow:inset -1px -2px 3px rgba(0,0,0,.3),inset 1px 2px 2px rgba(255,255,255,.5)}
.token.movable{animation:bob 1s infinite;outline:3px solid var(--gold);z-index:8}
@keyframes bob{50%{transform:translate(-50%,-78%)}}
.token.t-red{background:radial-gradient(circle at 35% 30%,#ff8a8a,#e5484d 60%,#a81e22)}
.token.t-green{background:radial-gradient(circle at 35% 30%,#7fe0ae,#22a06b 60%,#14663f)}
.token.t-yellow{background:radial-gradient(circle at 35% 30%,#ffe27a,#f5b301 60%,#a97a00)}
.token.t-blue{background:radial-gradient(circle at 35% 30%,#8db9f5,#2f7de1 60%,#174a94)}
.game-msg{text-align:center;font-weight:700;color:var(--emerald-800);min-height:22px;font-size:14.5px}
.turn-banner{text-align:center;font-size:13px;color:var(--muted)}

/* ---------- Chat ---------- */
.chat-box{background:#fff;border-radius:16px;border:1px solid #e3f1e9;height:340px;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:8px}
.msg{max-width:78%;padding:9px 12px;border-radius:14px;font-size:14px;line-height:1.4}
.msg.me{align-self:flex-end;background:var(--emerald-600);color:#fff;border-bottom-right-radius:4px}
.msg.them{align-self:flex-start;background:#eef7f2;border-bottom-left-radius:4px}
.msg img{max-width:100%;border-radius:10px}
.chat-input{display:flex;gap:8px;margin-top:10px}
.chat-input input{flex:1}
.icon-btn{width:46px;height:46px;border-radius:12px;background:#eef7f2;display:flex;align-items:center;justify-content:center;font-size:19px;flex:none}

/* ---------- Modal / popup ---------- */
.modal-back{position:fixed;inset:0;background:rgba(4,21,14,.65);z-index:60;display:flex;align-items:center;justify-content:center;padding:20px}
.modal{background:#fff;border-radius:20px;padding:22px;max-width:400px;width:100%;box-shadow:var(--shadow);max-height:88vh;overflow-y:auto}
.modal h2{margin-top:0}
table{width:100%;border-collapse:collapse;font-size:13.5px}
td,th{padding:8px 6px;border-bottom:1px solid #eef4f0;text-align:left}
th{color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.4px}
.stat-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;margin:12px 0}
.stat{background:#eef7f2;border-radius:14px;padding:12px 6px;text-align:center}
.stat b{display:block;font-size:19px;color:var(--emerald-800)}
.stat span{font-size:11.5px;color:var(--muted)}
.toast{position:fixed;left:50%;bottom:84px;transform:translateX(-50%);background:#0d2b1f;color:#fff;padding:11px 18px;border-radius:999px;font-size:14px;z-index:80;box-shadow:var(--shadow);white-space:nowrap}
