/* TechFace.NET Game section (hub, lobby, Ludo board, global invite pop-up). Light + dark, mobile first. */
:root { --ld-red: #e53935; --ld-green: #2e9d4f; --ld-yellow: #f4c20d; --ld-blue: #1e7ce5; --ld-board: #fff; --ld-line: #cbd5e1; --ld-yard: #fff; }
html.dark { --ld-board: #182238; --ld-line: #33415c; --ld-yard: #0f172a; }

/* ---------- hub ---------- */
.ld-hub { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .ld-hub { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; } }
.ld-game-card { display: flex; flex-direction: column; gap: .8rem; }
.ld-game-art { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; box-shadow: inset 0 0 0 1px rgba(0,0,0,.05); }
.ld-game-art span:nth-child(1) { background: var(--ld-red); } .ld-game-art span:nth-child(2) { background: var(--ld-green); }
.ld-game-art span:nth-child(3) { background: var(--ld-blue); } .ld-game-art span:nth-child(4) { background: var(--ld-yellow); }
.ld-game-art i { position: absolute; inset: 0; margin: auto; width: 84px; height: 84px; border-radius: 22px; background: #fff; color: #0f172a;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 12px 30px rgba(0,0,0,.25); transform: rotate(-8deg); }
.ld-game-info .tf4-h2 { display: flex; align-items: center; gap: .5rem; }
.ld-soon { display: flex; align-items: center; gap: .35rem; border-top: 1px dashed var(--tf-line); padding-top: .7rem; }
.ld-picker { display: flex; flex-direction: column; gap: .7rem; }
.ld-picker .tf4-h2 { display: flex; align-items: center; gap: .45rem; margin-bottom: 0; }
.ld-search { position: relative; display: block; color: var(--tf-muted); }
.ld-search svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); }
.ld-search .tf4-input { padding-left: 2.3rem; border-radius: 999px; background: var(--tf-soft); }
.ld-selected { display: flex; flex-wrap: wrap; gap: .35rem; }
.ld-selected .ld-av { margin-right: .1rem; }
.ld-people { display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow-y: auto; margin: 0 -.4rem; padding: 0 .4rem; }
.ld-sect { padding: .5rem .2rem .25rem; }
.ld-person { display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left; padding: .5rem .55rem; border-radius: 12px; border: 1px solid transparent; min-height: 56px; }
.ld-person:hover { background: var(--tf-hover); }
.ld-person b { display: block; font-size: .95rem; }
.ld-person small { display: block; font-size: .78rem; }
.ld-person.is-picked { background: rgba(24, 119, 242, .08); border-color: rgba(24, 119, 242, .35); }
.ld-check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--tf-line); display: inline-flex; align-items: center; justify-content: center; color: transparent; flex: none; }
.ld-person.is-picked .ld-check { background: var(--tf-blue); border-color: var(--tf-blue); color: #fff; }
.ld-av { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; background: #664356; color: #fff; font-weight: 800; flex: none; vertical-align: middle; }
.ld-av img { width: 100%; height: 100%; object-fit: cover; }
.ld-mini-ico { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--tf-soft); color: var(--tf-blue); flex: none; }
.ld-mini-ico.is-win { background: rgba(245, 158, 11, .16); color: #d97706; }
.ld-hist-players { display: flex; flex-wrap: wrap; gap: .3rem .8rem; margin-top: .2rem; font-size: .8rem; color: var(--tf-muted); }
.ld-hist-p { display: inline-flex; align-items: center; gap: .3rem; }
.ld-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.ld-dot.ld-red { background: var(--ld-red); } .ld-dot.ld-green { background: var(--ld-green); } .ld-dot.ld-yellow { background: var(--ld-yellow); } .ld-dot.ld-blue { background: var(--ld-blue); }
.ld-invite-card { text-align: center; padding: 2rem 1rem; }
.ld-invite-ico { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto .8rem; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--tf-grad); box-shadow: 0 10px 26px rgba(24, 119, 242, .35); }

/* ---------- room ---------- */
.ld-room { width: 100%; max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: .7rem; }
.ld-topbar { display: flex; align-items: center; gap: .5rem; justify-content: space-between; }
.ld-title { display: inline-flex; align-items: center; gap: .35rem; font-weight: 900; font-size: 1.05rem; }
.ld-main { min-width: 0; }

/* lobby */
.ld-lobby { max-width: 760px; margin: 0 auto; width: 100%; }
.ld-seats { display: grid; gap: .6rem; grid-template-columns: 1fr; margin: .9rem 0; }
@media (min-width: 560px) { .ld-seats { grid-template-columns: 1fr 1fr; } }
.ld-seat { display: flex; align-items: center; gap: .75rem; padding: .75rem; border-radius: 14px; border: 2px solid var(--tf-line); background: var(--tf-card); min-width: 0; position: relative; }
.ld-seat::before { content: ''; position: absolute; left: -2px; top: -2px; bottom: -2px; width: 7px; border-radius: 14px 0 0 14px; }
.ld-seat-red::before { background: var(--ld-red); } .ld-seat-green::before { background: var(--ld-green); }
.ld-seat-yellow::before { background: var(--ld-yellow); } .ld-seat-blue::before { background: var(--ld-blue); }
.ld-seat b { display: block; margin-bottom: .2rem; }
.ld-seat.is-empty { border-style: dashed; }
.ld-seat-empty { width: 48px; height: 48px; border-radius: 50%; border: 2px dashed var(--tf-line); display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--tf-muted); flex: none; }
.ld-lobby-actions { margin-top: .5rem; }

