/* ============================================================
   Морской бой — цифровой стиль. Mobile first.
   ============================================================ */
:root {
  --bg: #070b16;
  --bg-2: #0b1222;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8eefb;
  --muted: #8b97b3;
  --accent: #29e0ff;
  --accent-2: #4f7cff;
  --accent-rgb: 41, 224, 255;
  --hit: #ff4d5e;
  --hit-2: #ff9a3c;
  --miss: #6f7ea1;
  --good: #3ddc97;
  --warn: #ffc94d;
  --grid: rgba(var(--accent-rgb), 0.16);
  --water: rgba(var(--accent-rgb), 0.04);
  --ship: #c9d6f5;
  --radius: 18px;
  --radius-s: 12px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
[data-theme='aurora'] { --accent: #b476ff; --accent-2: #5ee2ff; --accent-rgb: 180, 118, 255; }
[data-theme='coral'] { --accent: #ff7a59; --accent-2: #ffc94d; --accent-rgb: 255, 122, 89; }
[data-theme='radar'] { --accent: #3ef29a; --accent-2: #a6ff5e; --accent-rgb: 62, 242, 154; }
[data-theme='gold'] { --accent: #ffd166; --accent-2: #ff8f5e; --accent-rgb: 255, 209, 102; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(var(--accent-rgb), 0.16), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(79, 124, 255, 0.14), transparent 60%),
    var(--bg);
}
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(var(--accent-rgb), 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at 50% 30%, black 20%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, black 20%, transparent 80%);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }
p { margin: 0; }
b { font-weight: 800; }
.mono { font-family: var(--mono); font-weight: 600; letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent); }
.hidden { display: none !important; }
.dot { margin: 0 6px; color: var(--muted); }
.input {
  width: 100%; padding: 14px; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 17px; outline: none; margin-top: 12px;
}
.input:focus { border-color: var(--accent); }

#app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; }

/* ---------- Экраны ---------- */
.screen {
  display: none;
  flex-direction: column;
  gap: 14px;
  min-height: 100dvh;
  padding: calc(14px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  animation: screen-in 0.3s ease both;
}
.screen.active { display: flex; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.top h2 { text-align: center; font-size: 18px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); font-size: 22px; line-height: 1; color: var(--text);
}
.icon-btn.back { font-size: 28px; padding-bottom: 3px; }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Кнопки ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 16px; font-weight: 800; font-size: 16px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; transform: none; }
.btn.big { width: 100%; padding: 17px 20px; font-size: 18px; min-height: 58px; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04101c; border-color: transparent;
  box-shadow: 0 10px 30px -10px rgba(var(--accent-rgb), 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.primary.big { flex-direction: column; gap: 0; }
.btn.primary.big small { font-weight: 600; font-size: 12px; opacity: 0.75; }
.btn.ghost { background: var(--surface); }
.btn.bonus {
  width: 100%; justify-content: space-between; padding: 14px 18px;
  background: linear-gradient(135deg, rgba(255, 201, 77, 0.18), rgba(255, 122, 89, 0.15));
  border-color: rgba(255, 201, 77, 0.4);
  animation: pulse-glow 2s ease-in-out infinite;
}
.btn.bonus span { flex: 1; text-align: left; }
.btn.bonus b { color: var(--warn); }
@keyframes pulse-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 201, 77, 0); } 50% { box-shadow: 0 0 24px -4px rgba(255, 201, 77, 0.55); } }
.btn.fire {
  min-width: 140px; min-height: 52px; padding: 12px 22px; font-size: 18px; border-radius: 16px;
  background: linear-gradient(135deg, var(--hit), var(--hit-2)); color: #1a0508; border-color: transparent;
  box-shadow: 0 10px 30px -10px rgba(255, 77, 94, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.btn.fire:disabled { opacity: 0.35; filter: grayscale(0.6); }
.my-turn .btn.fire:not(:disabled) { animation: fire-ready 1.4s ease-in-out infinite; }
@keyframes fire-ready { 0%, 100% { box-shadow: 0 10px 30px -10px rgba(255, 77, 94, 0.8); } 50% { box-shadow: 0 10px 40px -6px rgba(255, 77, 94, 1); } }

.sticky-bottom { position: sticky; bottom: calc(10px + var(--safe-bottom)); margin-top: auto; padding-top: 8px; }

/* ---------- Карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.card-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 15px; margin-bottom: 10px; }
.card.action {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; min-height: 118px;
  transition: transform 0.12s ease, border-color 0.2s;
}
.card.action:active { transform: scale(0.97); }
.card.action.done { border-color: rgba(61, 220, 151, 0.45); }
.card.action .act-icon { font-size: 26px; margin-bottom: 6px; }
.card.action b { font-size: 16px; }
.card.action small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card.continue {
  display: flex; align-items: center; gap: 14px; text-align: left; border-color: rgba(var(--accent-rgb), 0.5);
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.16), var(--surface));
}
.cont-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #04101c; font-size: 16px; padding-left: 3px; }
.cont-text { display: flex; flex-direction: column; }
.cont-text small { color: var(--muted); font-size: 12px; }

/* ---------- Главная ---------- */
.home-head { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; }
.avatar {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.35), rgba(79, 124, 255, 0.2)); border: 1px solid rgba(var(--accent-rgb), 0.4);
}
.avatar.big { width: 64px; height: 64px; font-size: 32px; }
.who { min-width: 0; }
.name-row { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 17px; }
.name-row .icon-btn { width: 26px; height: 26px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.rank-row { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.xpbar { height: 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.xpbar.big { height: 12px; margin: 6px 0; }
.xpbar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.7); }
.xp-text { font-size: 11px; color: var(--muted); margin-top: 4px; }
.streak { display: flex; flex-direction: column; align-items: center; line-height: 1; padding: 6px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.streak span { font-size: 18px; }
.streak b { font-family: var(--mono); font-size: 16px; }
.streak small { font-size: 10px; color: var(--muted); }

.logo { text-align: center; padding: 14px 0 4px; }
.logo h1 {
  font-size: clamp(38px, 11vw, 52px); line-height: 0.95; letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff, rgba(var(--accent-rgb), 0.85)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 8px 30px rgba(var(--accent-rgb), 0.35));
}
.logo h1 span { display: block; color: var(--accent); -webkit-text-fill-color: var(--accent); font-weight: 800; }
.logo p { font-size: 12px; color: var(--muted); margin-top: 8px; letter-spacing: 0.08em; }

.missions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.missions li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.missions .m-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; grid-column: 1 / -1; }
.missions .m-row b { color: var(--accent); }
.missions .m-bar { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.missions .m-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.6s; }
.missions small { font-size: 11px; }
.missions li.done { opacity: 0.55; }
.missions li.done .m-bar i { background: var(--good); }
.missions li.done .m-row b { color: var(--good); }

.home-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.home-nav button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.home-nav button span { font-size: 20px; }
.home-nav button:active { transform: scale(0.96); }
.version { text-align: center; font-size: 11px; }

/* ---------- Онлайн ---------- */
.card.action.wide { flex-direction: row; align-items: center; gap: 14px; min-height: 0; padding: 14px 16px; border-color: rgba(var(--accent-rgb), 0.35); background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.12), var(--surface)); }
.card.action.wide .act-icon { margin: 0; font-size: 28px; }
.card.action.wide .act-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.card.action.wide .chev { font-size: 26px; color: var(--muted); }
.online-status { font-size: 14px; color: var(--muted); text-align: center; line-height: 1.4; padding: 0 6px; min-height: 40px; }
.online-status.good { color: var(--good); }
.online-status.bad { color: var(--hit); }
.online-status.busy { color: var(--accent); }
.room-card .card-title { margin-bottom: 6px; }
.room-code-box { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.room-code { text-align: center; font-size: 40px; letter-spacing: 0.3em; padding: 14px 0 14px 0.3em; border-radius: 14px; background: rgba(0, 0, 0, 0.3); border: 1px dashed rgba(var(--accent-rgb), 0.6); color: var(--accent); text-shadow: 0 0 20px rgba(var(--accent-rgb), 0.6); }
.room-code-box .input { margin-top: 0; font-size: 12px; color: var(--muted); }
.room-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.code-input { text-align: center; font-size: 26px; letter-spacing: 0.25em; text-transform: uppercase; }
.online-note { text-align: center; padding: 0 8px; }
.waiting { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.waiting .modal-actions { justify-content: center; width: 100%; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(var(--accent-rgb), 0.2); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin-bottom: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.reactions { display: flex; justify-content: center; gap: 6px; }
.reactions button { width: 40px; height: 36px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 18px; transition: transform 0.12s; }
.reactions button:active { transform: scale(0.9); }
.float.emoji { font-size: 54px; text-transform: none; letter-spacing: 0; }
.own-slot .float.emoji { font-size: 30px; }

.lb { display: flex; flex-direction: column; gap: 4px; }
.lb-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.22); font-size: 14px; }
.lb-row.me { background: rgba(var(--accent-rgb), 0.16); border: 1px solid rgba(var(--accent-rgb), 0.4); }
.lb-rank { color: var(--muted); font-size: 13px; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Режимы ---------- */
.modes { display: flex; flex-direction: column; gap: 10px; }
.mode-card {
  display: grid; grid-template-columns: 48px 1fr; gap: 12px; text-align: left; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); transition: border-color 0.2s, background 0.2s, transform 0.12s;
}
.mode-card:active { transform: scale(0.985); }
.mode-card.selected { border-color: var(--accent); background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.14), var(--surface)); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.4) inset; }
.mode-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: var(--surface-2); }
.mode-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.mode-head b { font-size: 16px; }
.tag { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; background: rgba(var(--accent-rgb), 0.15); color: var(--accent); }
.mode-body p { font-size: 13px; color: var(--muted); line-height: 1.35; }
.mode-body small { display: block; margin-top: 6px; font-size: 11px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.3); }
.seg button { padding: 10px; border-radius: 11px; font-weight: 800; font-size: 14px; color: var(--muted); transition: all 0.2s; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.5) inset; }
#difficulty-desc { margin-top: 10px; }

