/* Меню: всё помещается в один экран без прокрутки — и на телефоне лёжа, и на компьютере.
   Прокручиваться может только список открытых игр внутри своей панели. */
html, body { height: 100%; overflow: hidden; background: #061a2b; }
body { overscroll-behavior: none; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(70% 60% at 85% -10%, #ffd44722, transparent 70%), radial-gradient(60% 60% at 5% 110%, #ff6f9122, transparent 70%); }
[hidden] { display: none !important; }

#pick { position: fixed; inset: 0; z-index: 2; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: clamp(6px, 1.8vh, 18px);
        padding: max(clamp(8px, 2.2vh, 26px), env(safe-area-inset-top)) max(clamp(10px, 2.6vw, 40px), env(safe-area-inset-right))
                 max(clamp(8px, 2.2vh, 26px), env(safe-area-inset-bottom)) max(clamp(10px, 2.6vw, 40px), env(safe-area-inset-left)); }

/* шапка */
.top { display: flex; align-items: center; gap: clamp(8px, 1.6vw, 18px); min-width: 0; }
.top .grow { flex: 1; min-width: 0; }
.top h1 { margin: 0; font-size: clamp(22px, 6vh, 46px); line-height: 1.05; font-weight: 900; letter-spacing: .01em; white-space: nowrap;
          background: linear-gradient(180deg, #fff3bd, var(--mimosa)); -webkit-background-clip: text; background-clip: text; color: transparent;
          overflow: hidden; text-overflow: ellipsis; }
.sub { margin: 0; color: #cfe6f0; font-size: clamp(12px, 2.6vh, 17px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back, .pill { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 38px; padding: 0 clamp(10px, 1.4vw, 16px); border-radius: 999px;
        color: var(--foam); text-decoration: none; font-weight: 700; font-size: clamp(13px, 2.4vh, 15px); white-space: nowrap;
        background: #ffffff14; border: 1px solid #ffffff2b; transition: background .15s; }
.back:hover, .pill:hover { background: #ffffff26; }
.pill.video { background: #ff3d3d; border-color: #ff3d3d; color: #fff; }
.pill.me { border-color: var(--c, #ffffff55); border-width: 2px; }

/* карточки: картинка заполняет всё, подпись поверх */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) clamp(150px, 21vw, 300px); gap: clamp(8px, 1.4vw, 18px); min-height: 0; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(8px, 1.4vw, 18px); min-height: 0; }
.choices.small { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); }
.choice { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 0; overflow: hidden; text-decoration: none; color: var(--foam);
          border-radius: clamp(14px, 3vh, 26px); background: #0c2c44; border: 2px solid #ffffff26; box-shadow: var(--shadow);
          transition: transform .16s, border-color .16s, box-shadow .16s; }
.choice:hover, .choice:focus-visible { transform: translateY(-3px); border-color: var(--mimosa); box-shadow: 0 22px 50px #04121ec0; outline: 0; }
.choice:active { transform: translateY(0) scale(.99); }
.choice.last { border-color: var(--mimosa); }
.choice img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.choice:hover img { transform: scale(1.05); }
.choice:has(img)::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, #06192bd9 78%); }
.choice > span { position: relative; z-index: 1; }
.choice .name { padding: 0 clamp(10px, 1.4vw, 18px); font-size: clamp(17px, 4.6vh, 30px); font-weight: 900; line-height: 1.1; }
.choice .about { padding: 2px clamp(10px, 1.4vw, 18px) 0; font-size: clamp(12px, 2.2vh, 15px); line-height: 1.25; color: #d2e4ee; }
.choice .meta { padding: 3px clamp(10px, 1.4vw, 18px) clamp(8px, 1.8vh, 14px); font-size: clamp(12px, 2.3vh, 15px); color: var(--mimosa); font-weight: 800; }
.choice .badge { position: absolute; top: 8px; left: 8px; padding: 3px 10px; border-radius: 999px; background: var(--mimosa); color: #3a2a00; font-weight: 800; font-size: 12px; z-index: 2; }
.choices.small .choice { justify-content: center; align-items: center; text-align: center; padding: 6px; gap: 2px;
                         background: linear-gradient(160deg, #15507a, #0c2c44); }
.choices.small .choice.team { background: linear-gradient(160deg, #e0577f, #7b2b57); }
.choices.small .choice.make { background: linear-gradient(160deg, #2f8f73, #12463f); }
.choices.small .choice .name { padding: 0; font-size: clamp(15px, 3.8vh, 23px); }
.choices.small .choice .about { padding: 0; }
.choice .big-emoji { font-size: clamp(24px, 8vh, 56px); line-height: 1; }

/* уровни: сетка на весь экран */
.levels { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: clamp(6px, 1.1vw, 14px); min-height: 0; }
.lvl { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 2px; min-height: 0; overflow: hidden; padding: clamp(6px, 1.5vh, 14px) clamp(8px, 1vw, 14px);
       border-radius: clamp(12px, 2.6vh, 20px); background: linear-gradient(160deg, #15507a, #0c2c44); border: 2px solid #ffffff26; color: var(--foam); text-decoration: none; text-align: left;
       transition: transform .15s, border-color .15s; }
a.lvl:hover, a.lvl:focus-visible { transform: translateY(-2px); border-color: var(--mimosa); outline: 0; }
.lvl.locked { background: #0c2c4488; opacity: .55; }
.lvl::before { content: ''; position: absolute; inset: 0; background: var(--img) center / cover; opacity: .45; transition: opacity .2s, transform .4s; }
.lvl::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, #06192b99 0%, transparent 45%, #06192be6 100%); }
.lvl > * { position: relative; z-index: 1; }
a.lvl:hover::before { opacity: .75; transform: scale(1.06); }
.lvl.locked::before { filter: grayscale(1); opacity: .18; }
.lvl .num { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(30px, 12vh, 72px); font-weight: 900; color: var(--mimosa); line-height: 1; text-shadow: 0 4px 16px #04121e; }
.lvl.locked .num { font-size: clamp(20px, 7vh, 42px); opacity: .7; }
.lvl .name { font-size: clamp(13px, 3.2vh, 21px); font-weight: 800; line-height: 1.12; }
.lvl .about { font-size: clamp(11px, 2.1vh, 14px); line-height: 1.25; color: #b8d2e0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.lvl .meta { font-size: clamp(11px, 2.2vh, 14px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl .off { color: #ffffff33; }

/* свои уровни */
.choice.mine { justify-content: center; align-items: center; text-align: center; gap: 2px; background: linear-gradient(160deg, #6a4bc9, #2b1e63); }
.choice.mine .name, .choice.mine .about, .choice.mine .meta { padding-left: 8px; padding-right: 8px; }
.levels.scroll { overflow-y: auto; grid-auto-rows: minmax(clamp(96px, 30vh, 190px), 1fr); align-content: start; scrollbar-width: thin; }
.lvl.mine-lvl { justify-content: space-between; }
.lvl.mine-lvl .fill { position: absolute; inset: 0; z-index: 2; border-radius: inherit; }
.lvl.mine-lvl:hover { border-color: var(--mimosa); }
.lvl.mine-lvl .edit { position: absolute; z-index: 3; top: 6px; right: 6px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: #06192bdd; border: 1px solid #ffffff44; font-size: 20px; text-decoration: none; color: #fff; padding: 0; cursor: pointer; }
.lvl.mine-lvl .name { padding-right: 46px; }
.lvl.mine-lvl::before { opacity: .8; }
.lvl.add { align-items: center; justify-content: center; text-align: center; background: #ffffff0c; border-style: dashed; }
.lvl.add::before, .lvl.add::after { display: none; }
.lvl.add .plus { font-size: clamp(30px, 10vh, 56px); line-height: 1; color: var(--mimosa); }

/* лобби */
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(8px, 1.2vw, 16px); min-height: 0; }
.stack { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: clamp(8px, 1.2vw, 16px); min-height: 0; }
.panel2 { display: flex; flex-direction: column; gap: clamp(5px, 1.2vh, 12px); min-height: 0; overflow: hidden; padding: clamp(8px, 1.8vh, 18px) clamp(10px, 1.2vw, 18px);
          background: #0c2c44d0; border: 1px solid #ffffff26; border-radius: clamp(14px, 3vh, 22px); text-align: left; backdrop-filter: blur(8px); }
.panel2 h2 { margin: 0; font-size: clamp(14px, 3.2vh, 21px); }
.panel2.room { max-width: 760px; width: 100%; margin: auto; align-items: center; text-align: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.fill > * { flex: 1 1 0; min-width: 0; }
.field { display: grid; gap: 2px; font-size: clamp(11px, 2.2vh, 14px); color: #b8d2e0; }
.vis { font-size: clamp(12px, 2.3vh, 14px); }
input[type=text], select { font: inherit; font-size: clamp(14px, 2.8vh, 17px); padding: clamp(4px, 1.1vh, 9px) 10px; border-radius: 12px; border: 2px solid #ffffff33;
        background: #061a2b; color: #fff; min-width: 0; width: 100%; }
.nick { display: flex; gap: 6px; }
.nick select { flex: 1 1 0; }
.nick button { flex: none; font: inherit; font-size: clamp(16px, 3vh, 20px); padding: 0 10px; border-radius: 12px; border: 2px solid #ffffff33; background: #061a2b; cursor: pointer; }
input.code { text-transform: uppercase; letter-spacing: 5px; width: 6.6em; flex: none; font-weight: 800; text-align: center; }
.btn.big { font-size: clamp(14px, 2.9vh, 18px); padding: clamp(6px, 1.5vh, 13px) clamp(12px, 1.6vw, 22px); justify-content: center; }
.games { display: grid; gap: 6px; align-content: start; overflow-y: auto; min-height: 0; flex: 1; scrollbar-width: thin; }
.game { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 12px; background: #ffffff10; }
.game .what { flex: 1; min-width: 0; font-size: 13px; line-height: 1.25; }
.game .what b { font-size: 15px; }
.game .st { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.game .st.wait { background: #9be37a; color: #12340a; }
.game .st.play { background: #ffb36b; color: #3a1a00; }
.game .btn { padding: 6px 12px; font-size: 14px; }
.empty { color: #9fc0d0; font-size: clamp(12px, 2.4vh, 15px); }
.bigcode { font-size: clamp(32px, 11vh, 64px); font-weight: 900; letter-spacing: .2em; color: var(--mimosa); line-height: 1.1; }
.who { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.who .p { padding: 5px 12px; border-radius: 12px; background: #ffffff14; border: 2px solid var(--c); font-size: clamp(13px, 2.8vh, 17px); }
.who .p.off { opacity: .5; }
.err { position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 5; margin: 0; color: #ffb0c0; font-size: 14px; }

/* профиль: слева персонаж, справа выбор */
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(8px, 1.4vw, 18px); min-height: 0; }
.stage { position: relative; min-height: 0; overflow: hidden; border-radius: clamp(14px, 3vh, 26px); border: 2px solid #ffffff26;
         background: radial-gradient(70% 60% at 50% 35%, #2a7ea8, #0c2c44); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage .ships { position: absolute; z-index: 2; top: 8px; left: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; line-height: 1.1; text-align: center; color: #cfe6f0; }
.stage .ships > div { display: flex; flex-direction: column; gap: 6px; }
.stage .ships button { width: clamp(40px, 11vh, 52px); height: clamp(40px, 11vh, 52px); padding: 0; border-radius: 12px; border: 2px solid #ffffff33; background: #06192bcc; display: grid; place-items: center; cursor: pointer; }
.stage .ships button.on { border-color: var(--mimosa); background: #ffd44733; }
.stage .hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 13px; color: #cfe6f0; pointer-events: none; }
.choose { display: flex; flex-direction: column; justify-content: space-between; gap: clamp(5px, 1.4vh, 14px); min-height: 0; overflow: hidden; padding: clamp(8px, 1.8vh, 18px) clamp(10px, 1.2vw, 18px);
          background: #0c2c44d0; border: 1px solid #ffffff26; border-radius: clamp(14px, 3vh, 26px); }
.heroes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.heroes button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: clamp(36px, 10vh, 64px); border-radius: 14px; border: 2px solid #ffffff26; background: #ffffff10; color: #fff;
                 font-weight: 800; font-size: clamp(14px, 3vh, 18px); }
.heroes button.on { border-color: var(--mimosa); background: #ffd44726; }
.swatches { display: flex; gap: clamp(5px, 1vh, 9px); flex-wrap: wrap; }
.swatches button { position: relative; width: clamp(30px, 8.6vh, 44px); height: clamp(30px, 8.6vh, 44px); border-radius: 50%; border: 3px solid #ffffff22; font-size: clamp(16px, 4.2vh, 22px); background: #ffffff14; padding: 0; line-height: 1; }
.swatches button.on { border-color: #fff; transform: scale(1.1); box-shadow: 0 0 0 2px var(--mimosa); }
.swatches button.none { background: conic-gradient(#ff9dbb, #ffe07a, #9be37a, #8fd0ff, #c7b0ff, #ff9dbb); font-size: 13px; }

/* телефон стоя: колонка */
@media (orientation: portrait) {
  .home-grid, .lobby-grid, .profile-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 3fr) minmax(0, 1fr); }
  .lobby-grid { grid-template-rows: minmax(0, 1fr) auto; }
  .profile-grid { grid-template-rows: minmax(0, 1fr) auto; }
  .home-grid .choices:not(.small) { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); }
  .choices.small { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: auto; }
  .levels { --cols: 2 !important; }
  .top h1 { font-size: clamp(22px, 7vw, 40px); }
  .sub { display: none; }
}
/* совсем низкий экран: только главное */
@media (max-height: 520px) and (orientation: landscape) {
  .sub, .lvl .about, .choices.small .about { display: none; }
  .choice .about { display: none; }
  .back, .pill { min-height: 32px; }
}

/* четыре карты в ряд, на телефоне лёжа тоже */
@media (orientation: landscape) { .home-grid #maps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---- 1.14: неоновое «Ралли» и чистые иконки ---- */
#pick { display: flex; flex-direction: column; }
.rally { position: relative; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 6px 22px; margin: 4px 0 14px;
  padding: 16px 22px; border-radius: 22px; text-decoration: none; color: #fff; overflow: hidden; isolation: isolate;
  background: linear-gradient(100deg, #12062e 0%, #2a0b52 45%, #3b0a4a 100%); border: 1.5px solid rgba(255, 63, 180, .65);
  box-shadow: 0 0 0 1px rgba(63, 243, 255, .15) inset, 0 10px 34px rgba(255, 63, 180, .28); transition: transform .15s, box-shadow .15s; }
.rally::before { content: ''; position: absolute; inset: 0; z-index: -1; opacity: .55;
  background: repeating-linear-gradient(100deg, transparent 0 46px, rgba(63, 243, 255, .08) 46px 48px),
              radial-gradient(ellipse at 85% 50%, rgba(255, 63, 180, .45), transparent 60%); animation: rally-scan 6s linear infinite; }
@keyframes rally-scan { to { background-position: 480px 0, 0 0; } }
.rally:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(63, 243, 255, .3) inset, 0 14px 44px rgba(255, 63, 180, .45); }
.rally-k { font: 900 italic clamp(30px, 4.4vw, 46px)/1 system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase;
  background: linear-gradient(90deg, #3ff3ff, #ff3fb4); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 63, 180, .55)); }
.rally-t { font-size: 15px; color: #d9d3ff; line-height: 1.3; }
.rally-b { font: 700 14px system-ui, sans-serif; color: #3ff3ff; white-space: nowrap; }
.rally-b:empty { display: none; }
.rally-go { font: 800 18px system-ui, sans-serif; padding: 12px 22px; border-radius: 14px; background: linear-gradient(90deg, #ff3fb4, #ff7a3c); color: #fff;
  box-shadow: 0 0 18px rgba(255, 63, 180, .6); white-space: nowrap; }
.rally-go::after { content: ' ›'; }
.home-grid { flex: 1; min-height: 0; }
.choice .ico { width: 54px; height: 54px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .9; margin-bottom: 4px; }
.choice .name { letter-spacing: .01em; }
@media (max-width: 720px) {
  .rally { grid-template-columns: 1fr auto; padding: 14px 16px; }
  .rally-t { grid-column: 1 / -1; grid-row: 2; font-size: 13.5px; }
  .rally-b { grid-row: 3; }
}
@media (prefers-reduced-motion: reduce) { .rally::before { animation: none; } }
/* телефон вертикально: меню прокручивается, карточки не сжимаются, метка «в прошлый раз» — справа */
@media (max-aspect-ratio: 1/1) {
  html, body { overflow: auto; }
  .home-grid, .choices, .rally { flex: none; }
  .choices .choice { min-height: 148px; }
  .choice .badge { left: auto; right: 8px; }
}
