@charset "UTF-8";
/* Табла Дончев */
:root {
  --bg: #1d0c06;
  --bg2: #2c140b;
  --card: rgba(255, 236, 200, 0.06);
  --card-b: rgba(240, 214, 160, 0.14);
  --text: #f7ebd3;
  --muted: #c9ad8a;
  --gold: #ebd29c;
  --gold-d: #b8955f;
  --red: #c2473a;
  --green: #6cc287;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 70% at 50% -10%, #5e2716 0%, transparent 62%),
    radial-gradient(90% 60% at 50% 110%, #43200f 0%, transparent 60%),
    repeating-linear-gradient(92deg, rgba(0,0,0,.05) 0 2px, transparent 2px 7px),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.screen { min-height: 100dvh; padding: calc(14px + var(--safe-t)) 16px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }

/* ---------- Brand ---------- */
.title { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: 40px; line-height: 1; margin: 0; letter-spacing: .5px; }
.title em { font-style: italic; color: var(--gold); }
.sub { margin: 6px 0 0; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; font-size: 12px; font-weight: 800; }
.hero { text-align: center; padding: 26px 0 6px; }
.logo { display: block; width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 20px; box-shadow: 0 10px 28px rgba(0,0,0,.55); }
.logo.small { width: 42px; height: 42px; margin: 0; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,.5); }

/* ---------- Cards, buttons ---------- */
.card { background: var(--card); border: 1px solid var(--card-b); border-radius: var(--radius); padding: 16px; }
.card h2 { margin: 0 0 14px; font-size: 18px; text-align: center; }
.card h3 { margin: 0 0 8px; font-size: 16px; color: var(--gold); }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 12px; line-height: 1.4; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 0 20px; border-radius: 14px; font-weight: 800; font-size: 18px; transition: transform .08s, opacity .2s, background .2s; user-select: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #f7e7c0, #dcc088 60%, #c9a56d); color: #3a170a; box-shadow: 0 6px 18px rgba(235,210,156,.25), inset 0 1px 0 rgba(255,255,255,.6), inset 0 -2px 0 rgba(120,80,30,.25); }
.btn.ghost { background: rgba(255,240,214,.08); border: 1px solid var(--card-b); }
.btn.danger { background: rgba(194,71,58,.18); border: 1px solid rgba(194,71,58,.5); color: #ffb3a8; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(240,207,134,.55); } 50% { box-shadow: 0 0 0 10px rgba(240,207,134,0); } }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: rgba(255,240,214,.07); border: 1px solid var(--card-b); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 11px 15px; border-radius: 999px; background: rgba(255,240,214,.08); border: 1px solid var(--card-b); font-weight: 700; font-size: 15px; }
.chip.on { background: var(--gold); color: #2a1708; border-color: var(--gold); }
.chip.other { box-shadow: 0 0 0 2px #7fb6ff inset; }
.chip.on.other { box-shadow: 0 0 0 3px #7fb6ff; }
.err { color: #ffb3a8; text-align: center; margin: 10px 0 0; }

/* ---------- Setup ---------- */
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px; border-radius: 16px; background: rgba(255,240,214,.07); border: 1px solid var(--card-b); }
.who-btn b { font-size: 20px; }
.who-btn small { color: var(--muted); }
.who-btn:active { transform: scale(.98); }
.ck { width: 34px; height: 34px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 2px 5px rgba(0,0,0,.5); }
.ck-0 { background: radial-gradient(circle at 50% 50%, #f3e4c4 0 26%, #c9ab78 28%, transparent 31%), radial-gradient(circle at 38% 30%, #fbf1dc, #ecd9b1 55%, #d2b685); border: 1px solid #a8895a; }
.ck-1 { background: radial-gradient(circle at 50% 50%, #3a2a20 0 26%, #0d0805 28%, transparent 31%), radial-gradient(circle at 38% 30%, #4d3a2e, #2c1f18 55%, #140d09); border: 1px solid #000; }
.code-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.code-row span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.code-row input { flex: 1; min-width: 0; height: 46px; border-radius: 12px; border: 1px solid var(--card-b); background: rgba(0,0,0,.25); color: var(--text); padding: 0 12px; font: inherit; font-size: 17px; letter-spacing: 1px; }

/* ---------- Lobby ---------- */
.lobby-head { display: flex; align-items: center; gap: 12px; }
.lobby-head .title { font-size: 30px; flex: 1; }
.players { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.vs { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; }
.pcard { background: var(--card); border: 1px solid var(--card-b); border-radius: var(--radius); padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-height: 128px; }
.pcard b { font-size: 18px; }
.pcard .you { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }
.presence { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #6b5a48; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(108,194,135,.2); }
.dot.bot { background: #7fb6ff; }
.scores { display: flex; flex-direction: column; gap: 12px; }
.score-line { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "lbl big" "meta meta"; align-items: center; row-gap: 2px; }
.score-line .lbl { grid-area: lbl; color: var(--muted); font-weight: 700; }
.score-line .big { grid-area: big; font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; }
.score-line .meta { grid-area: meta; color: var(--muted); font-size: 13px; }
.score-line.alltime { border-top: 1px solid var(--card-b); padding-top: 12px; }
.score-line.alltime .big { font-size: 24px; color: var(--gold); }
.lobby-actions { display: flex; flex-direction: column; gap: 10px; }
.lobby-actions .note { text-align: center; color: var(--muted); margin: 0; font-size: 15px; }
.links { display: flex; justify-content: center; gap: 10px; }
.link-btn { padding: 12px 16px; border-radius: 12px; background: rgba(255,240,214,.06); border: 1px solid var(--card-b); font-weight: 700; }
.conn { text-align: center; font-size: 12px; color: var(--muted); margin: 0; min-height: 16px; }
.conn.bad { color: #ffb3a8; }

/* ---------- Game ---------- */
.screen.game { padding: calc(8px + var(--safe-t)) 6px calc(10px + var(--safe-b)); gap: 6px; height: 100dvh; min-height: 0; overflow: hidden; }
.game-head { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; padding: 0 4px; }
.gtitle { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.gtitle span { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: 26px; color: var(--gold); }
.gtitle small { color: var(--muted); font-size: 12px; }
.gscore { min-width: 64px; padding: 6px 10px; border-radius: 12px; background: rgba(0,0,0,.25); border: 1px solid var(--card-b); text-align: center; font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.gscore small { display: block; font-size: 10px; color: var(--muted); font-weight: 700; letter-spacing: .5px; }
.strip { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 14px; background: rgba(255,240,214,.05); border: 1px solid transparent; transition: border-color .3s, background .3s; }
.strip .ck { width: 26px; height: 26px; }
.strip .name { font-weight: 800; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip .info { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.strip.turn { border-color: rgba(224,187,109,.65); background: rgba(224,187,109,.10); }
.strip .thinking::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--gold); animation: blink 1s infinite; vertical-align: middle; }
@keyframes blink { 50% { opacity: .2; } }
.board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board { width: 100%; height: auto; max-height: 100%; aspect-ratio: 429 / 388; border-radius: 8px; box-shadow: 0 10px 24px rgba(0,0,0,.55); touch-action: none; user-select: none; -webkit-user-select: none; }
.status { text-align: center; min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 0 8px; font-size: 16px; font-weight: 700; line-height: 1.25; }
.status .hint { color: var(--muted); font-weight: 600; }
.controls { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; padding: 0 6px; min-height: 58px; }
.controls .btn { width: 100%; }
.controls.single { grid-template-columns: 1fr; }

/* Board marks */
.board .count { font: 800 12px 'Nunito', sans-serif; text-anchor: middle; pointer-events: none; }
.board .count.on-light { fill: #6b4d2a; }
.board .count.on-dark { fill: #f3e8d2; }
.board .src-ring { fill: none; stroke: #ffe08a; stroke-width: 2.6; opacity: .95; animation: srcPulse 1.6s ease-in-out infinite; pointer-events: none; }
@keyframes srcPulse { 50% { opacity: .35; } }
.board .sel-ring { fill: rgba(255,224,138,.18); stroke: #ffe08a; stroke-width: 3; pointer-events: none; }
.board .dest { fill: rgba(120,240,150,.55); stroke: #b6ffc8; stroke-width: 3; pointer-events: none; animation: destPulse 1.1s ease-in-out infinite; }
.board .dest.far { stroke-dasharray: 4 3; }
@keyframes destPulse { 50% { fill: rgba(120,240,150,.22); } }
.board .dest-tray { fill: rgba(120,230,150,.25); stroke: #7ff0a0; stroke-width: 2; pointer-events: none; animation: destPulse 1.1s ease-in-out infinite; }
.board .last-mark { fill: #ffe08a; opacity: .9; pointer-events: none; }
.board .die.used { opacity: .32; }
.board .left-dot { fill: rgba(255,255,255,.18); }
.board .left-dot.on { fill: #ffe08a; }
.board .pieces, .board .marks, .board .dice, .board .fly { pointer-events: none; }
.board .dragging { opacity: .92; }

/* ---------- Pages ---------- */
.page-head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.page-head h2 { margin: 0; text-align: center; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 30px; color: var(--gold); }
.rules { display: flex; flex-direction: column; gap: 12px; }
.rules p { margin: 0 0 8px; line-height: 1.5; color: #eadcc2; }
.stat-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 14px; align-items: center; }
.stat-grid .h { color: var(--muted); font-size: 13px; font-weight: 800; text-align: center; }
.stat-grid .n { text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 17px; }
.stat-grid .l { color: #eadcc2; }
.stat-grid .lead { color: var(--gold); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--card-b); font-size: 14px; }
.hist li:last-child { border-bottom: 0; }
.hist .when { color: var(--muted); font-size: 12px; }
.hist .pts { font-weight: 900; }
.hist .sess { color: var(--gold); font-weight: 800; }
.hist .ck { width: 18px; height: 18px; }

/* ---------- Modal / sheet ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,5,2,.62); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .2s; }
.modal.center { align-items: center; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: linear-gradient(180deg, #3a2314, #24150b); border: 1px solid var(--card-b); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + var(--safe-b)); box-shadow: 0 -10px 40px rgba(0,0,0,.5); animation: up .25s ease-out; }
.modal.center .sheet { border-radius: 22px; border-bottom: 1px solid var(--card-b); width: calc(100% - 28px); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet h2 { margin: 0 0 6px; text-align: center; font-size: 22px; }
.sheet .lead { text-align: center; color: var(--muted); margin: 0 0 16px; line-height: 1.4; }
.sheet .stack { display: flex; flex-direction: column; gap: 10px; }
.sheet .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 14px; border-radius: 14px; background: rgba(255,240,214,.06); border: 1px solid var(--card-b); font-weight: 700; font-size: 17px; text-align: left; }
.menu-item .ic { width: 26px; text-align: center; }
.trophy { font-size: 56px; text-align: center; line-height: 1; margin: 4px 0 8px; }
.final { text-align: center; font-size: 44px; font-weight: 900; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.final small { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; background: var(--red); color: #fff; margin-left: 6px; vertical-align: middle; }
.nego-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 14px; }
.nego-box > div { background: rgba(0,0,0,.22); border-radius: 14px; padding: 10px; text-align: center; border: 1px solid var(--card-b); }
.nego-box small { display: block; color: var(--muted); font-size: 12px; }
.nego-box b { font-size: 18px; }
.nego-box .mine { border-color: var(--gold); }
.nego-box .theirs { border-color: #7fb6ff; }
.countdown { text-align: center; margin: 2px 0 14px; font-weight: 800; color: var(--gold); min-height: 24px; }
.countdown .num { font-size: 26px; display: inline-block; min-width: 30px; }
.nego-chips { justify-content: center; margin-bottom: 16px; }
.legend { text-align: center; color: var(--muted); font-size: 12px; margin: -6px 0 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin: 0 4px 0 10px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); z-index: 60; background: rgba(20,12,6,.94); border: 1px solid var(--gold-d); color: var(--text); padding: 11px 16px; border-radius: 14px; font-weight: 700; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: toastIn .25s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- Landscape phones: board left, controls right ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  #app { max-width: none; }
  .screen.game { display: grid; grid-template-columns: 1fr 230px; grid-template-rows: auto auto 1fr auto auto; grid-template-areas: "board head" "board opp" "board status" "board me" "board controls"; padding: 6px calc(8px + env(safe-area-inset-right)) 6px calc(6px + env(safe-area-inset-left)); column-gap: 10px; }
  .game-head { grid-area: head; }
  .strip.opp { grid-area: opp; }
  .strip.me { grid-area: me; }
  .board-wrap { grid-area: board; }
  .status { grid-area: status; }
  .controls { grid-area: controls; grid-template-columns: 1fr; }
  .controls .btn { min-height: 46px; }
  .gtitle span { font-size: 20px; }
}
@media (max-width: 360px) {
  .title { font-size: 34px; }
  .btn { font-size: 16px; min-height: 50px; }
  .gtitle span { font-size: 22px; }
}

/* ---------- Accounts ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form h2 { margin-bottom: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { color: var(--muted); font-size: 14px; font-weight: 700; }
.field input { height: 50px; border-radius: 12px; border: 1px solid var(--card-b); background: rgba(0,0,0,.28); color: var(--text); padding: 0 14px; font: inherit; font-size: 18px; width: 100%; }
.field input:focus { outline: 2px solid var(--gold-d); outline-offset: 1px; }
.field input.pin { letter-spacing: 12px; font-size: 24px; text-align: center; font-weight: 900; }
.center { text-align: center; }
.small { font-size: 13px; }
.hello { margin: -4px 0 0; color: var(--muted); }
.hello b { color: var(--text); }
.tag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: rgba(235,210,156,.18); color: var(--gold); vertical-align: middle; }

/* ---------- Players ---------- */
.players-list { display: flex; flex-direction: column; gap: 10px; }
.prow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; }
.prow.myturn { border-color: rgba(235,210,156,.6); background: rgba(235,210,156,.08); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 19px; color: #3a170a; background: radial-gradient(circle at 50% 50%, #f3e4c4 0 30%, #c9ab78 32%, transparent 35%), radial-gradient(circle at 38% 30%, #fbf1dc, #ecd9b1 55%, #d2b685); box-shadow: 0 2px 6px rgba(0,0,0,.45); flex: none; }
.pinfo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pinfo b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmeta { font-size: 13px; color: var(--muted); }
.pmeta b { color: var(--text); }
.your-turn { color: var(--gold); font-weight: 900; }
.btn.small { min-height: 42px; padding: 0 14px; font-size: 15px; border-radius: 12px; white-space: nowrap; }
.invite-card { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; border-color: rgba(127,182,255,.55); background: rgba(127,182,255,.08); animation: pulseCard 1.6s ease-in-out infinite; }
.invite-card .inv-btns { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@keyframes pulseCard { 50% { border-color: rgba(127,182,255,.2); } }
.levels { display: flex; gap: 8px; margin-bottom: 8px; }
.levels .chip { flex: 1; text-align: center; }
.you-tag { color: var(--gold); font-size: 12px; }
.status .thinking::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--gold); animation: blink 1s infinite; vertical-align: middle; }

/* ---------- Settings / admin ---------- */
.sec { margin: 10px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.adm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--card-b); }
.adm-row small { color: var(--muted); }
.linkbox { word-break: break-all; background: rgba(0,0,0,.3); border: 1px dashed var(--gold-d); border-radius: 12px; padding: 12px; font-size: 14px; margin-bottom: 14px; user-select: all; -webkit-user-select: all; }

/* ---------- Ranking ---------- */
table.rank { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.rank th { color: var(--muted); font-size: 12px; font-weight: 800; text-align: center; padding: 0 4px 8px; line-height: 1.2; }
table.rank td { text-align: center; padding: 10px 4px; border-top: 1px solid var(--card-b); font-weight: 800; }
table.rank td small { color: var(--muted); font-weight: 600; }
table.rank td.nm { text-align: left; font-size: 16px; }
table.rank th:nth-child(2) { text-align: left; }
table.rank tr.mine td { color: var(--gold); }
@media (orientation: landscape) and (max-height: 560px) {
  .board { width: auto; height: 100%; max-width: 100%; }
}