/* ---------- Доска ---------- */
.board-wrap { width: 100%; }
.board {
  --n: 11;
  display: grid; grid-template-columns: repeat(11, 1fr); grid-template-rows: repeat(11, 1fr);
  width: 100%; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none;
  border-radius: 14px; padding: 4px;
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.06), rgba(0, 0, 0, 0.25));
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8), inset 0 0 40px rgba(var(--accent-rgb), 0.05);
  position: relative;
}
.board.shake { animation: shake 0.35s ease; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.lbl { display: grid; place-items: center; font-family: var(--mono); font-size: clamp(9px, 2.4vw, 12px); color: rgba(var(--accent-rgb), 0.7); font-weight: 700; }
.cell {
  position: relative; border: 1px solid var(--grid); background: var(--water); border-radius: 3px; margin: 0.5px;
  transition: background 0.15s, box-shadow 0.15s;
}
.cell::before, .cell::after { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }

/* корабли */
.cell.ship { background: linear-gradient(160deg, #e6edff, var(--ship)); border-color: rgba(255, 255, 255, 0.5); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.35); }
.cell.ship.s-one { border-radius: 40%; }
.cell.ship.s-h.s-head { border-radius: 50% 3px 3px 50%; }
.cell.ship.s-h.s-tail { border-radius: 3px 50% 50% 3px; }
.cell.ship.s-v.s-head { border-radius: 50% 50% 3px 3px; }
.cell.ship.s-v.s-tail { border-radius: 3px 3px 50% 50%; }
.cell.ship::before { inset: 28%; border-radius: 30%; background: rgba(var(--accent-rgb), 0.35); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.cell.ship.s-mid::before, .cell.ship.s-h.s-tail::before, .cell.ship.s-v.s-tail::before { inset: 36%; background: rgba(0, 0, 0, 0.15); }

/* промах */
.cell.miss::before { inset: 40%; border-radius: 50%; background: var(--miss); opacity: 0.8; }
/* попадание */
.cell.hit { background: radial-gradient(circle, rgba(255, 154, 60, 0.6), rgba(255, 77, 94, 0.35)); border-color: rgba(255, 77, 94, 0.7); box-shadow: 0 0 12px rgba(255, 77, 94, 0.5); }
.cell.hit::before, .cell.hit::after { inset: 45% 18%; background: #fff; border-radius: 2px; box-shadow: 0 0 6px rgba(255, 255, 255, 0.8); }
.cell.hit::before { transform: rotate(45deg); }
.cell.hit::after { transform: rotate(-45deg); }
.cell.hit.ship { background: linear-gradient(160deg, #6b1d2a, #3a0d16); }
.cell.hit.sunk { background: linear-gradient(160deg, #4a1220, #2a0810); border-color: rgba(255, 77, 94, 0.5); box-shadow: none; }
.cell.hit.sunk::before, .cell.hit.sunk::after { background: var(--hit); box-shadow: none; }
/* радар */
.cell.detected { border-color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn), 0 0 10px rgba(255, 201, 77, 0.6); animation: detected 1.2s ease-in-out infinite; }
.cell.detected::before { inset: 30%; border-radius: 50%; background: var(--warn); }
@keyframes detected { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
/* прицел */
.cell.target { box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(var(--accent-rgb), 0.9); background: rgba(var(--accent-rgb), 0.28); z-index: 2; animation: target-pulse 1s ease-in-out infinite; }
.cell.target::before { inset: 30%; border-radius: 50%; border: 2px solid var(--accent); }
.cell.target.miss::before { background: none; }
@keyframes target-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.cell.area { background: rgba(var(--accent-rgb), 0.22); border-color: rgba(var(--accent-rgb), 0.6); }
/* призрак расстановки */
.cell.ghost-ok { background: rgba(61, 220, 151, 0.4); border-color: var(--good); }
.cell.ghost-bad { background: rgba(255, 77, 94, 0.4); border-color: var(--hit); }
.cell.lifted { opacity: 0.35; }
.cell.deny { animation: deny 0.3s ease; }
@keyframes deny { 0%, 100% { background: var(--water); } 50% { background: rgba(255, 77, 94, 0.6); } }

/* анимации событий */
.cell.anim-hit { animation: hit-pop 0.7s ease; z-index: 3; }
@keyframes hit-pop { 0% { transform: scale(0.6); box-shadow: 0 0 0 0 rgba(255, 154, 60, 0.9); } 40% { transform: scale(1.35); box-shadow: 0 0 0 10px rgba(255, 154, 60, 0); } 100% { transform: scale(1); } }
.cell.anim-miss { animation: miss-ripple 0.6s ease; }
@keyframes miss-ripple { 0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.8); } 100% { box-shadow: 0 0 0 12px rgba(var(--accent-rgb), 0); } }
.cell.anim-sunk { animation: sunk-flash 0.9s ease; z-index: 3; }
@keyframes sunk-flash { 0%, 40% { filter: brightness(2.2); transform: scale(1.1); } 100% { filter: none; transform: scale(1); } }
.cell.anim-scan { animation: scan 0.9s ease; }
@keyframes scan { 0% { background: rgba(255, 201, 77, 0); } 30% { background: rgba(255, 201, 77, 0.6); } 100% { background: var(--water); } }
.cell.anim-trail { animation: trail 0.5s ease; }
@keyframes trail { 0% { background: rgba(var(--accent-rgb), 0.9); } 100% { background: var(--water); } }

/* ---------- Расстановка ---------- */
.hint { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.35; }
.tray { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; touch-action: none; }
.tray-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); cursor: grab; transition: all 0.15s; user-select: none; -webkit-user-select: none;
}
.tray-item.selected { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.14); box-shadow: 0 0 16px -4px rgba(var(--accent-rgb), 0.6); }
.tray-item.empty { opacity: 0.3; cursor: default; }
.tray-item span { font-size: 12px; color: var(--muted); }
.tray-ship { display: flex; gap: 2px; }
.tray-ship i { width: 14px; height: 14px; border-radius: 3px; background: linear-gradient(160deg, #e6edff, var(--ship)); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); }
.tray-ship i:first-child { border-radius: 50% 3px 3px 50%; }
.tray-ship i:last-child { border-radius: 3px 50% 50% 3px; }
.tray-ship i:only-child { border-radius: 40%; }
.place-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.place-actions .btn { padding: 12px 8px; font-size: 13px; }

/* ---------- Бой ---------- */
#screen-battle { gap: 10px; }
#screen-battle.shake { animation: screen-shake 0.4s ease; }
@keyframes screen-shake { 0%, 100% { transform: translate(0); } 20% { transform: translate(-5px, 3px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-3px, 2px); } 80% { transform: translate(3px, -2px); } }
.battle-top { grid-template-columns: 44px 1fr 44px; }
.turn-info { text-align: center; }
.turn-label { font-weight: 800; font-size: 17px; color: var(--accent); transition: color 0.3s; }
.turn-label.enemy { color: var(--hit-2); }
.mode-label { font-size: 11px; }
.timer { position: relative; width: 44px; height: 44px; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 3; }
.tr-bg { stroke: rgba(255, 255, 255, 0.1); }
.tr-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.1s linear, stroke 0.3s; }
.timer.urgent .tr-fg { stroke: var(--hit); }
.timer.urgent span { color: var(--hit); animation: target-pulse 0.5s infinite; }
.timer span { font-size: 15px; }

.fleets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fleet { display: flex; flex-direction: column; gap: 5px; padding: 8px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.fleet small { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.fleet-ships { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.fs { display: flex; gap: 2px; }
.fs i { width: 8px; height: 8px; border-radius: 2px; background: var(--ship); opacity: 0.9; }
.fs i.dmg { background: var(--hit); box-shadow: 0 0 6px var(--hit); }
.fs.sunk i { background: rgba(255, 77, 94, 0.35); box-shadow: none; }

.battle-boards {
  display: grid; grid-template-columns: 38% 1fr; grid-template-areas: "enemy enemy" "own bottom"; gap: 12px; align-items: start;
  transition: filter 0.3s;
}
.battle-boards.blur { filter: blur(14px); pointer-events: none; }
.board-slot { position: relative; }
.enemy-slot { grid-area: enemy; }
.own-slot { grid-area: own; cursor: pointer; }
.battle-bottom { grid-area: bottom; }
.own-slot .board { border-color: rgba(255, 255, 255, 0.15); }
.own-slot .lbl { font-size: 0; }
.slot-cap { position: absolute; left: 0; right: 0; bottom: -16px; text-align: center; font-size: 10px; color: var(--muted); }
.battle-boards.view-own { grid-template-areas: "own own" "enemy bottom"; }
.battle-boards.view-own .own-slot .lbl { font-size: clamp(9px, 2.4vw, 12px); }
.battle-boards.view-own .enemy-slot .lbl { font-size: 0; }
.battle-boards.view-own .own-slot .board { border-color: rgba(var(--accent-rgb), 0.25); }
.battle-boards.view-own .enemy-slot .board { border-color: rgba(255, 255, 255, 0.15); }
.battle-boards.single { grid-template-areas: "enemy enemy" "bottom bottom"; }
.float-layer { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; overflow: visible; }
.float { position: absolute; font-weight: 800; font-size: 26px; text-transform: uppercase; letter-spacing: 0.04em; text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8); animation: float-up 1.1s ease forwards; white-space: nowrap; }
.float.hit { color: var(--hit-2); }
.float.sunk { color: var(--hit); font-size: 32px; }
.float.miss { color: var(--accent); font-size: 20px; }
@keyframes float-up { 0% { opacity: 0; transform: translateY(20px) scale(0.7); } 20% { opacity: 1; transform: translateY(0) scale(1.1); } 70% { opacity: 1; transform: translateY(-10px) scale(1); } 100% { opacity: 0; transform: translateY(-40px) scale(0.9); } }
.own-slot .float { font-size: 14px; }
.own-slot .float.sunk { font-size: 16px; }

.battle-bottom { display: flex; flex-direction: column; gap: 8px; min-height: 100%; }
.status-line { min-height: 36px; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.3; }
.fire-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: auto; }
.single .fire-row { justify-content: center; }
.single .status-line { min-height: 20px; }
.combo { font-size: 15px; color: var(--hit-2); font-weight: 800; text-shadow: 0 0 12px rgba(255, 154, 60, 0.6); }
.abilities { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ab { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); transition: all 0.15s; }
.ab.on { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.16); box-shadow: 0 0 16px -4px rgba(var(--accent-rgb), 0.7); }
.ab.empty { opacity: 0.4; }
.ab-icon { font-size: 20px; }
.ab-name { font-size: 11px; font-weight: 700; }
.ab-count { font-size: 11px; color: var(--accent); }

.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(7, 11, 22, 0.9); backdrop-filter: blur(6px); padding: 20px; }
.pass-card { width: 100%; max-width: 380px; text-align: center; display: flex; flex-direction: column; gap: 12px; padding: 30px 20px; border-radius: 24px; background: var(--bg-2); border: 1px solid var(--line); }
.pass-icon { font-size: 44px; }
.pass-card p { color: var(--muted); margin-bottom: 8px; }

/* ---------- Итоги ---------- */
.result-hero { text-align: center; padding: 26px 0 8px; }
.result-badge { font-size: 64px; line-height: 1; margin-bottom: 10px; animation: badge-in 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; filter: drop-shadow(0 10px 30px rgba(var(--accent-rgb), 0.5)); }
@keyframes badge-in { from { transform: scale(0.2) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.result-hero h2 { font-size: 34px; }
.result-hero.win h2 { background: linear-gradient(180deg, #fff, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-hero.lose h2 { color: var(--hit); }
.result-hero p { margin-top: 6px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); text-align: center; }
.stat b { font-size: 18px; }
.stat small { font-size: 11px; color: var(--muted); }
.events { display: flex; flex-direction: column; gap: 8px; }
.event { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.14), var(--surface)); border: 1px solid rgba(var(--accent-rgb), 0.35); animation: screen-in 0.4s ease both; }
.event .ev-icon { font-size: 26px; }
.event b { display: block; font-size: 14px; }
.event small { font-size: 12px; }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }

/* ---------- Профиль ---------- */
.profile-card { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; }
.profile-card b { font-size: 18px; }
.profile-card .xpbar { margin-top: 8px; }
.themes { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.theme-chip.on { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.14); }
.theme-chip.locked { opacity: 0.5; }
.theme-chip small { color: var(--muted); font-size: 11px; }
.swatch { width: 16px; height: 16px; border-radius: 50%; background: linear-gradient(135deg, var(--c1), var(--c2)); }
[data-theme-id='cyan'] .swatch { --c1: #29e0ff; --c2: #4f7cff; }
[data-theme-id='aurora'] .swatch { --c1: #b476ff; --c2: #5ee2ff; }
[data-theme-id='coral'] .swatch { --c1: #ff7a59; --c2: #ffc94d; }
[data-theme-id='radar'] .swatch { --c1: #3ef29a; --c2: #a6ff5e; }
[data-theme-id='gold'] .swatch { --c1: #ffd166; --c2: #ff8f5e; }
.achievements { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ach { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 10px 6px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); opacity: 0.45; }
.ach.got { opacity: 1; background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.16), rgba(0, 0, 0, 0.25)); border: 1px solid rgba(var(--accent-rgb), 0.35); }
.ach-icon { font-size: 24px; }
.ach b { font-size: 12px; line-height: 1.2; }
.ach small { font-size: 10px; color: var(--muted); line-height: 1.2; }
.daily-history { display: flex; flex-direction: column; gap: 6px; }
.dh-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.2); }

/* ---------- Настройки ---------- */
.settings { display: flex; flex-direction: column; gap: 4px; padding: 6px 16px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.setting:last-child { border-bottom: 0; }
.setting b { display: block; font-size: 15px; }
.setting small { display: block; font-size: 12px; }
.switch { position: relative; flex: none; width: 48px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, 0.12); transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }

/* ---------- Правила ---------- */
.howto { display: flex; flex-direction: column; gap: 10px; }
.howto h3 { font-size: 15px; color: var(--accent); margin-top: 6px; }
.howto p { font-size: 14px; color: #c6cfe3; line-height: 1.5; }

/* ---------- Тосты и модалка ---------- */
.toasts { position: fixed; top: calc(12px + var(--safe-top)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 11px 16px; border-radius: 14px; background: rgba(14, 20, 38, 0.95); border: 1px solid var(--line); font-size: 14px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); opacity: 0; transform: translateY(-12px); transition: all 0.3s ease; }
.toast.show { opacity: 1; transform: none; }
.toast.good { border-color: rgba(61, 220, 151, 0.5); }
.toast.bad { border-color: rgba(255, 77, 94, 0.5); }
.toast-icon { font-size: 18px; }
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); padding: 20px; }
.modal-card { width: 100%; max-width: 380px; padding: 22px; border-radius: 22px; background: var(--bg-2); border: 1px solid var(--line); animation: badge-in 0.3s ease both; }
.modal-card h3 { font-size: 20px; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- Широкие экраны ---------- */
@media (min-width: 820px) {
  #app { max-width: 560px; }
  #screen-battle, #screen-battle.active { max-width: 1040px; margin: 0 auto; width: 100%; }
  #app:has(#screen-battle.active) { max-width: 1040px; }
  .battle-boards { grid-template-columns: 1fr 1fr; grid-template-areas: "enemy own" "bottom bottom"; }
  .battle-boards.view-own { grid-template-areas: "enemy own" "bottom bottom"; }
  .own-slot .lbl, .battle-boards.view-own .enemy-slot .lbl { font-size: 12px; }
  .battle-boards.view-own .enemy-slot .board, .own-slot .board { border-color: rgba(var(--accent-rgb), 0.25); }
  .slot-cap { display: none; }
  .own-slot { cursor: default; }
  .battle-boards.single { grid-template-areas: "enemy enemy" "bottom bottom"; }
  .battle-boards.single .enemy-slot { width: 60%; margin: 0 auto; }
  .battle-bottom { flex-direction: row; align-items: center; justify-content: space-between; }
  .status-line { text-align: left; min-height: 0; flex: 1; }
  .abilities { flex: 0 0 340px; }
  .own-slot .float { font-size: 26px; }
  .cell.target { animation: none; }
}
@media (hover: hover) {
  .cell:hover { filter: brightness(1.25); }
  .btn:hover:not(:disabled) { filter: brightness(1.08); }
  .mode-card:hover, .card.action:hover { border-color: rgba(var(--accent-rgb), 0.5); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
