/* Kilalao'Ntsaina.mg — styles. Vert profond + or, clair / sombre, mode Lite. */
:root {
  --green: #145c3c; --green-2: #1f7a4d; --gold: #d4a017; --gold-2: #f2c94c; --red: #c0392b;
  --bg: #f7f3ea; --bg-2: #efe8d8; --card: #ffffff; --ink: #1d2420; --ink-2: #5d675f; --line: #e2dccd;
  --board-light: #eed9b0; --board-dark: #a8794f; --hl: rgba(212, 160, 23, .45); --move: rgba(20, 92, 60, .35);
  --radius: 14px; --shadow: 0 2px 10px rgba(0, 0, 0, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #121614; --bg-2: #1a201d; --card: #1e2522; --ink: #ecf0ed; --ink-2: #9aa79f; --line: #2d3732;
  --board-light: #c3d1c6; --board-dark: #6e8f7a; --hl: rgba(242, 201, 76, .45); --move: rgba(242, 201, 76, .35);
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent; }
a { color: var(--green-2); }
[data-theme="dark"] a { color: var(--gold-2); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: linear-gradient(90deg, var(--green), var(--green-2)); color: #fff; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: #fff; text-decoration: none; }
.brand .logo { width: 30px; height: 30px; }
.brand small { color: var(--gold-2); font-weight: 600; }
.topbar .spacer { flex: 1; }
.iconbtn { position: relative; width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(255,255,255,.12);
  color: #fff; display: grid; place-items: center; cursor: pointer; font-size: 20px; }
.iconbtn:hover { background: rgba(255,255,255,.22); }
.badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.net { display: flex; gap: 2px; align-items: flex-end; height: 16px; margin-right: 2px; }
.net i { width: 4px; background: rgba(255,255,255,.35); border-radius: 1px; }
.net i:nth-child(1) { height: 5px; } .net i:nth-child(2) { height: 10px; } .net i:nth-child(3) { height: 15px; }
.net.good i { background: #7ee2a8; } .net.mid i:nth-child(-n+2) { background: var(--gold-2); } .net.bad i:nth-child(1) { background: #ff8a7a; }
.offline-bar { background: var(--red); color: #fff; text-align: center; font-size: 14px; padding: 4px; }

/* bouton thème soleil / lune */
.theme-toggle .sun, .theme-toggle .moon { transition: transform .4s, opacity .4s; position: absolute; }
[data-theme="dark"] .theme-toggle .sun { transform: rotate(90deg) scale(0); opacity: 0; }
[data-theme="light"] .theme-toggle .moon, :root:not([data-theme]) .theme-toggle .moon { transform: rotate(-90deg) scale(0); opacity: 0; }

/* ---------- mise en page ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 16px 14px 90px; }
.grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid.dash { grid-template-columns: 2fr 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin: 0 0 12px; font-size: 17px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
.muted { color: var(--ink-2); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* ---------- boutons et champs ---------- */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; min-height: 48px; font-weight: 600; cursor: pointer;
  background: var(--bg-2); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--green-2); color: #fff; }
.btn.gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #2b2100; }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.big { font-size: 19px; min-height: 60px; border-radius: 16px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 46px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 1px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; min-height: 20px; margin-top: 2px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 12px; min-height: 40px; cursor: pointer; }
.seg button.on { background: var(--green-2); color: #fff; border-color: var(--green-2); }
.error { color: var(--red); font-size: 14px; min-height: 1em; }

/* ---------- accueil / auth ---------- */
.hero { text-align: center; padding: 28px 10px 10px; }
.hero h1 { font-size: 28px; margin-bottom: 6px; }
.hero p { color: var(--ink-2); max-width: 520px; margin: 0 auto 18px; }
.auth { max-width: 420px; margin: 0 auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; padding: 10px; border-radius: 10px; background: var(--bg-2); cursor: pointer; font-weight: 600; }
.tabs button.on { background: var(--green-2); color: #fff; }

/* ---------- jeux ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.game-tile { border-radius: var(--radius); padding: 14px; background: var(--card); border: 1px solid var(--line); cursor: pointer;
  text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.game-tile .ico { font-size: 34px; line-height: 1; }
.game-tile b { font-size: 16px; }
.game-tile.soon { opacity: .6; cursor: default; }
.game-tile.live { border-color: var(--green-2); box-shadow: 0 0 0 2px rgba(31, 122, 77, .15); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg-2); color: var(--ink-2); }
.pill.green { background: rgba(31, 122, 77, .15); color: var(--green-2); }
.pill.gold { background: rgba(212, 160, 23, .2); color: #8a6500; }
[data-theme="dark"] .pill.gold { color: var(--gold-2); }

/* ---------- listes de joueurs ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; position: relative; }
.avatar.big { width: 84px; height: 84px; font-size: 32px; }
.avatar.online::after { content: ""; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%;
  background: #2ecc71; border: 2px solid var(--card); }

/* ---------- échiquier ---------- */
.game-layout { display: grid; gap: 14px; }
@media (min-width: 900px) { .game-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.board-wrap { width: min(100%, calc(100vh - 230px), 640px); margin: 0 auto; }
@media (min-width: 900px) { .board-wrap { width: min(100%, calc(100vh - 300px), 620px); } }
.player-bar { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }
.player-bar .grow { flex: 1; min-width: 0; }
.clock { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; padding: 6px 12px; border-radius: 10px;
  background: var(--bg-2); min-width: 92px; text-align: center; }
.clock.run { background: var(--green-2); color: #fff; }
.clock.low { background: var(--red); color: #fff; }
.board { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; border-radius: 8px;
  overflow: hidden; user-select: none; touch-action: none; box-shadow: var(--shadow); }
.sq { position: relative; display: grid; place-items: center; }
.sq.l { background: var(--board-light); } .sq.d { background: var(--board-dark); }
.sq.last { box-shadow: inset 0 0 0 100px var(--hl); }
.sq.sel { box-shadow: inset 0 0 0 100px var(--move); }
.sq.check { background: radial-gradient(circle, #ff4d4d 0%, rgba(255, 77, 77, .6) 40%, transparent 75%); }
.sq.dot::after { content: ""; width: 30%; height: 30%; border-radius: 50%; background: rgba(0, 0, 0, .25); }
.sq.cap::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(0, 0, 0, .25); }
.sq .coord { position: absolute; font-size: 10px; font-weight: 700; opacity: .7; pointer-events: none; }
.sq .coord.f { right: 3px; bottom: 1px; } .sq .coord.r { left: 3px; top: 1px; }
.sq.l .coord { color: var(--board-dark); } .sq.d .coord { color: var(--board-light); }
.pc { font-size: min(10.5vw, 70px); line-height: 1; cursor: grab; pointer-events: none;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", "Arial Unicode MS", sans-serif; }
.pc.w { color: #fff; -webkit-text-stroke: 1.5px #222; paint-order: stroke fill; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.pc.b { color: #151515; -webkit-text-stroke: .6px #000; text-shadow: 0 1px 0 rgba(255,255,255,.15); }
.drag { position: fixed; z-index: 50; pointer-events: none; transform: translate(-50%, -50%) scale(1.15); }
.promo { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); z-index: 5; }
.promo div { display: flex; gap: 6px; background: var(--card); padding: 10px; border-radius: 12px; }
.promo button { font-size: 44px; width: 64px; height: 64px; border: 0; border-radius: 10px; background: var(--bg-2); cursor: pointer; }
.moves { max-height: 260px; overflow: auto; display: grid; grid-template-columns: 34px 1fr 1fr; gap: 2px 6px; font-variant-numeric: tabular-nums; }
.moves span { padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.moves span.n { color: var(--ink-2); cursor: default; }
.moves span.cur { background: var(--hl); }
.result-banner { text-align: center; padding: 14px; border-radius: var(--radius); background: var(--bg-2); }
.result-banner b { font-size: 20px; display: block; }
.chat { max-height: 180px; overflow: auto; font-size: 14px; }
.chat p { margin: 4px 0; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- messagerie ---------- */
.thread { height: 52vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding: 6px 2px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; background: var(--bg-2); align-self: flex-start; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--green-2); color: #fff; }
.bubble small { display: block; font-size: 11px; opacity: .7; }

/* ---------- mur ---------- */
.post { border-top: 1px solid var(--line); padding: 12px 0; }
.post:first-child { border-top: 0; }
.post .body { white-space: pre-wrap; margin: 6px 0; word-wrap: break-word; }
.post .actions { display: flex; gap: 8px; }
.linkbtn { border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 4px 6px; border-radius: 8px; font-size: 14px; }
.linkbtn:hover { background: var(--bg-2); }
.linkbtn.on { color: var(--red); }

/* ---------- notifications ---------- */
.panel { position: fixed; top: 58px; right: 8px; width: min(380px, calc(100vw - 16px)); max-height: 70vh; overflow: auto; z-index: 40; }
.notif { display: flex; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer; }
.notif:hover { background: var(--bg-2); }
.notif.unread { background: rgba(212, 160, 23, .12); }
.notif .ico { font-size: 22px; }
.toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px;
  width: min(460px, calc(100vw - 20px)); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  display: flex; gap: 10px; align-items: center; animation: up .25s ease-out; }
.toast.critical { background: var(--red); color: #fff; }
.toast .grow { flex: 1; }
.toast button { background: rgba(255,255,255,.18); color: inherit; border: 0; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; }
@keyframes up { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- barre d'onglets mobile ---------- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 6px; color: var(--ink-2); text-decoration: none; font-size: 12px; position: relative; }
.tabbar a span { display: block; font-size: 22px; line-height: 1.1; }
.tabbar a.on { color: var(--green-2); font-weight: 700; }
[data-theme="dark"] .tabbar a.on { color: var(--gold-2); }
.tabbar .badge { top: 2px; right: calc(50% - 22px); }
@media (min-width: 900px) { .tabbar { left: 50%; transform: translateX(-50%); width: 560px; bottom: 12px; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow); } }

/* ---------- fenêtres ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 70; display: grid; place-items: center; padding: 14px; }
.modal { background: var(--card); border-radius: 18px; padding: 20px; width: min(440px, 100%); max-height: 90vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.banner { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--gold); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.banner .grow { flex: 1; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--green-2); border-radius: 50%; animation: rot 1s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.seeking { text-align: center; padding: 20px; }
.seeking .pulse { font-size: 54px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); opacity: .7; } }

/* ---------- saison (décor léger, désactivé en Lite) ---------- */
.season-rain .topbar::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .25;
  background-image: linear-gradient(105deg, transparent 47%, #fff 48%, transparent 49%); background-size: 22px 22px; animation: rain .8s linear infinite; }
@keyframes rain { to { background-position: -6px 22px; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti i { position: absolute; top: -10px; width: 8px; height: 12px; animation: fall 2.2s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }

/* ---------- mode Lite : zéro animation, zéro décor ---------- */
[data-lite="1"] *, [data-lite="1"] *::before, [data-lite="1"] *::after { animation: none !important; transition: none !important; }
[data-lite="1"] .topbar { background: var(--green); }
[data-lite="1"] .season-rain .topbar::after, [data-lite="1"] .confetti { display: none; }
[data-lite="1"] .card, [data-lite="1"] .board { box-shadow: none; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
