/* Не се сърди, човече — тема RAFAS. Един екран без скрол: дъската се оразмерява по ширина И височина. */
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{background:#080b0d;color:#f1f0eb;font-family:Arial,sans-serif;-webkit-font-smoothing:antialiased;overflow:hidden}
button{font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;color:inherit}
h1,h2,p{margin:0}
#app{height:100dvh;display:flex;justify-content:center;background:#090d10 url('assets/background.jpg') center/cover fixed}

/* колоната: всичко освен дъската има фиксирана височина (--rest); дъската взима остатъка */
.ludo-app{--rest:462px;--gap:8px;width:100%;max-width:440px;height:100%;display:flex;flex-direction:column;gap:var(--gap);
  padding:calc(env(safe-area-inset-top,0px) + 8px) 12px calc(env(safe-area-inset-bottom,0px) + 8px);position:relative}
.game-header{display:flex;align-items:center;justify-content:space-between;height:40px;flex:none}
.brand{width:150px;max-height:40px;object-fit:contain}
.icon-button{width:38px;height:38px;border:1px solid #555b60;background:#11181ddd;border-radius:50%;color:#dfe3e5;display:grid;place-items:center}
.icon-button svg{width:18px;height:18px}
.icon-button:disabled{opacity:.5;cursor:default}
.titles{flex:none;text-align:center}
h1{font:600 19px Georgia,serif;letter-spacing:.4px;color:#f3efdf;line-height:1.2}
.eyebrow{font-size:10px;letter-spacing:1.4px;color:#9ba5ad;margin-top:3px}
.eyebrow span{color:#d7b876;margin:0 8px}

.players{display:flex;justify-content:space-between;gap:12px;flex:none;height:46px}
.player{display:flex;align-items:center;gap:7px;min-width:0;padding:3px 6px 3px 3px;border-bottom:2px solid #43474b;transition:border-color .25s}
.player.active{border-color:var(--team);text-shadow:0 0 12px var(--team)}
.player img{width:38px;height:38px;object-fit:contain}
.player strong{display:block;font-size:13px;line-height:18px}
.player small{display:block;font-size:10px;color:#b0b6bc;white-space:nowrap}

/* дъската: квадрат, не по-широк от колоната и не по-висок от свободното място */
.board{--size:min(100%, calc(100dvh - var(--rest)));width:var(--size);aspect-ratio:1;flex:none;align-self:center;position:relative;
  border:6px ridge #6a6c70;border-radius:14px;background:#11181e;box-shadow:0 12px 24px #0009}
.home{position:absolute;width:40%;height:40%;background:color-mix(in srgb,var(--team) 25%,#080d12) url('assets/background.jpg') center/500px;background-blend-mode:soft-light;
  border:1px solid color-mix(in srgb,var(--team) 70%,#c2c2c2);border-radius:10px;display:flex;align-items:flex-end;justify-content:center;padding-bottom:6px}
.home span{font-size:8px;letter-spacing:1px;color:var(--team)}
.home-0{left:0;top:0}.home-1{right:0;top:0}.home-2{right:0;bottom:0}.home-3{left:0;bottom:0}
.cell{position:absolute;width:6.6667%;height:6.6667%;background:#e2dfd2;border:1px solid #777a79;border-radius:3px;display:grid;place-items:center;color:#11212b;font-size:10px}
.lane{opacity:.92}
.finish{position:absolute;left:40%;top:40%;width:20%;height:20%;background:#101820;border:1px solid #92979a;display:flex;flex-direction:column;align-items:center;justify-content:center}
.finish img{width:90%;object-fit:contain;margin-bottom:4px}
.finish small{font-size:7px;letter-spacing:1px;color:#c9c5b5}

/* пионките живеят постоянно в DOM-а — затова преходите по left/top се виждат */
.pawn{position:absolute;width:7.3%;height:9.5%;padding:0;background:none;border:0;overflow:visible;
  transform:translate(-50%,-70%) translateX(var(--stack,0px));transition:left .16s ease-in-out,top .16s ease-in-out;filter:drop-shadow(0 2px 2px #000b)}
.pawn.fly{transition:left .7s cubic-bezier(.3,.8,.4,1),top .7s cubic-bezier(.3,.8,.4,1)}
.pawn img{width:100%;height:100%;object-fit:contain;pointer-events:none;display:block;transform-origin:50% 90%}
.pawn.hop img{animation:hop .17s ease-out}
.pawn span{position:absolute;bottom:-3px;left:50%;transform:translateX(-50%);font-size:7px;background:#08121b;color:#fff;padding:1px 3px;border-radius:4px;pointer-events:none}
.pawn:disabled{cursor:default}
.pawn.can-move{filter:drop-shadow(0 0 4px var(--team)) drop-shadow(0 0 1px #fff);animation:pawnPulse 1s ease-in-out infinite alternate;cursor:pointer;z-index:5}
.pawn.can-move:focus-visible{outline:2px solid #fff;outline-offset:3px}
.pawn.moving{z-index:9;filter:drop-shadow(0 6px 6px #000c)}

.turn-panel{flex:none;padding:10px 12px;border:1px solid #6d7378;border-radius:16px;background:#10171ded;box-shadow:0 5px 20px #0009}
.turn-label{text-align:center;font-size:13px;font-weight:700;letter-spacing:.7px;color:#e9edf0;text-shadow:0 0 14px color-mix(in srgb,var(--team) 60%,transparent)}
.action-row{display:flex;align-items:center;gap:12px;margin-top:8px}
.die{width:62px;height:62px;flex:none;padding:4px;border:1px solid #6b7074;background:#151b22;border-radius:14px}
.die img{width:100%;height:100%;object-fit:contain}
.die:disabled{cursor:default}
.die.rolling{animation:shake .18s infinite}
.action-copy{flex:1;min-width:0}
.roll-button{width:100%;min-height:44px;border:1px solid #81e5b5;border-radius:12px;background:#087343;color:#fff;font-size:16px;font-weight:700;box-shadow:inset 0 0 0 3px #ffffff12}
.roll-button:disabled{background:#263338;border-color:#596b70;color:#c1cdce;cursor:default}
.under{min-height:22px;margin-top:6px;display:flex;align-items:center;justify-content:center;gap:5px}
.under p{font-size:11px;color:#b7bdc2;text-align:center;line-height:1.4}
.move-options{display:contents}
.move-options button{flex:1;min-height:30px;border:1px solid #55997f;border-radius:8px;background:#113d2f;color:#fff;font-size:12px}
.live-message{flex:none;font-size:12px;color:#c5c8c9;text-align:center;min-height:18px;line-height:18px}
footer{flex:none;display:flex;justify-content:space-between;align-items:center;border-top:1px solid #333d44;padding-top:6px;height:40px}
footer button{background:none;color:#c7ced4;border:0;display:flex;align-items:center;gap:6px;font-size:11px;padding:6px 3px}
footer button span{font-size:10px;color:#8d9aa3}
footer svg{width:16px;height:16px}

.overlay{position:fixed;inset:0;z-index:20;background:#000b;display:flex;align-items:center;justify-content:center;padding:16px;backdrop-filter:blur(5px)}
.dialog{position:relative;width:100%;max-width:420px;max-height:calc(100dvh - 32px);overflow:auto;background:#141e25;border:1px solid #667077;border-radius:20px;padding:26px 22px;color:#e7ecf0;box-shadow:0 20px 80px #000}
.close{position:absolute;right:12px;top:12px;background:none;border:0;color:#fff;padding:8px}
.close svg{width:16px;height:16px}
.dialog h2{font:24px Georgia,serif;margin:14px 0}
.dialog p,.dialog li{font-size:13px;line-height:1.6;color:#bac6ce}
.dialog ol{padding-left:20px}.dialog li{margin:10px 0}
.setting-row{display:flex;justify-content:space-between;align-items:center;padding:10px 0;border-bottom:1px solid #303e48}
.setting-row button{border:1px solid #5a6e7c;background:#233642;color:#fff;border-radius:8px;padding:7px 16px;min-width:82px}
.speed{display:flex;align-items:center;gap:8px;font-size:12px;margin:18px 0;width:100%;background:#223642;color:#d7e6ef;border:1px solid #587184;border-radius:8px;padding:10px}
.primary{width:100%;border:1px solid #61ce99;background:#087343;color:#fff;border-radius:11px;padding:13px;font-weight:700}
.dialog small{display:block;text-align:center;color:#8799a5;font-size:10px;margin-top:10px}
.history-row{border-bottom:1px solid #2e3c45;padding-bottom:8px;margin-bottom:8px}

/* много ниски екрани (пейзаж, стари телефони): по-плътно */
@media (max-height:640px){.ludo-app{--rest:400px;--gap:5px}.titles{display:none}.players{height:40px}.player img{width:32px;height:32px}.live-message{display:none}}
@media (min-width:900px) and (min-height:900px){.ludo-app{max-width:520px;--rest:500px}}

@keyframes shake{0%,100%{transform:rotate(-8deg)}50%{transform:rotate(8deg)}}
@keyframes pawnPulse{from{filter:drop-shadow(0 0 2px var(--team))}to{filter:drop-shadow(0 0 7px var(--team))}}
@keyframes hop{0%{transform:translateY(0) scale(1)}45%{transform:translateY(-38%) scale(1.12)}100%{transform:translateY(0) scale(1)}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
