/* Clash of Khortytsia UI kit: dark oak frames, warm parchment, carved ornament strips,
   Dnipro-blue accents and gold highlights. Readable on a 6" phone. */
:root {
  --oak: #3b2414;
  --oak-2: #5a381e;
  --oak-3: #7a4c28;
  --parch: #f3e6c4;
  --parch-2: #e7d3a4;
  --parch-3: #d4bb83;
  --ink: #2d1b0e;
  --ink-soft: #6b5233;
  --gold: #f2c230;
  --gold-dark: #b8860b;
  --red: #b3261e;
  --red-2: #8a1a14;
  --dnipro: #2f7fb8;
  --dnipro-2: #1f5d8c;
  --green: #4f8f2f;
  --crystal: #49c6ec;
  --shadow: 0 6px 18px rgba(20, 10, 0, 0.45);
  --r: 12px;
  --font-title: 'Ruslan Display', 'Georgia', serif;
  --font: 'PT Sans', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6f9c45; font-family: var(--font); color: var(--ink); -webkit-tap-highlight-color: transparent; }
canvas#world { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; display: block; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
.center { text-align: center; justify-content: center; }
.good { color: #2f7a1f; }
.bad { color: var(--red); }
b { font-weight: 700; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ── buttons ── */
.btn {
  font: 700 14px var(--font); color: var(--ink); cursor: pointer; border-radius: 10px;
  padding: 8px 14px; border: 2px solid var(--oak); background: linear-gradient(#fbf2d9, var(--parch-2));
  box-shadow: 0 3px 0 var(--oak), inset 0 1px 0 #fff8; transition: transform .06s, filter .1s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover:not([disabled]) { filter: brightness(1.06); }
.btn:active:not([disabled]) { transform: translateY(2px); box-shadow: 0 1px 0 var(--oak); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(#7fc04a, #4f8f2f); color: #fff; text-shadow: 0 1px 1px #0006; }
.btn.primary .cost-item { color: #fff; }
.btn.primary .cost-item.short { color: #ffd0c8; }
.btn.crystal { background: linear-gradient(#8fe2ff, #2f9cc8); color: #08293a; }
.btn.danger { background: linear-gradient(#e36a5c, var(--red)); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--oak-3); }
.btn.ghost.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 7px; font-size: 11px; border-width: 1px; box-shadow: 0 2px 0 var(--oak); }
.btn.big { padding: 12px 22px; font-size: 18px; }
.btn.tab { background: var(--parch-3); box-shadow: none; border-radius: 10px 10px 0 0; }
.btn.tab.active { background: var(--parch); border-bottom-color: var(--parch); }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud-top { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; pointer-events: none; }
#hud-top > * { pointer-events: auto; }
.profile, .resources, .builders, .chip.shield {
  background: linear-gradient(var(--oak-2), var(--oak)); color: var(--parch); border: 2px solid #1d1008; border-radius: var(--r);
  box-shadow: var(--shadow); padding: 6px 10px; display: flex; align-items: center; gap: 10px;
}
.profile .muted { color: var(--parch-3); }
.council-badge { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(#ffe48a, var(--gold-dark)); color: var(--oak); font: 900 18px var(--font-title); display: grid; place-items: center; border: 2px solid #1d1008; }
.trophies { font-weight: 700; }
.resources { margin-left: auto; gap: 8px; }
.res-chip { display: flex; align-items: center; gap: 5px; min-width: 84px; }
.res-chip .res-text { display: flex; flex-direction: column; gap: 2px; min-width: 52px; }
.res-chip .progress { height: 5px; background: #0006; border: none; }
.res-chip .progress .fill { background: var(--gold); }
.res-chip.full b { color: #ffb4a8; }
.res-chip.crystals b { color: #aef0ff; }
.builders b { color: var(--gold); }

#hud-left, #hud-right { position: absolute; display: flex; flex-direction: column; gap: 8px; }
#hud-left { left: 10px; bottom: 12px; }
#hud-right { right: 10px; top: 76px; }
.hud-btn {
  position: relative; width: 66px; height: 62px; border-radius: 14px; cursor: pointer; border: 2px solid #1d1008;
  background: linear-gradient(var(--parch), var(--parch-3)); box-shadow: var(--shadow), inset 0 -3px 0 #0002; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: 700 11px var(--font); color: var(--ink);
}
.hud-btn .ico { font-size: 22px; line-height: 1; }
.hud-btn:active { transform: translateY(2px); }
.hud-btn .badge { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; border-radius: 10px; min-width: 20px; padding: 1px 6px; font-size: 12px; border: 2px solid #fff; }
#hud-right .hud-btn { width: 52px; height: 50px; font-size: 9px; }
#hud-right .hud-btn .ico { font-size: 18px; }
#hud-attack { position: absolute; right: 12px; bottom: 12px; }
.attack-btn {
  width: 118px; height: 104px; border-radius: 22px; border: 3px solid #1d1008; cursor: pointer; color: #fff; text-shadow: 0 2px 2px #0008;
  background: radial-gradient(circle at 50% 30%, #f05a3c, var(--red-2)); box-shadow: var(--shadow), inset 0 -5px 0 #0003; font: 400 18px var(--font-title);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.attack-btn .swords { font-size: 34px; }
.attack-btn:active { transform: translateY(3px); }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 194, 48, .9), var(--shadow); } 50% { box-shadow: 0 0 0 9px rgba(242, 194, 48, 0), var(--shadow); } }

#tutorial {
  position: absolute; top: 72px; left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100vw - 150px));
  background: var(--parch); border: 2px solid var(--oak); border-radius: var(--r); box-shadow: var(--shadow); padding: 8px 12px; display: flex; align-items: center; gap: 10px;
}
.tut-icon { font-size: 26px; }
.tut-text { display: flex; flex-direction: column; font-size: 13px; }

/* ── building sheet & place bar ── */
#sheet, #place-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 10px; width: min(640px, calc(100vw - 280px)); min-width: 300px;
  background: var(--parch); border: 3px solid var(--oak); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 12px; z-index: 5;
}
.sheet-inner { display: flex; gap: 12px; }
.sheet-icon { width: 96px; height: 110px; flex: 0 0 auto; }
.sheet-main { flex: 1; min-width: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h3 { margin: 0; font: 400 18px var(--font-title); }
.sheet-desc { margin: 4px 0 6px; font-size: 13px; color: var(--ink-soft); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.sheet-actions .progress { flex: 1 1 100%; }
.busy { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.timer { font-variant-numeric: tabular-nums; color: var(--dnipro-2); font-weight: 700; }
details.next { flex: 1 1 100%; font-size: 13px; }
details.next summary { cursor: pointer; color: var(--ink-soft); }
.hint { font-size: 12px; color: var(--red-2); }
.hint.good { color: var(--green); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 14px; font-size: 13px; }
.stat { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--parch-3); }
.stat .k { color: var(--ink-soft); }
.close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-soft); }
#place-bar { display: flex; align-items: center; gap: 10px; }
#place-bar .place-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
#place-bar.invalid .btn.primary { filter: grayscale(.8); }

/* ── panels ── */
#panels { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
/* isolation: each open window is its own layer, so a confirm opened over a panel is never painted through by
   the panel's z-indexed body. */
.shade { position: absolute; inset: 0; background: rgba(15, 8, 2, .45); display: grid; place-items: center; pointer-events: auto; animation: fade .15s; isolation: isolate; }
@keyframes fade { from { opacity: 0; } }
.panel {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--parch); border: 4px solid var(--oak); border-radius: 18px; box-shadow: 0 16px 40px #0009, inset 0 0 0 2px var(--gold-dark); overflow: hidden;
}
.panel.wide { width: min(980px, calc(100vw - 24px)); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 6px; background: linear-gradient(var(--oak-2), var(--oak)); color: var(--parch); }
.panel-head .close { color: var(--parch-2); }
.panel-title { margin: 0; font: 400 20px var(--font-title); letter-spacing: .5px; }
.ornament {
  height: 10px; flex: 0 0 auto;
  background:
    linear-gradient(135deg, transparent 33%, var(--red) 33% 50%, transparent 50% 83%, var(--red) 83%) 0 0 / 14px 10px,
    linear-gradient(45deg, transparent 33%, #1d1008 33% 50%, transparent 50% 83%, #1d1008 83%) 7px 0 / 14px 10px,
    var(--parch-2);
  border-bottom: 1px solid var(--oak-3);
}
.panel-body { padding: 12px 16px 16px; overflow: auto; }
.panel-body h3 { font: 400 17px var(--font-title); margin: 6px 0; }
.panel-body h4 { margin: 12px 0 6px; }
.panel.confirm { width: min(420px, calc(100vw - 24px)); }
.confirm-text { font-size: 15px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--oak); margin-bottom: 10px; flex-wrap: wrap; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.cards.heroes { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 10px 8px;
  background: linear-gradient(#fffaf0, var(--parch-2)); border: 2px solid var(--oak-3); border-radius: 12px; cursor: pointer; font: 13px var(--font); color: var(--ink);
}
button.card:hover:not([disabled]) { border-color: var(--gold-dark); box-shadow: 0 0 0 2px var(--gold) inset; }
.card.locked, .card.dim { filter: grayscale(.6); opacity: .8; cursor: default; }
.card-icon { width: 96px; height: 86px; }
.card-icon.big { width: 120px; height: 120px; border-radius: 12px; }
.card-icon.round, .mini.round, .b-portrait.round { border-radius: 50%; }
.troop .card-icon, .hero .card-icon { border-radius: 10px; border: 2px solid var(--oak-3); }
.troop .card-icon.clip { width: 120px; height: 150px; object-fit: cover; object-position: 50% 25%; background: #d9d4cc; display: block; margin: 0 auto; }
.hero .card-icon.clip { width: 140px; height: 180px; object-fit: cover; object-position: 50% 30%; background: #d9d4cc; display: block; margin: 0 auto; }
.card-name { font-weight: 700; }
.card-sub { font-size: 12px; color: var(--ink-soft); }
.mini-stats { font-size: 12px; font-variant-numeric: tabular-nums; }
.lock { font-size: 12px; color: var(--red-2); font-weight: 700; }
.ability { font-size: 12px; background: #fff7; border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 2px; border: 1px dashed var(--oak-3); }

.cost { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cost-item { display: inline-flex; gap: 3px; align-items: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.cost-item.short { color: var(--red); }
.res-icon { vertical-align: middle; }
.free { color: var(--green); font-weight: 700; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--parch-3); font-size: 12px; margin: 2px; }
.chip.small { font-size: 11px; }
.progress { position: relative; height: 16px; background: #0002; border-radius: 8px; overflow: hidden; border: 1px solid var(--oak-3); min-width: 80px; }
.progress .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#8fe2ff, var(--dnipro)); }
.progress span { position: relative; display: block; text-align: center; font-size: 11px; font-weight: 700; line-height: 14px; }

.army-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 8px; }
.army-head .progress { width: 180px; display: inline-block; vertical-align: middle; }
.queue { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0 8px; }
.q-item { position: relative; display: flex; flex-direction: column; align-items: center; font-size: 12px; }
.mini { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--oak-3); }
.q-item .x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: none; background: var(--red); color: #fff; cursor: pointer; line-height: 18px; padding: 0; }

.stars { color: #bfae8a; letter-spacing: 1px; font-size: 18px; }
.stars .on { color: var(--gold); text-shadow: 0 0 4px #b8860b; }

/* campaign */
.map-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 14px; }
.map { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; padding-right: 6px;
  background: linear-gradient(90deg, transparent 46%, #2f7fb855 46% 54%, transparent 54%); }
.region { font: 400 15px var(--font-title); color: var(--dnipro-2); margin-top: 6px; background: var(--parch); align-self: center; padding: 0 8px; }
.node { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 30px; border: 2px solid var(--oak-3); background: #fffaf0; cursor: pointer; font: 14px var(--font); width: 86%; align-self: center; }
.node .num { width: 26px; height: 26px; border-radius: 50%; background: var(--oak); color: var(--parch); display: grid; place-items: center; font-weight: 700; }
.node .nm { flex: 1; text-align: left; }
.node.done { background: #f4ffe4; }
.node.locked { opacity: .55; }
.node.sel { border-color: var(--gold-dark); box-shadow: 0 0 0 3px var(--gold); }
.map-detail { background: #fff8; border: 2px solid var(--oak-3); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.def-list { display: flex; flex-wrap: wrap; }

.attack-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px; border-radius: 14px; border: 2px solid var(--oak-3); background: #fffaf0; cursor: pointer; font: 14px var(--font); }
.mode-card:hover { border-color: var(--gold-dark); }
.mode-ico { font-size: 40px; }
.opponent { background: #fff8; border: 2px solid var(--oak-3); border-radius: 12px; padding: 10px; margin-bottom: 10px; }

.quests { display: flex; flex-direction: column; gap: 8px; }
.quest { padding: 8px; border-radius: 10px; border: 1px solid var(--parch-3); background: #fff6; display: flex; flex-direction: column; gap: 6px; }
.quest.ready { border-color: var(--green); background: #f1ffe6; }
.quest.claimed { opacity: .55; }
.q-text { display: flex; justify-content: space-between; gap: 6px; }

/* kurin */
.kurin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kurin-create { display: flex; flex-direction: column; gap: 8px; }
.kurin-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--parch-3); padding: 6px 0; }
.kurin-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.members { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; margin-bottom: 8px; }
.member { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.member .acts { margin-left: auto; display: flex; gap: 4px; }
.role { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--parch-3); }
.role.koshovyi { background: var(--gold); }
.role.starshyna { background: #f6d58a; }
.chat-col { display: flex; flex-direction: column; gap: 6px; }
.chat { height: 300px; overflow: auto; background: #fff9; border: 1px solid var(--oak-3); border-radius: 10px; padding: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.war-box { border: 2px solid var(--oak-3); border-radius: 12px; background: #fff7; padding: 8px 10px; margin: 8px 0 12px; display: flex; flex-direction: column; gap: 6px; }
.war-box > button { align-self: flex-start; }
.war-head { display: flex; align-items: center; gap: 8px; }
.war-head h4 { margin: 0; }
.war-head .chip.phase-battle { background: var(--red); color: #fff; }
.war-head .chip.phase-preparation { background: var(--gold); }
.war-score { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 15px; }
.war-stars { font-weight: 700; color: #b8860b; }
.war-vs { font-weight: 700; padding: 0 4px; }
.war-map h5 { margin: 4px 0; }
.war-base { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; padding: 3px 0; border-bottom: 1px dashed var(--parch-3); }
.war-base.me { background: #fff3c4; }
.war-base > :last-child { margin-left: auto; }
.war-pos { font-weight: 700; min-width: 28px; }
.war-result { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; background: var(--parch-3); }
.war-result.us { background: #e3f7d4; }
.war-result.them { background: #fbe0dc; }
.war-log { font-size: 12px; }
.war-attack { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.war-attack.mine { color: var(--dnipro-2); }
.msg.sys { color: var(--ink-soft); font-style: italic; font-size: 12px; }
.msg.me b { color: var(--dnipro-2); }
/* Report/block: a quiet ⋯ that is still a comfortable touch target. */
.msg { position: relative; padding-right: 30px; }
.msg-more { position: absolute; right: 0; top: -3px; width: 28px; height: 24px; border: 0; background: none; color: var(--ink-soft); font: 700 16px/1 sans-serif; cursor: pointer; opacity: .55; }
.msg-more:hover, .msg-more:focus-visible { opacity: 1; color: var(--red); }
.chat-note { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.chat-note p { margin: 0; }
.rules-list { margin: 6px 0 10px; padding-left: 22px; display: grid; gap: 6px; }
.report-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.report-quote blockquote { margin: 2px 0 8px; padding: 6px 10px; border-left: 3px solid var(--red); background: #fff8; font-style: italic; overflow-wrap: anywhere; }
.community { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.community h5 { margin: 6px 0 0; }
input, select {
  font: 15px var(--font); padding: 8px 10px; border-radius: 10px; border: 2px solid var(--oak-3); background: #fffdf6; color: var(--ink); min-width: 0; flex: 1;
}
input[type=checkbox] { flex: 0 0 auto; width: 18px; height: 18px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 5px 6px; border-bottom: 1px solid var(--parch-3); text-align: left; }
.table tr.me { background: #fff3c4; }
.log { display: flex; flex-direction: column; gap: 6px; }
.log-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px; border-radius: 8px; background: #fff6; font-size: 13px; }
.log-row.defense { border-left: 4px solid var(--dnipro); }
.log-row.attack { border-left: 4px solid var(--red); }

/* ── battle HUD ── */
#battle-hud { position: fixed; inset: 0; pointer-events: none; }
#battle-hud > * { pointer-events: auto; }
#battle-top { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.b-enemy, .b-center, .b-loot { background: rgba(30, 16, 6, .78); color: var(--parch); border-radius: 12px; padding: 6px 12px; border: 2px solid #1d1008; }
.b-enemy .muted, .b-loot .muted { color: var(--parch-3); }
.b-center { text-align: center; }
.b-timer { font: 400 22px var(--font-title); }
.b-timer.warn { color: #ff8a7a; }
.b-dest { font-size: 18px; }
#battle-hint { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); color: #fff; font-weight: 700; text-shadow: 0 2px 4px #000; pointer-events: none; text-align: center; }
#battle-bar { position: absolute; bottom: 8px; left: 8px; right: 8px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.b-card { position: relative; width: 74px; padding: 4px; border-radius: 12px; border: 2px solid #1d1008; background: linear-gradient(var(--parch), var(--parch-3)); cursor: pointer; display: flex; flex-direction: column; align-items: center; font: 11px var(--font); }
.b-card.sel { box-shadow: 0 0 0 3px var(--gold), 0 0 14px var(--gold); transform: translateY(-6px); }
.b-card.empty { filter: grayscale(1); opacity: .6; }
.b-card.hero { background: linear-gradient(#fff1b8, #d8ae4a); }
.b-portrait { width: 60px; height: 56px; border-radius: 8px; }
.b-card .cnt { position: absolute; top: 2px; right: 4px; font-weight: 700; background: #1d1008cc; color: #fff; border-radius: 8px; padding: 0 5px; }
.b-card .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 68px; }
.ab-btn { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(#fff3a0, var(--gold-dark)); border: 2px solid #1d1008; display: grid; place-items: center; font-weight: 700; font-size: 13px; cursor: pointer; animation: pulse 1s infinite; }
.ab-btn.cd { background: #777; color: #fff; animation: none; cursor: default; }
.ab-btn.dead { background: #444; color: #ccc; animation: none; }

.panel.result { text-align: center; }
.panel.result.won .panel-head { background: linear-gradient(#7fc04a, #3e7a22); }
.panel.result.lost .panel-head { background: linear-gradient(#8a5a4a, #4a2a20); }
.result-stars .stars { font-size: 56px; }
.result-dest { font-size: 20px; font-weight: 700; margin: 6px 0 12px; }

/* ── welcome / loading ── */
#welcome, #loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30;
  background: radial-gradient(circle at 50% 30%, #5f8fb8 0%, #2f5f8a 40%, #1b2f22 100%); }
#loading { color: var(--parch); text-align: center; }
#welcome-bg { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 29; pointer-events: none;
  background: radial-gradient(circle at 50% 30%, #5f8fb8 0%, #2f5f8a 40%, #1b2f22 100%); }
/* the card sits over the video; a soft vignette keeps it readable */
#welcome-bg:not(.hidden) + #welcome { background: radial-gradient(ellipse at 50% 50%, #0000 35%, #0008 100%); }
.logo-title { font: 400 clamp(28px, 6vw, 52px) var(--font-title); color: var(--gold); text-shadow: 0 3px 0 var(--oak), 0 6px 14px #000a; letter-spacing: 1px; text-align: center; }
.welcome-card { width: min(460px, calc(100vw - 28px)); background: var(--parch); border: 4px solid var(--oak); border-radius: 20px; box-shadow: 0 20px 50px #000a; padding: 22px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.welcome-card .logo-title { font-size: clamp(26px, 6vw, 38px); }
/* carved oak frame with rushnyky (art/ui/slice_auth.py): 9-slice of corners + repeating bars, emblems laid on top.
   --fs scales the source pixels; border widths are the source slices 250 143 200 145. */
.welcome-card {
  --fs: .36; --ft: calc(250px * var(--fs)); --fr: calc(143px * var(--fs)); --fb: calc(200px * var(--fs)); --fl: calc(145px * var(--fs));
  position: relative; width: min(480px, calc(100vw - 16px)); padding: 0 8px;
  border-style: solid; border-color: transparent; border-width: var(--ft) var(--fr) var(--fb) var(--fl); border-radius: 0;
  border-image: url(/assets/ui/auth/frame9.webp) 250 143 200 145 round;
  background: url(/assets/ui/auth/parchment.webp) center / cover; background-clip: padding-box;
  box-shadow: none; filter: drop-shadow(0 16px 22px #000b);
}
.welcome-card::before {
  content: ''; position: absolute; pointer-events: none;
  inset: calc(-1 * var(--ft)) calc(-1 * var(--fr)) calc(-1 * var(--fb)) calc(-1 * var(--fl));
  background:
    url(/assets/ui/auth/shield.webp) top center / calc(253px * var(--fs)) auto no-repeat,
    url(/assets/ui/auth/medallion.webp) bottom center / calc(235px * var(--fs)) auto no-repeat,
    url(/assets/ui/auth/bolt.webp) left calc(22px * var(--fs)) center / calc(54px * var(--fs)) auto no-repeat,
    url(/assets/ui/auth/bolt.webp) right calc(18px * var(--fs)) center / calc(54px * var(--fs)) auto no-repeat;
}
/* green carved plank: caps + centre ornament + stretched plain strip (the strip is uniform across, so it can stretch) */
.btn.auth {
  --cap: calc(var(--h) * 92 / 160); --h: 64px;
  height: var(--h); padding: 0 calc(var(--cap) + 4px); justify-content: center; border: 0; border-radius: 0; box-shadow: none;
  font-size: 20px; color: #fff8e0; text-shadow: 0 2px 0 #23430f, 0 0 6px #000c;
  background:
    url(/assets/ui/auth/btn_l.webp) left / auto 100% no-repeat,
    url(/assets/ui/auth/btn_r.webp) right / auto 100% no-repeat,
    url(/assets/ui/auth/btn_c.webp) center / auto 100% no-repeat,
    url(/assets/ui/auth/btn_fill.webp) center / calc(100% - 2 * var(--cap) + 4px) 100% no-repeat;
  filter: drop-shadow(0 3px 2px #0009);
}
.btn.auth:hover:not([disabled]) { filter: drop-shadow(0 3px 2px #0009) brightness(1.08); }
.btn.auth:active:not([disabled]) { box-shadow: none; }
@media (max-width: 520px) { .welcome-card { --fs: .27; } .btn.auth { --h: 56px; font-size: 18px; } }
.slogan { font: 400 15px var(--font-title); color: var(--red-2); }
.lang-switch { display: flex; gap: 6px; justify-content: center; }
.loading-dots { padding: 20px; text-align: center; }

/* ── toasts ── */
#toasts { position: fixed; top: 132px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: rgba(30, 16, 6, .92); color: var(--parch); padding: 8px 16px; border-radius: 10px; border: 2px solid var(--gold-dark); font-weight: 700; transition: opacity .5s, transform .5s; max-width: 90vw; text-align: center; }
.toast.error { border-color: var(--red); color: #ffd6cf; }
.toast.good { border-color: #7fc04a; color: #e6ffd0; }
.toast.out { opacity: 0; transform: translateY(-10px); }

/* ── phones ── */
@media (max-width: 760px) {
  #hud-top { gap: 6px; }
  .profile { padding: 4px 8px; gap: 6px; }
  .profile .muted { display: none; }
  .resources { margin-left: 0; width: 100%; justify-content: space-between; padding: 4px 8px; }
  .res-chip { min-width: 0; }
  .res-chip .res-text { min-width: 40px; }
  .builders { padding: 4px 8px; }
  #tutorial { top: 116px; left: 8px; right: 72px; transform: none; max-width: none; }
  #hud-right { top: 120px; }
  .hud-btn { width: 56px; height: 54px; }
  .attack-btn { width: 92px; height: 84px; font-size: 15px; }
  #sheet, #place-bar { width: calc(100vw - 16px); min-width: 0; bottom: 6px; z-index: 6; }
  .sheet-icon { display: none; }
  .map-wrap, .kurin-cols, .attack-menu { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  #battle-top { flex-wrap: wrap; }
  .b-enemy { display: none; }
  .b-card { width: 62px; }
  .b-portrait { width: 50px; height: 46px; }
}

/* Crystal shop */
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin: 8px 0; }
.shop > .hint, .shop > .loading-dots { grid-column: 1 / -1; }
.shop-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px 10px; border-radius: var(--r); border: 2px solid var(--parch-3); background: #fff6; text-align: center; }
.shop-item.badge-popular, .shop-item.badge-starter { border-color: var(--crystal); }
.shop-item.badge-best { border-color: var(--gold-dark); background: #fff3d0; }
.shop-item.owned { opacity: .55; }
.shop-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--crystal); color: #fff; font-weight: 700; }
.badge-best .shop-badge { background: var(--gold-dark); }
.shop-amount { display: flex; align-items: center; gap: 6px; font-size: 22px; }
.shop-bonus { color: var(--green); font-weight: 700; font-size: 13px; }
.shop-free { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-radius: 10px; background: var(--parch-2); font-size: 13px; }
