/* ============================================================================
   Общие игровые стили: доска, полосы игроков, панель действий, выбор отряда.
   Глобальные (не scoped): используются компонентом боя (Battle), PvP-страницей
   и просмотром реплея. Цвета — через переменные темы из app.css.
   ============================================================================ */

/* кнопки */
button.start { background: linear-gradient(180deg, #3a9540, #2f7d32); color: #fff; border: none; border-radius: 10px; padding: 10px 22px; font-size: 16px; cursor: pointer; font-weight: 700; box-shadow: 0 4px 14px #1c5a2055; transition: filter .12s, transform .12s; }
button.start:hover { filter: brightness(1.08); transform: translateY(-1px); }
button.start:disabled { opacity: .4; cursor: default; filter: none; transform: none; box-shadow: none; }
button.start.big { font-size: 20px; padding: 14px 36px; }
button.ghost { background: transparent; border: 1px solid var(--border2); color: var(--text-dim); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button.ghost:hover { border-color: var(--accent); }
button.ghost.sm { padding: 3px 9px; font-size: 12px; }

/* переключатель темы */
.theme-btn { background: transparent; border: 1px solid var(--border2); color: var(--text-dim); border-radius: 8px; padding: 3px 9px; font-size: 14px; cursor: pointer; }
.theme-btn:hover { border-color: var(--accent); }

/* ===== выбор отряда (стартовый экран и PvP) ===== */
.pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.pick { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 2px solid var(--border); border-radius: 10px; color: var(--text); padding: 8px; cursor: pointer; transition: .15s; }
.pick img { width: 42px; height: 42px; }
.pick span { font-size: 13px; text-align: left; }
.pick em { color: var(--text-soft); font-style: normal; display: block; font-size: 11px; }
.pick:hover { border-color: var(--border2); transform: translateY(-1px); }
.pick.on { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 10px var(--accent); }
.pick:disabled { opacity: .4; cursor: default; transform: none; }

.setup-bar { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.setup-bar label { color: var(--text-dim); font-size: 14px; }
.setup-bar select { padding: 6px 8px; border-radius: 8px; background: var(--panel2); color: var(--text); border: 1px solid var(--border2); }

/* карта юнита сбоку от сетки выбора */
.setup-main { display: flex; gap: 16px; align-items: flex-start; margin: 18px 0; }
.setup-main .pick-grid { flex: 1; margin: 0; }
.card-preview { flex: 0 0 240px; position: sticky; top: 12px; }
.card-preview img { width: 240px; border-radius: 14px; box-shadow: 0 4px 14px #0007; display: block; }
.card-hint { width: 236px; height: 332px; border: 2px dashed var(--border2); border-radius: 14px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--text-soft); font-size: 13px; line-height: 1.5; }

/* ===== общая раскладка партии ===== */
/* фракционные цвета: «моя» сторона золото, врага — серебро; при игре за ворона меняются местами */
.game { max-width: 1500px; margin: 6px auto; padding: 0 10px 10px; font-family: system-ui, sans-serif; color: var(--text);
        --me-ring: #e3bd4f; --foe-ring: #cfd6db; --me-loc: #e7cf86; --foe-loc: #aeb9c2; }
.game.human-crow { --me-ring: #cfd6db; --foe-ring: #e3bd4f; --me-loc: #aeb9c2; --foe-loc: #e7cf86; }
.mainrow { display: flex; gap: 16px; align-items: flex-start; justify-content: center; }

/* ===== полоса игрока ===== */
.strip { display: flex; align-items: stretch; gap: 0; background: var(--strip-bg); border: 1px solid var(--strip-bd); border-radius: 12px; padding: 6px 16px; margin: 8px 0; flex-wrap: wrap; }
.strip.me { border-color: var(--me-bd); background: var(--me-bg); }
.strip.foe { border-color: var(--foe-bd); background: var(--foe-bg); }
.who { display: flex; align-items: center; gap: 8px; min-width: 118px; padding: 0 18px 0 8px; }
.who .mk { width: 38px; height: 38px; }
.who .nm { font-weight: 700; font-size: 16px; }
.who .fac { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 1px 6px; border-radius: 8px; vertical-align: middle; }
.fac.f-wolf { color: #2a210e; background: linear-gradient(180deg, #f0d066, #c9a23e); }
.fac.f-crow { color: #11181d; background: linear-gradient(180deg, #cdd6dd, #9aa7b1); }
.who .ctl { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
.who .ini { width: 20px; height: 20px; filter: drop-shadow(0 0 4px #ffcf5a); }
.grp { display: flex; flex-direction: column; gap: 5px; justify-content: center; align-items: stretch; padding: 2px 34px; min-width: 50px; border-left: 1px solid var(--strip-bd); }
.grp .lbl { display: block; width: 100%; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-soft); text-align: center; }
.crow { display: flex; gap: 8px; align-items: center; justify-content: center; min-height: 40px; flex-wrap: wrap; }
.mini { position: relative; width: 34px; height: 34px; min-width: 34px; flex: 0 0 34px; }
.mini img { width: 34px; height: 34px; object-fit: cover; border-radius: 50%; display: block; }
.mini .cnt { position: absolute; right: -3px; bottom: -3px; background: var(--bg); color: var(--accent); border: 1px solid var(--accent); border-radius: 50%; min-width: 16px; height: 16px; line-height: 14px; text-align: center; font-size: 10px; font-weight: 700; padding: 0 2px; }
.mini.empty { opacity: .3; }
.mini.dead img { filter: grayscale(1) brightness(.6); }
.mini.recruitable img { box-shadow: 0 0 0 2px #3f9d4a, 0 0 8px #2f7d3266; }
.recruit-btn { position: absolute; top: -7px; right: -7px; width: 19px; height: 19px; padding: 0; line-height: 17px; text-align: center; border-radius: 50%; border: 1px solid #4f9d54; background: #2f7d32; color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; box-shadow: 0 1px 4px #0008; z-index: 3; transition: transform .1s, filter .1s; }
.recruit-btn:hover { filter: brightness(1.18); transform: scale(1.12); }
.bag { position: relative; width: 40px; height: 40px; min-width: 40px; flex: 0 0 40px; }
.bag img { width: 40px; height: 40px; object-fit: cover; display: block; }
.bag span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #1c1812; font-size: 14px; }
.disc { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; background: #00000025; border: 1px dashed var(--border2); display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-dim); }
.hand .handcoin { background: none; border: 2px solid transparent; border-radius: 50%; padding: 0; cursor: pointer; width: 48px; height: 48px; flex: 0 0 48px; box-sizing: border-box; }
.hand .handcoin img { width: 44px; height: 44px; object-fit: cover; border-radius: 50%; display: block; }
.hand .handcoin:hover:not(:disabled) { border-color: var(--border2); }
.hand .handcoin.on { border-color: var(--accent); box-shadow: 0 0 10px var(--accent); }
.hand .handcoin:disabled { cursor: default; }

/* ===== доска ===== */
.board-wrap { position: relative; flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; align-items: flex-start; }
.board { position: relative; background: radial-gradient(circle at 50% 35%, var(--board1) 0%, var(--board2) 70%, var(--board3) 100%); border-radius: 18px; box-shadow: inset 0 0 50px #0009, 0 10px 34px var(--shadow); border: 1px solid var(--board-edge); }
.hex { position: absolute; clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%); background: var(--hex); display: flex; align-items: center; justify-content: center; cursor: default; transition: background .12s, filter .12s; box-sizing: border-box; box-shadow: inset 0 0 0 2px var(--hex-ink), inset 0 -6px 10px #0000000d; }
.hex.loc { background: var(--hex-loc); }
.hex.ctrl0 { background: var(--me-loc); }    /* локация нижнего игрока (моя) */
.hex.ctrl1 { background: var(--foe-loc); }   /* локация соперника */
.hex.rad { box-shadow: inset 0 0 0 3px #ffd24a99; }       /* радиус способности */
.hex.hl { background: #93dd95; cursor: pointer; }
.hex.hl:hover { filter: brightness(1.08); }
.hex.sel { background: #ffe08a; }
.hex.last { filter: drop-shadow(0 0 7px #e24a4a) brightness(1.05); }
.locmark { height: 60%; aspect-ratio: 1; width: auto; object-fit: contain; pointer-events: none; filter: drop-shadow(0 2px 3px #0006); }
.piece { position: relative; height: 78%; aspect-ratio: 1; width: auto; cursor: pointer; }
.piece .face { width: 100%; height: 100%; border-radius: 50%; display: block; }
.piece.p0 .face { box-shadow: 0 0 0 4px var(--me-ring), 0 0 0 5px #00000050, 0 2px 6px #0008; }
.piece.p1 .face { box-shadow: 0 0 0 4px var(--foe-ring), 0 0 0 5px #00000060, 0 2px 6px #0008; }
.piece .coins { position: absolute; right: -4px; bottom: -4px; background: #1c1812; color: #ffe08a; border: 2px solid #ffe08a; border-radius: 50%; width: 22px; height: 22px; line-height: 18px; text-align: center; font-size: 13px; font-weight: 700; }
.piece .poison { position: absolute; left: -5px; top: -5px; width: 42%; height: 42%; border-radius: 50%; background: #1c1812; box-shadow: 0 0 0 2px #1c1812, 0 1px 3px #000a; pointer-events: none; }

/* ===== рельс инициативы (между доской и боковой панелью) ===== */
.init-rail { flex: 0 0 auto; align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 60px; }
.init-tok { width: calc(var(--ini-size, 36px) + 4px); height: calc(var(--ini-size, 36px) + 4px); border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--panel2); border: 2px solid var(--border2); box-shadow: 0 2px 8px #0007; transition: transform .12s, filter .12s, box-shadow .12s; }
.init-tok img { width: var(--ini-size, 36px); height: var(--ini-size, 36px); object-fit: cover; border-radius: 50%; filter: drop-shadow(0 1px 3px #000a); }
.init-tok.mine { border-color: var(--accent); }
.init-tok.foe { border-color: #c0584a; }
.init-tok.takeable { cursor: pointer; border-color: #4f9d54; box-shadow: 0 0 0 2px #2f7d3255, 0 0 14px #2f7d3299; animation: ini-pulse 1.4s ease-in-out infinite; }
.init-tok.takeable:hover { filter: brightness(1.15); transform: scale(1.07); animation: none; }
.init-cap { font-size: 11px; color: var(--text-soft); text-align: center; }
.init-tok.takeable + .init-cap { color: #6dc472; font-weight: 700; }
@keyframes ini-pulse { 0%, 100% { box-shadow: 0 0 0 2px #2f7d3255, 0 0 10px #2f7d3266; } 50% { box-shadow: 0 0 0 3px #2f7d3288, 0 0 18px #2f7d32cc; } }

/* ===== правая колонка: лог + действия ===== */
.side { width: 240px; flex: 0 0 240px; display: flex; flex-direction: column; gap: 10px; align-self: stretch; min-height: 0; max-height: calc(100vh - 220px); }
.log { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; flex: 1 1 auto; min-height: 120px; }
.log-head { display: flex; justify-content: space-between; align-items: center; color: var(--text-dim); font-weight: 700; margin-bottom: 6px; }
.log-lines { display: flex; flex-direction: column; gap: 3px; max-height: 300px; overflow-y: auto; }
.logline { font-size: 12px; color: var(--text); border-bottom: 1px solid var(--border); padding: 2px 0; }

.actions-panel { background: var(--panel2); border: 1px solid var(--border2); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; min-height: 0; overflow-y: auto; }
.ap-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--text-dim); margin-bottom: 2px; position: sticky; top: -8px; background: var(--panel2); padding-top: 8px; margin-top: -8px; z-index: 1; }
.act { display: block; width: 100%; text-align: left; background: var(--panel); color: var(--text); border: 1px solid var(--border2); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 14px; }
.act:hover { filter: brightness(1.1); border-color: var(--accent); }
.act.a-ctrl { background: #2f5d33; border-color: #3f7d44; color: #fff; }
.act.a-atk { background: #5d2f2f; border-color: #7d3f3f; color: #fff; }
.act.a-pass { opacity: .6; }
.clear { background: var(--border2); border: none; color: var(--text); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.hint { text-align: center; color: var(--text-soft); font-size: 14px; margin: 8px auto 0; }

/* ===== оверлеи ===== */
.overlay { position: absolute; inset: 8px; border-radius: 16px; background: #1a1510cc; color: #e8dcc0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 20px; z-index: 5; }
.overlay.win h2 { font-size: 34px; }
.spinner { width: 46px; height: 46px; border: 5px solid #5a4a2e; border-top-color: #ffe08a; border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== указы Nobility ===== */
.decrees { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; justify-content: center; }
.decree { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; background: var(--panel2); border: 1.5px solid var(--border); border-radius: 10px; padding: 6px; flex: 1 1 0; min-width: 0; transition: border-color .12s, transform .12s, box-shadow .12s, filter .12s; }
.decree .dthumb { width: 100%; max-width: 62px; aspect-ratio: 5 / 7; object-fit: cover; object-position: top; border-radius: 6px; box-shadow: 0 1px 4px #0007; }
.decree .dname { font-size: 10px; color: var(--text-dim); text-align: center; line-height: 1.1; }
.decree .seals { display: flex; gap: 4px; }
.decree .seals i { font-style: normal; font-size: 11px; opacity: .25; }
.decree .seals .s0 { color: var(--accent); }
.decree .seals .s1 { color: #c0584a; }
.decree .seals i.used { opacity: 1; }

/* указ можно огласить — подсветка как у действия */
.decree.actionable { cursor: pointer; border-color: #4f9d54; box-shadow: 0 0 0 1px #2f7d3255, 0 0 10px #2f7d3244; animation: decree-pulse 1.6s ease-in-out infinite; }
.decree.actionable:hover { transform: translateY(-2px); filter: brightness(1.07); animation: none; }
.decree.sel { cursor: pointer; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 12px #e3bd4f55; animation: none; }
.decree .dgo { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 50%; background: #2f7d32; color: #fff; font-size: 11px; font-weight: 700; box-shadow: 0 1px 4px #0008; }
@keyframes decree-pulse { 0%, 100% { box-shadow: 0 0 0 1px #2f7d3255, 0 0 8px #2f7d3233; } 50% { box-shadow: 0 0 0 1.5px #2f7d3288, 0 0 16px #2f7d3299; } }

/* читаемая карта указа по наведению (раскрывается влево, над доской) */
.decree-pop { position: absolute; top: 0; right: calc(100% + 12px); transform-origin: top right; transform: scale(.95);
              width: 240px; aspect-ratio: 5 / 7; object-fit: contain; border-radius: 14px;
              box-shadow: 0 12px 32px #000d, 0 0 0 1px #0007; opacity: 0; visibility: hidden; pointer-events: none;
              transition: opacity .14s ease, transform .14s ease; z-index: 60; }
.decree:hover .decree-pop { opacity: 1; visibility: visible; transform: scale(1); }

/* ============================================================
   Рейтинг · спектатор/комментатор · метки ходов · новые страницы
   (глобальные — применяются и в scoped-компонентах)
   ============================================================ */

/* --- финальный оверлей: дельта рейтинга --- */
.rank-delta { font-size: 15px; font-weight: 700; padding: 4px 12px; border-radius: 10px;
              background: #1c1812cc; border: 1px solid var(--border2); margin: 4px 0 2px; }
.rank-delta.up b { color: #6ad07a; }
.rank-delta.down b { color: #e88; }

/* --- плашка наблюдателя / комментатора над доской --- */
.spec-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 700;
            background: var(--panel); border: 1px solid var(--border2); border-radius: 10px;
            padding: 6px 14px; margin: 6px 0; color: var(--text); }
.spec-bar.cmt { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.spec-bar .sp-cnt { color: var(--text-soft); font-weight: 600; font-size: 13px; }
.cmt-eval { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; }
.cmt-track { position: relative; width: 160px; height: 12px; border-radius: 6px; overflow: hidden;
             background: linear-gradient(90deg, var(--foe-ring), var(--foe-ring)); border: 1px solid var(--border2); }
.cmt-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--me-ring); transition: width .3s ease; }
.cmt-pct { font-weight: 800; min-width: 38px; }
.cmt-best { color: var(--accent); font-weight: 700; }

/* --- страница поиска игры (/find) --- */
.find { max-width: 640px; margin: 0 auto; padding: 20px 16px; color: var(--text); font-family: system-ui, sans-serif; }
.find h1 { text-align: center; }
.find .sub { color: var(--text-soft); text-align: center; }
.find-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px;
             display: flex; flex-direction: column; gap: 14px; align-items: center; }
.find-card select { padding: 6px 10px; border-radius: 8px; background: var(--panel2); color: var(--text); border: 1px solid var(--border2); }
.fc-rating { font-size: 18px; } .fc-rating b { color: var(--accent); }
.fc-rating .rd, .rd { color: var(--text-soft); font-size: .8em; }
.find-searching { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px; }
.fs-info { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text); }
.fs-info b { color: var(--accent); }
.fs-hint { color: var(--text-soft); font-size: 13px; max-width: 360px; text-align: center; }
.find .err { color: #e88; }

/* --- наблюдение (/watch) --- */
.watch { max-width: 820px; margin: 0 auto; padding: 20px 16px; color: var(--text); font-family: system-ui, sans-serif; }
.watch .sub { color: var(--text-soft); }
.watch .empty, .leaderboard .empty, .find .empty { text-align: center; color: var(--text-soft); padding: 40px 0; }
.watch .games { display: flex; flex-direction: column; gap: 8px; }
.watch .game-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel);
                   border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.watch .host { font-weight: 700; } .watch .host i { color: var(--accent); margin: 0 4px; }
.watch .rs { color: var(--text-soft); font-size: 13px; }
.watch .rk { background: var(--accent); color: #17130b; font-weight: 700; font-size: 11px; padding: 1px 7px; border-radius: 8px; }
.watch .age { color: var(--text-soft); font-size: 12px; }
.watch .acts { margin-left: auto; display: flex; gap: 6px; }

/* --- лидерборд (/leaderboard) --- */
.leaderboard { max-width: 760px; margin: 0 auto; padding: 20px 16px; color: var(--text); font-family: system-ui, sans-serif; }
.leaderboard .sub { color: var(--text-soft); }
.lb-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.lb-table th, .lb-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.lb-table th { color: var(--text-soft); font-size: 13px; font-weight: 600; }
.lb-rank { color: var(--text-soft); width: 40px; }
.lb-name { font-weight: 700; }
.lb-rating { font-weight: 700; color: var(--accent); }
.lb-note { color: var(--text-soft); font-size: 12px; margin-top: 8px; }
