/* ================= Menus, settings, controls ================= */
#game3d { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

/* ?cover — clean key art for the Telegram app card (640x360) */
body.cover #title-screen { flex-direction: row; gap: 28px; background: radial-gradient(ellipse at 40% 50%, rgba(20, 10, 30, .1) 0%, rgba(8, 5, 12, .55) 60%, rgba(5, 3, 7, .9) 100%); }
body.cover #title-screen .menu, body.cover .ver { display: none; }
body.cover .logo { font-size: 46px; text-align: left; }
body.cover .logo span { font-size: 15px; margin-top: 12px; color: #ffb06a; letter-spacing: 2px; }
body.cover .title-hero { width: 150px; height: 150px; animation: none; }
.overlay { z-index: 25; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
#confirm { z-index: 28; }

/* Pause button */
.mini-btn {
  right: calc(134px + var(--sa-r)); top: calc(8px + var(--sa-t)); width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center; gap: 5px; box-shadow: 0 0 0 2px #000;
}
.mini-btn i { width: 5px; height: 16px; background: var(--gold); border-radius: 1px; box-shadow: 0 1px 0 #000; }
.mini-btn:active { transform: scale(.92); }
#map-box { cursor: pointer; pointer-events: auto; }
#map-box:active { transform: scale(.97); }

#portrait { position: relative; overflow: visible; }
#portrait img { border-radius: 2px; }
#lvl-badge {
  position: absolute; right: -7px; bottom: -7px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px;
  background: linear-gradient(#ffd86a, #c8921e); color: #2a1a05; font-size: 11px; line-height: 18px; text-align: center;
  border: 1px solid #000; box-shadow: 0 2px 0 rgba(0, 0, 0, .5);
}

/* Radial cooldowns */
.act .cd, .belt-btn .cd {
  inset: 0; height: auto !important; border-radius: inherit;
  background: conic-gradient(rgba(0, 0, 0, .7) calc(var(--p, 0) * 1%), transparent 0);
}
.belt-btn .cd { border-radius: 4px; }
.act .cdt {
  position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  font-style: normal; font-weight: 700; font-size: 20px; color: #fff; text-shadow: 0 2px 0 #000, 0 0 4px #000; pointer-events: none;
}

/* Button size presets */
#actions, #belt { transition: transform .2s; }
body[data-btn="s"] #actions { transform: scale(.85); transform-origin: right bottom; }
body[data-btn="l"] #actions { transform: scale(1.15); transform-origin: right bottom; }
body[data-btn="l"] #belt { bottom: calc(232px + var(--sa-b)); }
body[data-btn="s"] #belt { bottom: calc(180px + var(--sa-b)); }

/* Left-handed: mirror the action cluster */
body.lefty #actions { right: auto; left: calc(12px + var(--sa-l)); transform-origin: left bottom; }
body.lefty #btn-attack { right: auto; left: 0; }
body.lefty #btn-s1 { right: auto; left: 94px; }
body.lefty #btn-s2 { right: auto; left: 78px; }
body.lefty #btn-dash { right: auto; left: 10px; }
body.lefty #belt { right: auto; left: calc(12px + var(--sa-l)); }

/* Coach marks */
#coach {
  position: absolute; z-index: 6; max-width: min(240px, 58vw); padding: 10px 14px; border-radius: 8px;
  background: #fff6dc; color: #2a1d10; font-size: 14px; font-weight: 700; line-height: 1.3; pointer-events: none;
  box-shadow: 0 0 0 2px #000, 0 6px 16px rgba(0, 0, 0, .5);
  animation: coachIn .35s cubic-bezier(.2, 1.5, .4, 1), bob 1.6s ease-in-out .35s infinite;
}
#coach::after {
  content: ''; position: absolute; left: var(--ax, 50%); bottom: -9px; margin-left: -9px;
  border: 9px solid transparent; border-bottom: 0; border-top-color: #fff6dc;
}
@keyframes coachIn { from { opacity: 0; transform: translateY(10px) scale(.9); } }
@keyframes bob { 50% { transform: translateY(-5px); } }
.coach-target { animation: target 1.2s ease-in-out infinite !important; }
#joy.coach-target { opacity: 1; }
@keyframes target { 50% { filter: drop-shadow(0 0 10px rgba(255, 230, 140, .95)) brightness(1.25); } }

/* Buttons */
.btn.alt { background: linear-gradient(#4a3b56, #2c2236); }
.btn.danger { background: linear-gradient(#c9433f, #8a1f22); }
.btn.square { min-width: 0; flex: 1; font-size: 13px; padding: 11px 10px; }
.row { display: flex; gap: 8px; width: 100%; }
.chip {
  padding: 7px 10px; border-radius: 16px; font-size: 12px; font-weight: 700; color: #e8dcc4;
  background: #2a2131; border: 1px solid #4a3b2a; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.chip:active { transform: scale(.95); background: #3a2e44; }
.chip.wide { width: 100%; margin-top: 14px; }
.inv-tools { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.inv-tools .chip { flex: 1; white-space: nowrap; }
.shop .btn b { color: #fff; margin-right: 2px; }

/* Menu panels */
.menu-panel { width: min(92vw, 360px); display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 24px); overflow-y: auto; touch-action: pan-y; }
.menu-panel .btn.big { min-width: 0; width: 100%; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 4px; }
.mini-stats span { background: rgba(0, 0, 0, .3); border-radius: 5px; padding: 6px 8px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.mini-stats b { color: var(--text); }

.set-group { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); margin-top: 6px; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 6px; background: rgba(0, 0, 0, .25); cursor: pointer; }
.set > span { font-size: 14px; display: flex; flex-direction: column; }
.set small { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.set input { display: none; }
.sw { flex: none; width: 44px; height: 24px; border-radius: 12px; background: #3a3040; position: relative; transition: background .2s; box-shadow: inset 0 0 0 1px #000; }
.sw::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #cfc4b0; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.set input:checked + .sw { background: #5a8f3a; }
.set input:checked + .sw::after { transform: translateX(20px); background: #fff; }
.seg { display: flex; background: #1a1420; border-radius: 6px; padding: 2px; box-shadow: inset 0 0 0 1px #000; }
.seg button { width: 38px; height: 28px; border-radius: 4px; font-weight: 700; color: var(--muted); }
.seg button.on { background: linear-gradient(#7a5cd6, #4b2fa0); color: #fff; }

.help-row { display: flex; gap: 12px; align-items: flex-start; }
.help-row p { font-size: 13px; color: #cfc2ab; line-height: 1.4; }
.help-row p b { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
.hi { flex: none; width: 44px; height: 44px; border-radius: 8px; background: radial-gradient(circle at 50% 35%, #463852, #1a1420); border: 2px solid #8a7444; display: flex; align-items: center; justify-content: center; }
.hi img { width: 30px; height: 30px; }
.joy-ic::after { content: ''; width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, .5); box-shadow: 0 0 0 7px rgba(255, 255, 255, .12); }

.map-panel { width: min(96vw, 420px); }
#bigmap-cv { width: 100%; aspect-ratio: 1; display: block; background: #0a080d; border: 1px solid #000; border-radius: 4px; image-rendering: pixelated; }
.legend { display: flex; justify-content: space-around; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; vertical-align: middle; }

.confirm-panel { text-align: center; }
.confirm-panel p { font-size: 15px; line-height: 1.4; margin: 6px 0 8px; }
.confirm-panel .btn { flex: 1; }

.tt-verdict { margin-top: 8px; font-size: 13px; font-weight: 700; text-align: center; padding: 5px; border-radius: 4px; background: rgba(0, 0, 0, .25); }
.tt-verdict.up { color: #5ee37a; }
.tt-verdict.down { color: #ff7a7a; }
.tt-verdict:empty { display: none; }

/* Title & death */
#title-screen .menu { width: min(86vw, 320px); }
#title-screen .btn.big { width: 100%; min-width: 0; }
.ver { position: absolute; bottom: calc(12px + var(--sa-b)); font-size: 11px; color: rgba(255, 255, 255, .3); }
.death-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(90vw, 360px); }
.death-stats div { background: rgba(0, 0, 0, .4); border: 1px solid #5a1a1a; border-radius: 6px; padding: 8px 4px; display: flex; flex-direction: column; gap: 2px; }
.death-stats b { font-size: 20px; color: #fff; }
.death-stats span { font-size: 11px; color: var(--muted); }
.death-stats p { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: 4px; }
#death-screen .menu { width: min(86vw, 320px); }
#death-screen .btn { width: 100%; min-width: 0; }

/* ================= Camp & forge ================= */
#tooltip { z-index: 27; }
#btn-ctx {
  position: absolute; left: 50%; bottom: calc(230px + var(--sa-b)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 10px 20px 10px 12px; border-radius: 28px;
  background: linear-gradient(#ffcf6a, #d8921e); color: #2a1605; font-weight: 700; font-size: 16px;
  border: 2px solid #000; box-shadow: 0 0 0 2px #ffe9b0, 0 6px 18px rgba(0, 0, 0, .5), 0 0 24px rgba(255, 190, 80, .5);
  pointer-events: auto; z-index: 4;
}
#btn-ctx img { width: 30px; height: 30px; }
#btn-ctx.pop { animation: ctxPop .35s cubic-bezier(.2, 1.6, .4, 1), ctxPulse 1.6s ease-in-out .35s infinite; }
#btn-ctx.pressed { transform: translateX(-50%) scale(.94); }
@keyframes ctxPop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
@keyframes ctxPulse { 50% { box-shadow: 0 0 0 2px #ffe9b0, 0 6px 18px rgba(0, 0, 0, .5), 0 0 36px rgba(255, 190, 80, .85); } }

.res-bar, .res-inline { display: flex; gap: 12px; justify-content: center; font-weight: 700; font-size: 14px; }
.res-bar { background: rgba(0, 0, 0, .3); border-radius: 6px; padding: 6px; margin-bottom: 10px; }
.res-bar span, .res-inline span { display: inline-flex; align-items: center; gap: 3px; }
.res-bar img, .res-inline img { width: 20px; height: 20px; }
.res-inline { font-size: 12px; gap: 8px; }
.res-inline img { width: 16px; height: 16px; }
.ore { color: #ffb070; }
.ess { color: #d9a0ff; }

.forge-panel { width: min(96vw, 420px); max-height: calc(100vh - 24px); overflow-y: auto; touch-action: pan-y; }
.title-ic { width: 22px; height: 22px; vertical-align: -5px; margin-right: 6px; }
.tabs { display: flex; gap: 4px; background: #120d16; border-radius: 8px; padding: 3px; margin-bottom: 10px; box-shadow: inset 0 0 0 1px #000; }
.tabs button { flex: 1; padding: 8px 4px; border-radius: 6px; font-weight: 700; font-size: 13px; color: var(--muted); }
.tabs button.on { background: linear-gradient(#e0a83a, #a8681a); color: #2a1605; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); }

.forge-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 10px; }
.forge-grid .slot[data-sel] { outline: 2px solid #ffd86a; outline-offset: 1px; box-shadow: 0 0 12px rgba(255, 216, 106, .6); }
.slot .plus { position: absolute; left: 2px; bottom: 1px; font-style: normal; font-size: 10px; font-weight: 700; color: #ffd86a; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
.slot .eqd { position: absolute; right: 1px; top: 1px; font-style: normal; font-size: 7px; color: #5ee37a; text-shadow: 0 1px 0 #000; }

.forge-card { position: relative; background: rgba(0, 0, 0, .3); border: 1px solid var(--rc); border-radius: 8px; padding: 10px; overflow: visible; }
.fc-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.fc-head .slot { width: 54px; flex: none; }
.fc-name { font-weight: 700; font-size: 15px; }
.fc-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.plus-track { display: flex; gap: 3px; margin: 4px 0 8px; }
.plus-track i { flex: 1; height: 6px; border-radius: 3px; background: #2a2230; box-shadow: inset 0 0 0 1px #000; }
.plus-track i.on { background: linear-gradient(#ffe08a, #e0a020); box-shadow: 0 0 6px rgba(255, 200, 80, .6); }
.up-row { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 0; }
.up-row b { width: 16px; text-align: center; }
.up-row span { flex: 1; }
.up-row em { font-style: normal; color: var(--muted); }
.up-row i { font-style: normal; color: var(--muted); }
.up-row strong { color: #5ee37a; min-width: 36px; text-align: right; }
.cost { display: flex; gap: 12px; justify-content: center; margin: 10px 0 8px; font-weight: 700; }
.cost span { display: inline-flex; align-items: center; gap: 3px; }
.cost img { width: 20px; height: 20px; }
.cost .lack { color: #ff6a6a; }
.forge-btn { width: 100%; min-width: 0; background: linear-gradient(#e0a83a, #a8681a); color: #2a1605; text-shadow: none; }
.forge-btn:disabled, .btn:disabled { filter: grayscale(1) brightness(.6); cursor: default; }
.fc-max { text-align: center; color: #ffd86a; font-weight: 700; margin-top: 8px; }
.forge-empty, .forge-note { text-align: center; color: var(--muted); font-size: 12px; margin: 6px 0 10px; }
.wide-btn { width: 100%; }

.slot-picks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 10px; }
.slot-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 6px; background: #1d1622; border: 2px solid #3b3022; font-size: 9px; color: var(--muted); }
.slot-pick img { width: 30px; height: 30px; }
.slot-pick.on { border-color: #ffd86a; color: #ffd86a; background: #2a2016; }
.craft-card { position: relative; background: rgba(0, 0, 0, .3); border: 1px solid #5ee37a55; border-radius: 8px; padding: 10px; margin-bottom: 8px; text-align: center; }
.craft-card.master { border-color: #c77dff88; background: linear-gradient(rgba(120, 60, 180, .15), rgba(0, 0, 0, .3)); }
.cc-title { font-weight: 700; font-size: 15px; }
.craft-card.master .cc-title { color: #d9a0ff; }
.cc-desc { font-size: 11px; color: var(--muted); }

.forged { animation: forged .45s ease-out; }
@keyframes forged { 0% { box-shadow: 0 0 0 0 rgba(255, 220, 120, .9), inset 0 0 40px rgba(255, 200, 80, .7); transform: scale(1.03); } 30% { transform: translateX(-3px); } 60% { transform: translateX(3px); } 100% { box-shadow: 0 0 0 14px rgba(255, 220, 120, 0); transform: none; } }
.spark { position: absolute; left: 50%; top: 40%; width: 5px; height: 5px; border-radius: 1px; background: #ffe08a; box-shadow: 0 0 6px #ffb040; pointer-events: none; animation: spark .7s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }

.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-list .btn.big { width: 100%; min-width: 0; }

/* ================= Hero select ================= */
#select-screen { justify-content: flex-start; gap: 0; padding: calc(14px + var(--sa-t)) 12px calc(12px + var(--sa-b)); background: linear-gradient(rgba(5, 3, 8, .6), rgba(5, 3, 8, 0) 18%, rgba(5, 3, 8, 0) 42%, rgba(5, 3, 8, .92) 60%); }
.sel-back { position: absolute; left: 12px; top: calc(12px + var(--sa-t)); width: 40px; height: 40px; border-radius: 8px; background: var(--panel); border: 2px solid var(--frame); font-size: 20px; color: var(--gold); z-index: 2; }
.sel-title { font-family: 'Rubik', system-ui, sans-serif; font-weight: 900; font-size: 24px; color: #f2d27a; text-shadow: 0 3px 0 #6b3a0f, 0 5px 0 #000; margin-top: 8px; }
.sel-spacer { flex: 1; min-height: 40vh; }
.sel-panel { width: min(96vw, 440px); text-align: left; padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 56vh; overflow-y: auto; touch-action: pan-y; }
.sel-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sel-tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 8px; background: #1d1622; border: 2px solid #3b3022; font-weight: 700; font-size: 13px; color: var(--muted); }
.sel-tabs button img { width: 30px; height: 30px; }
.sel-tabs button.on { border-color: var(--cc); color: #fff; background: linear-gradient(rgba(255, 255, 255, .06), rgba(0, 0, 0, .2)); box-shadow: 0 0 14px color-mix(in srgb, var(--cc) 45%, transparent); }
.sel-role { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.sel-desc { font-size: 13px; color: #d8cbb4; line-height: 1.35; }
.sel-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.sb { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.sb i { display: flex; gap: 2px; }
.sb b { width: 12px; height: 7px; border-radius: 2px; background: #2a2230; box-shadow: inset 0 0 0 1px #000; }
.sb b.on { background: linear-gradient(#ffe08a, #e0a020); }
.sel-attack { font-size: 12px; color: #cfc2ab; background: rgba(0, 0, 0, .25); border-radius: 5px; padding: 5px 8px; }
.sel-skills { display: flex; flex-direction: column; gap: 6px; }
.sk { display: flex; gap: 8px; align-items: flex-start; }
.sk img { width: 34px; height: 34px; flex: none; border-radius: 6px; background: radial-gradient(circle at 50% 35%, #463852, #1a1420); border: 2px solid #8a7444; padding: 3px; }
.sk b { font-size: 13px; }
.sk em { font-style: normal; font-size: 11px; color: #9cc4ff; }
.sk p { font-size: 12px; color: #cfc2ab; line-height: 1.3; }
#sel-go { width: 100%; min-width: 0; background: linear-gradient(color-mix(in srgb, var(--cc, #7a5cd6) 85%, #fff), color-mix(in srgb, var(--cc, #7a5cd6) 70%, #000)); color: #12081a; text-shadow: none; }
.tt-cls { font-size: 11px; margin-top: 2px; color: #5ee37a; }
.tt-cls.bad { color: #ff6a6a; }
