/* «Разъезд» — the standalone shell. The board's own look is rails.css. */
@font-face{font-family:'Nunito'; font-weight:400; font-display:swap; src:url('fonts/nunito-cyrillic-400-normal.woff2') format('woff2'); unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
@font-face{font-family:'Nunito'; font-weight:400; font-display:swap; src:url('fonts/nunito-latin-400-normal.woff2') format('woff2'); unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}
@font-face{font-family:'Nunito'; font-weight:600; font-display:swap; src:url('fonts/nunito-cyrillic-600-normal.woff2') format('woff2'); unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
@font-face{font-family:'Nunito'; font-weight:600; font-display:swap; src:url('fonts/nunito-latin-600-normal.woff2') format('woff2'); unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}
@font-face{font-family:'Nunito'; font-weight:700; font-display:swap; src:url('fonts/nunito-cyrillic-700-normal.woff2') format('woff2'); unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
@font-face{font-family:'Nunito'; font-weight:700; font-display:swap; src:url('fonts/nunito-latin-700-normal.woff2') format('woff2'); unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}
@font-face{font-family:'Nunito'; font-weight:800; font-display:swap; src:url('fonts/nunito-cyrillic-800-normal.woff2') format('woff2'); unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
@font-face{font-family:'Nunito'; font-weight:800; font-display:swap; src:url('fonts/nunito-latin-800-normal.woff2') format('woff2'); unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}

:root{
  --bg:#F5EFE3; --paper:#FBF8F2; --card:#ECE2CF; --line:#DCCFB8;
  --ink:#38342F; --ink-2:#6D675E; --ink-3:#958E83;
  --blue:#A8C7E3; --blue-d:#7BA2C7; --mint:#A6DAC3; --mint-d:#6FB295; --rose:#E3B4BC; --rose-d:#C48A95;
  --gold:#C9A55C; --warn:#D9826F; --shadow:rgba(84,60,30,.22);
  --font:'Nunito',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
}
*{box-sizing:border-box}
html,body{height:100%; margin:0; overflow:hidden; overscroll-behavior:none}
body{background:var(--bg); color:var(--ink); font-family:var(--font); font-size:16px; line-height:1.4;
  -webkit-font-smoothing:antialiased; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent}
button{font:inherit; color:inherit; cursor:pointer; -webkit-tap-highlight-color:transparent}
button:focus-visible{outline:2.5px solid var(--blue-d); outline-offset:2px}
.icon-btn svg,.btn svg,.prize-chip svg{fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round}
h1,h2,h3,p{margin:0}
[hidden]{display:none !important}

/* layout: top bar, HUD, tip, the board (takes the rest), buttons. Short landscape screens: board left, the rest right. */
.app{height:100%; max-width:640px; margin:0 auto; display:grid; gap:8px;
  grid-template-columns:minmax(0,1fr); grid-template-rows:auto auto auto minmax(0,1fr) auto; grid-template-areas:"top" "hud" "tip" "stage" "bottom";
  padding:max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left))}
.top{grid-area:top; display:flex; align-items:center; gap:8px}
.hud{grid-area:hud; display:flex; align-items:center; justify-content:space-between; gap:10px; padding-inline:4px}
.tip{grid-area:tip}
.stage{grid-area:stage; min-height:0; display:grid; place-items:center; position:relative}
/* zoom buttons sit in the HUD row above the board, never over it */
.zoom-ctl{display:flex; gap:4px}
.zbtn{width:44px; height:40px; border:0; border-radius:12px; background:var(--paper); display:grid; place-items:center}
.zbtn svg{width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round}
.seg{display:grid; grid-template-columns:1fr 1fr; gap:4px; background:var(--card); border-radius:14px; padding:4px}
.seg button{min-height:40px; border:0; border-radius:11px; background:transparent; font-weight:800; font-size:15px; color:var(--ink-2)}
.seg button[aria-pressed="true"]{background:var(--paper); color:var(--ink); box-shadow:0 1px 3px var(--shadow)}
.bottom{grid-area:bottom; display:flex; gap:10px}
.bottom .btn{flex:1}
@media (orientation:landscape) and (max-height:560px){
  .app{max-width:none; grid-template-columns:minmax(0,1fr) minmax(220px,280px); grid-template-rows:auto auto auto minmax(0,1fr) auto;
    grid-template-areas:"stage top" "stage hud" "stage tip" "stage ." "stage bottom"; column-gap:16px}
  .bottom{flex-direction:column}
}

.icon-btn{width:44px; height:44px; flex:none; border:0; border-radius:14px; background:var(--paper); display:grid; place-items:center; box-shadow:0 1px 0 var(--line)}
.icon-btn svg{width:22px; height:22px}
.level-title{flex:1; min-width:0; font-size:19px; font-weight:800; text-align:center; letter-spacing:.01em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.prize-chip{height:44px; border:0; border-radius:14px; background:var(--paper); display:flex; align-items:center; gap:6px; padding:0 12px 0 10px;
  font-weight:800; font-variant-numeric:tabular-nums; box-shadow:0 1px 0 var(--line)}
.prize-chip svg{width:22px; height:22px; color:var(--blue-d)}
.prize-chip.full{color:var(--ink-3)}
.prize-chip.bump{animation:chip-bump .6s ease-out}
@keyframes chip-bump{30%{transform:translateY(-4px) scale(1.06); background:var(--mint)} 100%{transform:none}}

.chip{background:var(--paper); border-radius:10px; padding:6px 11px; font-weight:700; font-variant-numeric:tabular-nums; font-size:15px; transition:background-color .3s}
.stars-live{font-size:26px; letter-spacing:.06em; color:var(--gold); line-height:1; display:flex}
.stars-live span{display:inline-block}
.stars-live .off,.end-stars .off,.lv .st .off{color:var(--line)}
.stars-live .lost{animation:star-lost .6s ease-out}
@keyframes star-lost{0%{color:var(--warn); transform:scale(1.35)} 30%{transform:translateY(-4px) rotate(-12deg)} 60%{transform:translateY(2px) rotate(8deg)} 100%{transform:none}}
.stars-live.last .on{animation:star-last 1.2s ease-in-out infinite}
@keyframes star-last{50%{transform:scale(1.15); color:var(--warn)}}
.tip{background:var(--paper); border-radius:14px; padding:10px 14px; font-size:15px; font-weight:600; color:var(--ink-2); text-align:center; text-wrap:balance}

.board-host{width:100%; height:100%; box-shadow:0 10px 30px -18px var(--shadow)}

.btn{min-height:48px; border:0; border-radius:16px; padding:10px 16px; display:inline-flex; align-items:center; justify-content:center; gap:8px;
  background:var(--ink); color:var(--paper); font-weight:800; font-size:16px}
.btn svg{width:20px; height:20px; flex:none}
.btn.ghost{background:var(--paper); color:var(--ink); box-shadow:inset 0 0 0 1.5px var(--line)}
.btn.wide{width:100%}
.btn.danger{color:#9A4434}
.btn:disabled{opacity:.45; cursor:default}
.btn .count{min-width:24px; height:24px; padding:0 7px; border-radius:12px; background:rgba(255,255,255,.2); display:grid; place-items:center; font-size:14px}
.btn .count.ad svg{width:13px; height:13px; fill:currentColor; stroke:none}

/* end of a level */
.modal,.sheet{position:fixed; inset:0; z-index:20; background:rgba(56,52,47,.32); display:grid; padding:16px}
.modal{place-items:center}
.modal-card{width:min(360px, 100%); background:var(--paper); border-radius:24px; padding:24px 20px 20px; display:grid; gap:10px; text-align:center;
  box-shadow:0 24px 48px -20px rgba(56,52,47,.5); animation:pop .28s ease-out}
@keyframes pop{from{transform:scale(.94); opacity:0}}
.end-stars{font-size:38px; letter-spacing:.12em; color:var(--gold); line-height:1}
.modal-card h2{font-size:22px; font-weight:800}
.end-text{color:var(--ink-2); font-size:15px}
.end-prize{display:flex; align-items:center; gap:12px; text-align:left; background:var(--card); border-radius:16px; padding:10px 12px}
.ep-ico{width:52px; height:42px; flex:none; border-radius:10px; display:grid; place-items:center; font-size:22px; background:var(--mint); box-shadow:2px 5px 8px -3px var(--shadow)}
.ep-text{display:grid; font-size:14.5px; color:var(--ink-2)}
.ep-text b{color:var(--ink); font-size:15px}
.end-actions{display:grid; gap:8px; margin-top:6px}

/* sheets: from the bottom on phones, centred on wide screens */
.sheet{align-items:end; justify-items:center; padding:0}
.sheet-card{width:min(560px, 100%); max-height:88%; overflow-y:auto; background:var(--paper); border-radius:24px 24px 0 0;
  padding:16px 18px max(20px, env(safe-area-inset-bottom)); display:grid; gap:12px; align-content:start; animation:rise .25s ease-out; user-select:text; -webkit-user-select:text}
@keyframes rise{from{transform:translateY(24px); opacity:0}}
@media (min-width:700px) and (min-height:560px){ .sheet{align-items:center; padding:16px} .sheet-card{border-radius:24px} }
.sheet-head{display:flex; align-items:center; justify-content:space-between; gap:12px;
  position:sticky; top:-16px; z-index:1; margin:-16px 0 0; padding:16px 0 8px; background:var(--paper)}
.sheet-head h2{font-size:20px; font-weight:800}
.sheet-head .close{background:var(--card); box-shadow:none}
.sub{font-size:13px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:var(--ink-2); margin-top:6px}
.sheet-note{color:var(--ink-2); font-size:15px}
.sheet-note.small{font-size:13.5px; color:var(--ink-3)}

.level-grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(62px, 1fr)); gap:8px}
.lv{aspect-ratio:1; border:0; border-radius:14px; background:var(--card); display:grid; place-items:center; align-content:center; gap:2px; font-weight:800; font-size:18px; font-variant-numeric:tabular-nums}
.lv .st{font-size:11px; letter-spacing:.05em; color:var(--gold)}
.lv.cur{background:var(--blue); box-shadow:0 0 0 2px var(--blue-d)}
.lv:disabled{background:transparent; box-shadow:inset 0 0 0 1.5px var(--line); color:var(--ink-3); cursor:default}

.timetable{display:flex; flex-wrap:wrap; gap:6px 22px; align-items:baseline; font-size:12.5px; font-weight:800; letter-spacing:.05em; text-transform:uppercase; color:var(--ink-2)}
.timetable b{font-size:20px; letter-spacing:0; color:var(--ink); margin-left:7px; font-variant-numeric:tabular-nums}
.ptrain{display:flex; flex-wrap:wrap; gap:6px; align-items:center}
.ploco{width:62px; height:46px; border-radius:22px 10px 10px 22px; background:linear-gradient(90deg, var(--blue-d) 0 30%, var(--blue) 30% 100%); box-shadow:2px 6px 9px -4px var(--shadow); position:relative}
.ploco::after{content:""; position:absolute; left:21px; top:10px; width:9px; height:26px; border-radius:4px; background:rgba(255,255,255,.62)}
.pw{width:52px; height:46px; border-radius:10px; display:grid; place-items:center; position:relative; box-shadow:inset 0 0 0 1.5px var(--line); font-size:19px}
.pw .pi{opacity:.3; filter:grayscale(1)}
.pw.on{box-shadow:2px 6px 9px -4px var(--shadow)}
.pw.on .pi{opacity:1; filter:none}
.pw.c-blue{background:var(--blue)} .pw.c-mint{background:var(--mint)} .pw.c-rose{background:var(--rose)}
.pw.ad{border-radius:10px; box-shadow:inset 0 0 0 1.5px var(--line); border:0}
.pw .px{position:absolute; top:-7px; right:-6px; font-size:10.5px; font-weight:800; background:var(--ink); color:var(--paper); border-radius:6px; padding:2px 4px; line-height:1}
.ptrain.gone .pw,.ptrain.gone .ploco{opacity:.5}
.inv{display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:8px}
.inv div{background:var(--card); border-radius:14px; padding:10px 8px; display:grid; gap:2px; text-align:center}
.inv b{font-size:22px; font-variant-numeric:tabular-nums}
.inv span{font-size:13px; color:var(--ink-2); line-height:1.2}

.set-row{display:flex; align-items:center; justify-content:space-between; gap:12px; font-weight:700; font-size:17px}
.toggle{width:96px; height:44px; border:0; border-radius:22px; background:var(--card); position:relative; display:flex; align-items:center; justify-content:flex-end; padding:0 14px; font-weight:800; font-size:14px}
.toggle .knob{position:absolute; left:5px; top:5px; width:34px; height:34px; border-radius:50%; background:var(--paper); box-shadow:0 2px 4px var(--shadow); transition:left .2s}
.toggle[aria-pressed="true"]{background:var(--mint); justify-content:flex-start}
.toggle[aria-pressed="true"] .knob{left:57px}
.skins{display:grid; grid-template-columns:repeat(auto-fill, minmax(120px, 1fr)); gap:8px}
.skin{border:0; border-radius:16px; padding:0 0 10px; background:var(--card); display:grid; gap:7px; text-align:center; font-weight:700; font-size:14px; overflow:hidden}
.skin .sw{height:52px; display:flex; align-items:center; justify-content:center; gap:7px; border-radius:16px 16px 0 0}
.skin .sw i{width:20px; height:14px; border-radius:5px; box-shadow:1px 3px 4px -2px var(--rl-shadow)}
.skin .sw i:nth-child(1){background:var(--rl-blue)} .skin .sw i:nth-child(2){background:var(--rl-mint)} .skin .sw i:nth-child(3){background:var(--rl-rose)}
.skin[aria-pressed="true"]{box-shadow:0 0 0 2.5px var(--ink)}
.skin:disabled{cursor:default; color:var(--ink-3)}
.skin:disabled .sw{filter:grayscale(.7); opacity:.55}
.skin small{display:block; font-weight:600; font-size:11.5px; color:var(--ink-3); padding-inline:6px}
.about{display:grid; gap:4px; color:var(--ink-2); font-size:14.5px}
.sel{user-select:all; -webkit-user-select:all; color:var(--ink); font-weight:700}

.pause-layer{position:fixed; inset:0; z-index:50; background:rgba(56,52,47,.4); display:grid; place-items:center}
.pause-badge{background:var(--paper); border-radius:16px; padding:14px 22px; font-weight:800; font-size:20px}
.toast{position:fixed; z-index:40; left:50%; bottom:max(24px, env(safe-area-inset-bottom)); transform:translateX(-50%); width:max-content; max-width:calc(100% - 32px);
  background:var(--ink); color:var(--paper); border-radius:14px; padding:11px 16px; font-weight:700; font-size:15px; text-align:center; box-shadow:0 12px 24px -12px rgba(0,0,0,.5)}

.boot-loader{position:fixed; inset:0; z-index:60; background:var(--bg); display:grid; place-items:center; transition:opacity .3s}
.boot-loader.done{opacity:0; pointer-events:none}
.boot-spinner{width:36px; height:36px; border-radius:50%; border:4px solid var(--card); border-top-color:var(--blue-d); animation:spin .9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
/* short landscape screens: the side column is narrow, so the title takes a row of its own above the buttons */
@media (orientation:landscape) and (max-height:560px){
  .top{flex-wrap:wrap; row-gap:6px}
  .level-title{order:-1; flex:1 0 100%; text-align:left; padding-inline:4px}
  .prize-chip{flex:1; justify-content:center}
}
@media (prefers-reduced-motion:reduce){ .modal-card,.sheet-card,.prize-chip.bump,.boot-spinner,.stars-live .lost,.stars-live.last .on{animation:none} .toggle .knob{transition:none} }
/* narrow phones: the HUD row holds the counter, three zoom buttons and the stars */
@media (max-width:400px){
  .hud{gap:6px; padding-inline:0}
  .chip{padding:6px 8px; font-size:14px}
  .zbtn{width:38px}
  .stars-live{font-size:22px}
}
