/* app.css: layout and components. Colours and fonts come from theme.css. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font-body); -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.02em; margin: 0 0 8px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.icon { display: inline-flex; width: 18px; height: 18px; flex: none; }
.icon svg { width: 100%; height: 100%; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------------------------------------------------------------- frames and buttons */

.frame {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(255, 220, 160, 0.08), var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 16px; min-height: 36px;
  border: 1px solid #6a5232; border-radius: 8px;
  background: linear-gradient(180deg, #4a3f5e, #2f2840);
  box-shadow: inset 0 1px 0 rgba(255, 235, 200, 0.18), 0 2px 0 rgba(0, 0, 0, 0.45);
  color: var(--text); font: 700 14px var(--font-display); letter-spacing: 0.02em;
  cursor: pointer; white-space: nowrap; user-select: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 235, 200, 0.1); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { border-color: #b8894a; background: linear-gradient(180deg, #c9883a, #8c5520); color: #fff6e2; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
.btn.gold { border-color: #8a6a2a; background: linear-gradient(180deg, #5a4520, #3a2c14); color: #ffe6a8; }
.btn.echo { border-color: #8d6fd0; background: linear-gradient(180deg, #5d4790, #3a2b62); }
.btn.danger { border-color: #a8473a; background: linear-gradient(180deg, #7a3328, #4f1f19); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { padding: 10px 24px; min-height: 44px; font-size: 16px; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.icon-only { padding: 0; width: 30px; min-height: 30px; }
.btn .cost { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; font-family: var(--font-ui); font-weight: 700; }
.btn .icon { width: 16px; height: 16px; }

input:not([type=checkbox]) {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #120f1b; color: var(--text); font: 15px var(--font-ui);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }

.bar { position: relative; height: 18px; border-radius: 9px; background: #120f1b; border: 1px solid var(--line); overflow: hidden; margin: 6px 0; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #a8692a, var(--gold)); }
.bar > span { position: relative; display: block; text-align: center; font: 700 11px/16px var(--font-ui); text-shadow: 0 1px 2px #000; }

.badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--alert); border: 2px solid #2a120d; color: #fff;
  font: 800 12px/16px var(--font-ui); text-align: center;
}
.tag { display: inline-block; padding: 0 5px; border-radius: 4px; background: #3a2f22; color: var(--accent); font: 800 11px/17px var(--font-ui); letter-spacing: 0.05em; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; cursor: pointer; font: 700 13px var(--font-ui); }
.seg button.on { background: var(--panel-3); color: var(--text); }
.done-tag { color: var(--gold); font-weight: 700; white-space: nowrap; }

/* ---------------------------------------------------------------- HUD */

.hud-top { position: fixed; z-index: 30; top: 0; left: 0; right: 0; height: var(--hud-top); display: flex; align-items: center; gap: 16px; padding: 8px 14px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.profile { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.avatar { position: relative; width: 60px; height: 60px; flex: none; border-radius: 50%; border: 3px solid var(--gold-edge); background: radial-gradient(circle at 50% 35%, #4a3f66, #1a1626); box-shadow: 0 0 0 2px #2a1d10, 0 4px 14px rgba(0, 0, 0, 0.6); }
.avatar-clip { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.avatar-clip img { position: absolute; width: 165%; left: -33%; top: -6%; }
.avatar .level {
  position: absolute; right: -8px; bottom: -6px; min-width: 28px; height: 28px; padding: 0 4px;
  border-radius: 14px; background: linear-gradient(180deg, #6a4a1e, #3a2810); border: 2px solid var(--gold-edge);
  color: #ffe9b8; font: 800 13px/24px var(--font-ui); text-align: center;
}
.avatar.level-up { animation: levelup 1.2s ease; }
@keyframes levelup { 30% { transform: scale(1.15); box-shadow: 0 0 0 2px #2a1d10, 0 0 28px var(--gold); } }
.profile-text { display: flex; flex-direction: column; gap: 4px; text-shadow: 0 1px 3px #000; }
.profile-name { font: 700 16px var(--font-display); color: #fff3dc; }
.xp { width: 150px; height: 8px; border-radius: 4px; background: rgba(10, 8, 16, 0.75); border: 1px solid #5a4830; overflow: hidden; }
.xp i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #c9883a, var(--gold)); }

.wallet { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.coin { display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; border-radius: 16px; background: rgba(15, 12, 22, 0.82); border: 1px solid #5a4830; font: 800 14px var(--font-ui); font-variant-numeric: tabular-nums; }
.coin .icon { width: 22px; height: 22px; }
.coin.gold { color: var(--gold); }
.coin.whispers { color: var(--whispers); }
.coin.echoes { color: var(--echoes); }

.hud-bottom { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: var(--hud-bottom); display: flex; align-items: center; gap: 12px; padding: 8px 110px 10px 14px; pointer-events: none; }
.hud-bottom > * { pointer-events: auto; }
.controls { display: flex; align-items: center; gap: 10px; margin: 0 auto; }
.toggle { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 18px; background: rgba(15, 12, 22, 0.82); border: 1px solid #5a4830; cursor: pointer; user-select: none; font: 700 13px var(--font-ui); }
.toggle input { display: none; }
.switch { width: 34px; height: 18px; border-radius: 9px; background: #3a3346; position: relative; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #d8d0c0; transition: transform 0.2s; }
.toggle input:checked + .switch { background: #a8692a; }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(224, 83, 61, 0.25); } }
.glow { animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 18px rgba(201, 167, 255, 0.6); } }

.chat-dock { display: flex; align-items: center; gap: 8px; max-width: 34vw; min-width: 0; }
.chat-btn { position: relative; width: 48px; height: 48px; flex: none; border-radius: 50%; border: 2px solid var(--gold-edge); background: linear-gradient(180deg, #3b3150, #221c30); cursor: pointer; display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5); }
.chat-btn .icon { width: 24px; height: 24px; }
.chat-preview { min-width: 0; padding: 5px 10px; border-radius: 8px; background: rgba(15, 12, 22, 0.7); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); cursor: pointer; }
.chat-preview b { color: #f0d9a8; }

.map-btn {
  position: fixed; z-index: 45; right: 14px; bottom: 10px; width: 84px; height: 84px; border-radius: 50%;
  border: 3px solid var(--gold-edge); background: radial-gradient(circle at 50% 35%, #4d3f2a, #241b10);
  box-shadow: 0 0 0 2px #2a1d10, 0 6px 18px rgba(0, 0, 0, 0.6); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font: 800 12px var(--font-display); color: #ffe9b8; letter-spacing: 0.04em; text-transform: uppercase;
}
.map-btn .icon { width: 40px; height: 40px; }
.map-btn:hover { filter: brightness(1.12); }

/* ---------------------------------------------------------------- town map */

#town { position: fixed; inset: 0; z-index: 20; background: radial-gradient(ellipse at 50% 40%, #2a2440, #0d0b14 75%); display: grid; place-items: center; animation: fade 0.25s ease; }
.town-map { position: relative; width: min(100vw, calc((100vh - var(--hud-top) * 0.6) * 16 / 9)); aspect-ratio: 16 / 9; }
.town-map > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.building { position: absolute; transform: translate(-50%, -50%); border: 0; background: transparent; cursor: pointer; padding: 0; }
.building::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(closest-side, rgba(255, 214, 140, 0.35), transparent); opacity: 0; transition: opacity 0.2s; }
.building:hover::before, .building:focus-visible::before { opacity: 1; }
.building-label {
  position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); white-space: nowrap;
  padding: 3px 12px; border-radius: 6px; border: 1px solid var(--gold-edge);
  background: linear-gradient(180deg, #3a2c1a, #21180e); color: #ffe9b8;
  font: 700 clamp(11px, 1.1vw, 15px) var(--font-display); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}
.building:hover .building-label { background: linear-gradient(180deg, #5a4426, #33240f); }
.building .badge { top: auto; right: auto; left: 50%; bottom: 22px; transform: translateX(-50%); }
.town-title { position: absolute; top: calc(var(--hud-top) + 4px); left: 50%; transform: translateX(-50%); font: 700 clamp(18px, 2.2vw, 30px) var(--font-display); color: #f4e6c8; letter-spacing: 0.2em; text-transform: uppercase; text-shadow: 0 2px 8px #000; pointer-events: none; }

/* ---------------------------------------------------------------- windows */

.window-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(6, 4, 12, 0.6); animation: fade 0.2s ease; padding: calc(var(--hud-top) + 4px) 14px 14px; }
.window { width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; animation: rise 0.22s ease; }
.window-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 2px solid var(--line); background: linear-gradient(180deg, #3a2c1a, #241a0f); border-radius: 8px 8px 0 0; }
.window-head h2 { margin: 0; flex: 1; color: #ffe9b8; font-size: 22px; letter-spacing: 0.06em; }
.window-body { padding: 16px; overflow-y: auto; min-height: 200px; }
.window-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card { background: rgba(10, 8, 16, 0.35); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- panels */

.party { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border-radius: 22px; background: rgba(10, 8, 16, 0.4); border: 1px solid var(--line-soft); }
.chip .face { width: 32px; height: 32px; }
.chip .slot { font: 800 10px var(--font-ui); text-transform: uppercase; color: var(--accent); }
.in-town .controls { visibility: hidden; }
.face { position: relative; display: inline-block; vertical-align: middle; width: 40px; height: 40px; flex: none; border-radius: 50%; overflow: hidden; border: 2px solid var(--rarity, var(--gold-edge)); background: radial-gradient(circle at 50% 35%, #4a3f66, #1a1626); }
.face img { position: absolute; width: 160%; left: -30%; top: -6%; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.hero-card { display: flex; gap: 12px; padding: 12px; border-radius: var(--radius); background: rgba(10, 8, 16, 0.35); border: 1px solid var(--line-soft); border-left: 4px solid var(--rarity, var(--common)); }
.hero-card.locked .portrait img { filter: grayscale(1) brightness(0.5); }
.hero-card.locked { opacity: 0.8; }
.r-common { --rarity: var(--common); }
.r-rare { --rarity: var(--rare); }
.r-epic { --rarity: var(--epic); }
.r-legendary { --rarity: var(--legendary); }
.portrait { position: relative; width: 84px; height: 84px; flex: none; border-radius: 50%; overflow: hidden; border: 3px solid var(--rarity, var(--common)); background: radial-gradient(circle at 50% 35%, #4a3f66, #1a1626); }
.portrait img { position: absolute; width: 150%; left: -25%; top: -4%; }
.hero-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.hero-name { font: 700 17px var(--font-display); display: flex; justify-content: space-between; gap: 8px; }
.rarity { font: 800 10px var(--font-ui); text-transform: uppercase; letter-spacing: 0.08em; color: var(--rarity); }
.hero-title { font-size: 13px; color: var(--muted); }
.stats { display: flex; gap: 12px; font: 13px var(--font-ui); flex-wrap: wrap; color: var(--muted); }
.stats b { color: var(--text); }
.stars { display: inline-flex; gap: 1px; }
.stars .icon { width: 14px; height: 14px; }
.ability { font-size: 13px; color: var(--muted); background: rgba(0, 0, 0, 0.25); border-radius: 8px; padding: 6px 8px; }
.ability b { color: var(--accent-2); }
.hero-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.task { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: rgba(10, 8, 16, 0.35); border: 1px solid var(--line-soft); margin-bottom: 8px; }
.task.done { border-color: var(--gold-edge); }
.task.claimed { opacity: 0.55; }
.task b { font-family: var(--font-display); font-size: 16px; }
.task-reward { color: var(--whispers); font: 700 13px var(--font-ui); text-align: right; }

.cache-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.cache-card { padding: 16px; border-radius: var(--radius); background: rgba(10, 8, 16, 0.35); border: 1px solid var(--line-soft); text-align: center; }
.chest { width: 120px; height: 100px; margin: 0 auto 6px; }
.chest svg { width: 100%; height: 100%; }
.odds { width: 100%; margin-top: 12px; border-collapse: collapse; font: 13px var(--font-ui); text-align: left; }
.odds caption { color: var(--muted); margin-bottom: 4px; }
.odds td { padding: 4px; border-top: 1px solid var(--line-soft); }

.toll { display: flex; gap: 20px; align-items: center; padding: 16px; border-radius: var(--radius); margin-bottom: 16px; background: linear-gradient(135deg, rgba(70, 50, 110, 0.5), rgba(20, 16, 32, 0.6)); border: 1px solid #5a4890; }
.toll-bell { width: 110px; flex: none; }
.toll-bell svg { width: 100%; }
.toll.ready .toll-bell svg { animation: sway 3s ease-in-out infinite; transform-origin: 50% 8%; }
@keyframes sway { 25% { transform: rotate(6deg); } 75% { transform: rotate(-6deg); } }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin: 10px 0 14px; }
.fact { background: rgba(0, 0, 0, 0.28); border-radius: 8px; padding: 6px 10px; }
.fact small { display: block; color: var(--muted); font: 700 11px var(--font-ui); text-transform: uppercase; letter-spacing: 0.05em; }
.fact b { font: 800 17px var(--font-ui); font-variant-numeric: tabular-nums; }
.talent { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: rgba(10, 8, 16, 0.35); border: 1px solid var(--line-soft); margin-bottom: 8px; }
.talent b { font-family: var(--font-display); font-size: 16px; }
.talent .lvl { color: var(--muted); font: 12px var(--font-ui); margin-left: 6px; }
.talent .now { color: var(--accent-2); font: 12px var(--font-ui); }

.table { width: 100%; border-collapse: collapse; font: 14px var(--font-ui); }
.table th { text-align: left; color: var(--muted); font-weight: 700; font-size: 12px; padding: 4px 6px; }
.table td { padding: 6px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.table tr.me td { background: rgba(232, 162, 74, 0.12); }
.who-cell { display: flex; align-items: center; gap: 8px; }
.who-cell .face { width: 32px; height: 32px; }
.lvl-pill { display: inline-block; min-width: 24px; padding: 0 5px; border-radius: 10px; background: #3a2810; border: 1px solid var(--gold-edge); color: #ffe9b8; font: 800 11px/16px var(--font-ui); text-align: center; }
.online { color: var(--gold); font: 700 11px var(--font-ui); text-transform: uppercase; letter-spacing: 0.05em; }
.members { list-style: none; padding: 0; margin: 0; }
.members li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.members .right { margin-left: auto; font: 13px var(--font-ui); }

.codex-group { margin-bottom: 18px; }
.codex-group details { background: rgba(10, 8, 16, 0.35); border: 1px solid var(--line-soft); border-radius: 8px; margin-bottom: 6px; padding: 8px 12px; }
.codex-group summary { cursor: pointer; font: 700 16px var(--font-display); display: flex; align-items: center; gap: 10px; }
.codex-group details p { color: #ddd2bc; margin: 8px 0 0; max-width: 72ch; }
.codex-img { width: 36px; height: 36px; object-fit: contain; }

.profile-head { display: flex; align-items: center; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; }
.profile-head .avatar { width: 96px; height: 96px; }
.profile-head .avatar .level { min-width: 36px; height: 36px; font-size: 16px; line-height: 32px; }
.profile-head h2 { font-size: 26px; margin: 0; }
.avatar-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar-pick button { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.avatar-pick .face { width: 56px; height: 56px; }
.avatar-pick button.on .face { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.form { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.links { display: flex; gap: 14px; font: 13px var(--font-ui); }
.links a { color: var(--muted); }
.links a:hover { color: var(--text); }

/* ---------------------------------------------------------------- chat */

.chat-drawer { position: fixed; z-index: 35; left: 10px; top: calc(var(--hud-top) + 4px); bottom: calc(var(--hud-bottom) + 4px); width: min(380px, calc(100vw - 20px)); display: flex; flex-direction: column; animation: slide 0.2s ease; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.chat-tab { background: transparent; border: 0; color: var(--muted); padding: 6px 10px; cursor: pointer; font: 700 14px var(--font-display); border-bottom: 2px solid transparent; }
.chat-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.chat-tab:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-tab .count { margin-left: 4px; color: var(--alert); font: 800 12px var(--font-ui); }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font: 14px var(--font-ui); }
.msg { line-height: 1.35; overflow-wrap: anywhere; }
.msg .time { color: var(--dim); font-size: 11px; margin-right: 6px; }
.msg .from { font-weight: 700; margin-right: 6px; color: #f0d9a8; }
.msg .from .tag { margin-right: 4px; }
.msg.system { color: #e8cf9a; }
.msg.system .text::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; background: center / contain no-repeat url("../assets/ui/bell.svg"); }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- title screen */

#title { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 30%, rgba(30, 20, 50, 0.35), rgba(8, 6, 14, 0.75)); overflow-y: auto; }
.title-card { width: min(440px, 100%); padding: 24px 26px; text-align: center; }
.title-bell { width: 84px; margin: 0 auto; filter: drop-shadow(0 0 18px rgba(242, 193, 78, 0.45)); }
.title-card h1 { font-size: clamp(34px, 7vw, 46px); letter-spacing: 0.16em; text-transform: uppercase; color: #f6e8c8; margin: 4px 0 0; }
.title-card .subtitle { color: var(--accent); font: 700 16px var(--font-display); margin-bottom: 16px; }
.title-tabs { display: flex; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.title-tabs button { flex: 1; background: none; border: 0; padding: 10px; cursor: pointer; color: var(--muted); font: 700 15px var(--font-display); border-bottom: 2px solid transparent; }
.title-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.title-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.title-card .error { color: var(--bad); min-height: 1.2em; margin: 0; font: 14px var(--font-ui); }
.title-card .fine { color: var(--dim); font: 12px var(--font-ui); text-align: center; margin-top: 12px; }
.title-card .fine a { color: var(--muted); }

/* ---------------------------------------------------------------- dialogs, toasts, banners */

.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(6, 4, 12, 0.7); animation: fade 0.2s ease; padding: 16px; }
.modal { width: min(500px, 100%); max-height: 100%; overflow: auto; padding: 22px; animation: rise 0.22s ease; }
.modal h2 { color: #ffe9b8; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.big-reward { font: 800 22px var(--font-ui); color: var(--gold); display: flex; align-items: center; gap: 8px; }
.big-reward .icon { width: 28px; height: 28px; }
.reward-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.reward-card { padding: 12px 8px; border-radius: var(--radius); background: rgba(10, 8, 16, 0.45); border: 2px solid var(--rarity, var(--line)); text-align: center; font: 700 13px var(--font-ui); animation: flip 0.45s ease both; }
.reward-card .art { height: 66px; display: grid; place-items: center; margin-bottom: 6px; }
.reward-card .art img { height: 66px; }
.reward-card .art .icon { width: 42px; height: 42px; }
.reward-card .chest { width: 70px; height: 58px; margin: 0; }
.reward-card.k-recruit { border-color: var(--gold); }

#toasts { position: fixed; z-index: 60; top: calc(var(--hud-top) + 8px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 9px 18px; border-radius: 8px; background: linear-gradient(180deg, #3a2c1a, #21180e); border: 1px solid var(--gold-edge); box-shadow: var(--shadow); font: 700 14px var(--font-ui); animation: rise 0.25s ease; transition: opacity 0.5s; max-width: 90vw; text-align: center; }
.toast.bad { border-color: #a8473a; background: linear-gradient(180deg, #4a1f19, #2a110d); color: #ffd6cc; }
.toast.out { opacity: 0; }
.banner { position: fixed; z-index: 55; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 8px; background: rgba(20, 14, 10, 0.92); border: 1px solid var(--gold-edge); font: 700 14px var(--font-ui); }
#reconnect { top: calc(var(--hud-top) + 8px); }
#rotate-hint { bottom: calc(var(--hud-bottom) + 10px); display: none; }
@media (orientation: portrait) and (max-width: 700px) { #rotate-hint { display: block; } }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes slide { from { opacity: 0; transform: translateX(-16px); } }
@keyframes flip { from { opacity: 0; transform: rotateY(80deg) scale(0.9); } }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 760px), (max-height: 520px) {
  .avatar { width: 44px; height: 44px; border-width: 2px; }
  .avatar .level { min-width: 22px; height: 22px; font-size: 11px; line-height: 18px; right: -6px; bottom: -5px; }
  .profile-name { font-size: 14px; }
  .xp { width: 100px; }
  .coin { padding: 2px 8px 2px 4px; font-size: 12px; }
  .coin .icon { width: 18px; height: 18px; }
  .map-btn { width: 64px; height: 64px; font-size: 10px; }
  .map-btn .icon { width: 30px; height: 30px; }
  .hud-bottom { padding-right: 86px; }
  .chat-btn { width: 40px; height: 40px; }
  .chat-preview { display: none; }
  .window-body { padding: 10px; }
  .hero-grid, .cache-grid { grid-template-columns: 1fr; }
}