/* game layout */
.ld-game { display: grid; gap: .7rem; grid-template-columns: minmax(0, 1fr); grid-template-areas: "players" "board" "side"; }
@media (min-width: 1000px) { .ld-game { grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "board players" "board side"; grid-template-rows: auto 1fr; align-items: start; } }
.ld-players { grid-area: players; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
@media (min-width: 1000px) { .ld-players { grid-template-columns: 1fr; } }
.ld-board-wrap { grid-area: board; position: relative; width: 100%; max-width: min(100%, calc(100dvh - 8.5rem)); margin: 0 auto; aspect-ratio: 1; }
@media (max-width: 999px) { .ld-board-wrap { max-width: min(100%, 640px); } }
.ld-side { grid-area: side; display: flex; flex-direction: column; gap: .7rem; min-width: 0; }

/* player chips */
.ld-pl { display: flex; align-items: center; gap: .55rem; padding: .45rem .55rem; border-radius: 14px; background: var(--tf-card); border: 2px solid var(--tf-line); min-width: 0; transition: border-color .2s, box-shadow .2s, transform .2s; }
.ld-pl b { display: block; font-size: .88rem; }
.ld-pl small { display: block; font-size: .72rem; color: var(--tf-muted); }
.ld-pl-red { --pc: var(--ld-red); } .ld-pl-green { --pc: var(--ld-green); } .ld-pl-yellow { --pc: var(--ld-yellow); } .ld-pl-blue { --pc: var(--ld-blue); }
.ld-pl { border-left: 6px solid var(--pc); }
.ld-pl.is-turn { border-color: var(--pc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 25%, transparent), var(--tf-shadow); transform: translateY(-1px); }
.ld-pl.is-left { opacity: .5; } .ld-pl.is-left b { text-decoration: line-through; }
.ld-ring { position: relative; flex: none; display: inline-flex; padding: 3px; border-radius: 50%; }
.ld-pl.is-turn .ld-ring { background: conic-gradient(var(--pc) var(--ld-pct, 100%), var(--tf-line) 0); }
.ld-pl.is-turn .ld-ring .ld-av { box-shadow: 0 0 0 2px var(--tf-card); }
.ld-pl.is-turn .ld-ring::after { content: attr(data-sec); position: absolute; right: -6px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--pc); color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.ld-pl.is-turn .ld-ring[data-sec=""]::after { display: none; }
.ld-ring .tf4-online-dot { right: 1px; bottom: 1px; }

/* board */
.ld-board { width: 100%; height: 100%; display: block; border-radius: 16px; box-shadow: var(--tf-shadow-lg); background: var(--ld-board); touch-action: manipulation; user-select: none; }
.ld-bg { fill: var(--ld-board); }
.ld-cell { fill: var(--ld-board); stroke: var(--ld-line); stroke-width: .035; }
.ld-yard { fill: var(--ld-yard); }
.ld-fill-red { fill: var(--ld-red); } .ld-fill-green { fill: var(--ld-green); } .ld-fill-yellow { fill: var(--ld-yellow); } .ld-fill-blue { fill: var(--ld-blue); }
.ld-cell.ld-fill-red { fill: var(--ld-red); } .ld-cell.ld-fill-green { fill: var(--ld-green); } .ld-cell.ld-fill-yellow { fill: var(--ld-yellow); } .ld-cell.ld-fill-blue { fill: var(--ld-blue); }
.ld-tri { stroke: rgba(255,255,255,.6); stroke-width: .03; }
.ld-spot { fill: none; stroke-width: .12; opacity: .55; }
.ld-stroke-red { stroke: var(--ld-red); } .ld-stroke-green { stroke: var(--ld-green); } .ld-stroke-yellow { stroke: var(--ld-yellow); } .ld-stroke-blue { stroke: var(--ld-blue); }
.ld-star { fill: #94a3b8; opacity: .75; }
html.dark .ld-star { fill: #64748b; }
.ld-start-dot { fill: rgba(255,255,255,.85); }
.ld-tk { transition: transform .14s ease-out; cursor: default; }
.ld-tk-shadow { fill: rgba(0,0,0,.28); }
.ld-tk-body { stroke: #fff; stroke-width: .07; }
.ld-tk-cap { fill: rgba(255,255,255,.4); }
.ld-tk-red .ld-tk-body { fill: var(--ld-red); } .ld-tk-green .ld-tk-body { fill: var(--ld-green); }
.ld-tk-yellow .ld-tk-body { fill: #e0ac00; } .ld-tk-blue .ld-tk-body { fill: var(--ld-blue); }
.ld-tk.is-movable { cursor: pointer; }
.ld-tk.is-movable .ld-tk-body { stroke: #111827; stroke-width: .09; animation: ld-pulse 1s ease-in-out infinite; }
html.dark .ld-tk.is-movable .ld-tk-body { stroke: #fff; }
.ld-tk.is-movable:focus { outline: none; }
.ld-tk.is-movable:focus .ld-tk-body { stroke-width: .14; }
.ld-tk.is-moving { transition-duration: .12s; }
@keyframes ld-pulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .ld-tk { transition: none; } .ld-tk.is-movable .ld-tk-body { animation: none; } }

/* dice + status */
.ld-control { display: flex; align-items: center; gap: .9rem; }
.ld-dice { width: 74px; height: 74px; flex: none; border-radius: 18px; background: #fff; border: 2px solid var(--tf-line); box-shadow: 0 6px 16px rgba(0,0,0,.15), inset 0 -4px 0 rgba(0,0,0,.06);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 12px; gap: 2px; transition: transform .15s; }
.ld-dice i { border-radius: 50%; background: transparent; margin: 2px; }
.ld-dice:disabled { cursor: default; }
.ld-dice.is-ready { border-color: var(--tf-blue); box-shadow: 0 0 0 4px rgba(24, 119, 242, .25), 0 8px 20px rgba(24, 119, 242, .3); animation: ld-bob 1.2s ease-in-out infinite; cursor: pointer; }
.ld-dice.is-rolling { animation: ld-roll .35s linear infinite; }
@keyframes ld-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes ld-roll { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(.92); } 100% { transform: rotate(360deg) scale(1); } }
/* pips: grid cells 1..9 (row-major) */
.ld-dice[data-v="1"] i:nth-child(5),
.ld-dice[data-v="2"] i:nth-child(1), .ld-dice[data-v="2"] i:nth-child(9),
.ld-dice[data-v="3"] i:nth-child(1), .ld-dice[data-v="3"] i:nth-child(5), .ld-dice[data-v="3"] i:nth-child(9),
.ld-dice[data-v="4"] i:nth-child(1), .ld-dice[data-v="4"] i:nth-child(3), .ld-dice[data-v="4"] i:nth-child(7), .ld-dice[data-v="4"] i:nth-child(9),
.ld-dice[data-v="5"] i:nth-child(1), .ld-dice[data-v="5"] i:nth-child(3), .ld-dice[data-v="5"] i:nth-child(5), .ld-dice[data-v="5"] i:nth-child(7), .ld-dice[data-v="5"] i:nth-child(9),
.ld-dice[data-v="6"] i:nth-child(1), .ld-dice[data-v="6"] i:nth-child(3), .ld-dice[data-v="6"] i:nth-child(4), .ld-dice[data-v="6"] i:nth-child(6), .ld-dice[data-v="6"] i:nth-child(7), .ld-dice[data-v="6"] i:nth-child(9) { background: #111827; }
.ld-dice[data-v="1"] i:nth-child(5) { background: #e53935; transform: scale(1.25); }
.ld-dice[data-v="0"]::after { content: '🎲'; grid-area: 1 / 1 / 4 / 4; display: flex; align-items: center; justify-content: center; font-size: 32px; }
.ld-status { font-weight: 800; font-size: 1rem; line-height: 1.3; min-width: 0; }
.ld-room.is-my-turn .ld-status { color: var(--tf-blue); }
.ld-log-card { padding: .8rem; }
.ld-log { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; max-height: 260px; overflow-y: auto; font-size: .82rem; }
.ld-ev { padding: .3rem .5rem; border-radius: 8px; background: var(--tf-soft); }
.ld-ev-move { background: transparent; }
.ld-ev-over, .ld-ev-finish { background: rgba(245, 158, 11, .15); font-weight: 700; }
@media (max-width: 999px) { .ld-log-card { display: none; } .ld-control { position: sticky; bottom: calc(4rem + env(safe-area-inset-bottom)); z-index: 5; } }

/* result overlay */
.ld-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: 16px; background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); animation: tf-fade .25s; padding: 1rem; }
.ld-result { background: var(--tf-card); color: var(--tf-text); border-radius: 18px; padding: 1.4rem 1.2rem; text-align: center; max-width: 340px; width: 100%; box-shadow: var(--tf-shadow-lg); animation: tf4-up .3s var(--tf-ease); }
.ld-trophy { font-size: 3rem; line-height: 1; margin-bottom: .4rem; }
.ld-result-title { font-size: 1.35rem; font-weight: 900; margin-bottom: .6rem; }
.ld-ranks { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .35rem; text-align: left; }
.ld-ranks li { display: flex; align-items: center; gap: .55rem; padding: .35rem .55rem; border-radius: 10px; background: var(--tf-soft); font-weight: 600; }
.ld-rank-n { font-weight: 900; width: 2rem; color: var(--tf-muted); }
.ld-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 120; overflow: hidden; }
.ld-confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: ld-fall 2.6s ease-in forwards; }
@keyframes ld-fall { to { transform: translateY(105vh) rotate(720deg); opacity: .7; } }

/* ---------- global invite pop-up ---------- */
.ldg-pops { position: fixed; z-index: 115; left: 50%; transform: translateX(-50%); top: 4.3rem; width: min(94vw, 24rem); display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
@media (min-width: 1024px) { .ldg-pops { left: auto; right: 1rem; transform: none; bottom: 1.2rem; top: auto; } }
.ldg-pop { pointer-events: auto; display: flex; gap: .75rem; align-items: flex-start; padding: .85rem; border-radius: 18px; background: var(--tf-card); color: var(--tf-text);
  border: 1px solid var(--tf-line); box-shadow: var(--tf-shadow-lg); animation: tf4-up .3s var(--tf-ease); transition: opacity .3s, transform .3s; border-top: 4px solid var(--ld-green); }
.ldg-pop.is-out { opacity: 0; transform: translateY(10px); }
.ldg-av { position: relative; width: 46px; height: 46px; border-radius: 50%; background: #664356; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.ldg-av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ldg-kind { position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.ldg-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; font-size: .9rem; }
.ldg-ttl { color: var(--tf-muted); font-variant-numeric: tabular-nums; }
.ldg-actions { display: flex; gap: .4rem; margin-top: .4rem; }
