:root {
  --teal: #2EE6D6;
  --teal-soft: #8FF8ED;
  --ink: #040c12;
  --ink-2: #071820;
  --panel: rgba(7, 22, 31, .88);
  --line: rgba(46, 230, 214, .18);
  --text: #EAF9F6;
  --muted: #82A3A5;
  --gold: #F2C35C;
  --red: #FF6B6B;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: .028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
.is-hidden { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic { width: 20px; height: 20px; display: block; fill: currentColor; flex: none; pointer-events: none; }

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ============ HUD ============ */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: calc(var(--safe-top) + 10px) 14px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: linear-gradient(180deg, rgba(3, 10, 15, .88), rgba(3, 10, 15, .3) 72%, rgba(3, 10, 15, 0));
  pointer-events: none;
}
.hud-top::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(46, 230, 214, .16), transparent);
}
.lord-mini {
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: auto;
  min-width: 0;
  padding: 3px 9px 3px 3px;
  border-radius: 15px;
  background: linear-gradient(160deg, rgba(26, 32, 34, .9), rgba(7, 14, 18, .92));
  border: 1px solid rgba(242, 195, 92, .38);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4), inset 0 1px rgba(255, 255, 255, .06), 0 0 0 1px rgba(0, 0, 0, .35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.lord-name-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.lv-tag {
  flex: none;
  padding: 1px 5px;
  border-radius: 4px;
  font-style: normal;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .03em;
  color: #2a1c02;
  background: linear-gradient(180deg, #FFE39C, #E3AE3E);
  box-shadow: inset 0 1px rgba(255, 255, 255, .5), 0 1px 3px rgba(0, 0, 0, .35);
}
.xp-bar {
  display: block;
  height: 3px;
  margin-top: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, .5);
  border: 1px solid rgba(255, 255, 255, .05);
  overflow: hidden;
}
.xp-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #18BFB3, #2EE6D6 60%, #9DFFF5);
  box-shadow: 0 0 7px rgba(46, 230, 214, .55);
  transition: width .3s ease;
}
.lord-mini-info .xp-bar { width: 86px; }
.lord-main .xp-bar { width: 100%; max-width: 150px; margin-top: 5px; }
.avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  border: 1px solid rgba(242, 195, 92, .75);
  background: linear-gradient(150deg, #12414A, #081B25);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  color: var(--teal);
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 0 0 2px rgba(4, 12, 18, .9), 0 0 0 3px rgba(242, 195, 92, .22), 0 4px 16px rgba(0, 0, 0, .45), inset 0 1px rgba(255, 255, 255, .08);
  overflow: hidden;
  position: relative;
}
.avatar:after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 18px rgba(46, 230, 214, .14);
  pointer-events: none;
}
.avatar.has-img span { display: none; }
.avatar-lg { width: 46px; height: 46px; border-radius: 14px; font-size: 17px; }
.lord-mini-info b { display: block; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: #eafbf8; max-width: 132px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lord-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 10px; color: var(--muted); }
.lord-meta em {
  font-style: normal;
  padding: 1px 6px;
  border-radius: 5px;
  color: #9df6ee;
  background: rgba(46, 230, 214, .09);
  border: 1px solid rgba(46, 230, 214, .2);
  font-size: 9px;
}
.online-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 7px var(--teal);
}
.hud-top-right { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.glass-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(7, 21, 30, .72);
  border: 1px solid rgba(46, 230, 214, .18);
  display: grid;
  place-items: center;
  color: #cfe9e7;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.glass-btn:active { background: rgba(46, 230, 214, .14); }
.glass-btn .mp-icon { width: 20px; height: 20px; }
.boost-cta {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 9px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  color: #2a1c02;
  background: linear-gradient(180deg, #FFE39C, #E3AE3E);
  border: 1px solid rgba(255, 235, 180, .7);
  box-shadow: 0 4px 12px rgba(242, 195, 92, .28), inset 0 1px rgba(255, 255, 255, .6), inset 0 -2px rgba(80, 50, 5, .18);
  transition: transform .12s, filter .12s;
}
.boost-cta .ic { width: 15px; height: 15px; color: #2a1c02; }
.boost-cta:active { transform: scale(.95); filter: brightness(.96); }
.boost-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 9px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(242, 195, 92, .1);
  border: 1px solid rgba(242, 195, 92, .35);
  box-shadow: 0 0 18px rgba(242, 195, 92, .12);
}
.boost-badge .ic { width: 14px; height: 14px; }
.idle-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 10px;
  border-radius: 12px;
  color: #FFD98A;
  font-size: 12px;
  font-weight: 800;
  background: rgba(242, 195, 92, .11);
  border: 1px solid rgba(242, 195, 92, .42);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35), inset 0 1px rgba(255, 255, 255, .05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: idlePulse 2.4s ease-in-out infinite;
}
.idle-btn .ic { width: 16px; height: 16px; color: #FFD98A; }
.idle-btn:active { transform: scale(.94); background: rgba(242, 195, 92, .22); }
@keyframes idlePulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(0, 0, 0, .35), 0 0 0 0 rgba(242, 195, 92, .28); }
  50% { box-shadow: 0 4px 14px rgba(0, 0, 0, .35), 0 0 0 5px rgba(242, 195, 92, 0); }
}

.res-row {
  position: absolute;
  top: calc(var(--safe-top) + 57px);
  left: 12px; right: 12px;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.res-chip {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 36px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  color: #f4fffd;
  background: linear-gradient(180deg, rgba(10, 32, 43, .94), rgba(5, 18, 27, .92));
  border: 1px solid rgba(46, 230, 214, .14);
  box-shadow: 0 0 0 1px rgba(242, 195, 92, .06), inset 0 1px rgba(255, 255, 255, .05), inset 0 -1px rgba(0, 0, 0, .4), 0 5px 14px rgba(0, 0, 0, .28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
}
.res-chip::after {
  content: "";
  position: absolute;
  left: 12%; right: 12%; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .16), transparent);
  pointer-events: none;
}
.res-food { border-color: rgba(242, 180, 92, .2); }
.res-wood { border-color: rgba(201, 143, 90, .2); }
.res-gold { border-color: rgba(245, 214, 92, .2); }
.res-stone { border-color: rgba(185, 198, 209, .18); }
.res-chip .ic {
  width: 21px;
  height: 21px;
  padding: 2px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .22);
  box-shadow: inset 0 1px rgba(255, 255, 255, .06), 0 0 0 1px rgba(255, 255, 255, .04);
  filter: drop-shadow(0 0 6px currentColor);
  opacity: .96;
}
.res-food .ic { color: #F2B45C; }
.res-wood .ic { color: #C98F5A; }
.res-gold .ic { color: #F5D65C; }
.res-stone .ic { color: #B9C6D1; }

.ai-card {
  position: absolute;
  top: calc(var(--safe-top) + 101px);
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 8px;
  border-radius: 10px;
  border: 1px solid rgba(242, 195, 92, .35);
  background: linear-gradient(180deg, rgba(34, 25, 15, .86), rgba(13, 10, 8, .86));
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35), inset 0 1px rgba(255, 255, 255, .06), inset 0 -1px rgba(0, 0, 0, .4);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  pointer-events: none;
}
.ai-card .ic { width: 18px; height: 18px; color: #FF6B6B; filter: drop-shadow(0 0 6px rgba(255, 107, 107, .45)); }
.ai-info b { display: block; font-size: 10px; font-weight: 700; letter-spacing: .06em; color: #ffd9d9; }
.ai-info small { display: flex; align-items: center; gap: 4px; margin-top: 1px; font-size: 8.5px; color: #b98f92; }
.ai-info em { font-style: normal; color: #ff9b9b; }
.ai-info #aiWave { color: #f2c35c; }
.ai-sep { color: rgba(255, 255, 255, .25); }

.hud-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 12px calc(var(--safe-bottom) + 8px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(180deg, rgba(3, 10, 15, 0), rgba(3, 10, 15, .5) 30%, rgba(3, 10, 15, .92) 100%);
  pointer-events: none;
}
.hud-bottom > * { pointer-events: auto; }

.cmd-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }

.minimap-wrap {
  position: relative;
  flex: none;
  width: 112px;
  height: 71px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(242, 195, 92, .4);
  background: #06141c;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .45), 0 8px 22px rgba(0, 0, 0, .5), inset 0 0 22px rgba(46, 230, 214, .07);
}
.minimap-wrap::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: -24%;
  height: 20%;
  background: linear-gradient(180deg, transparent, rgba(46, 230, 214, .2), transparent);
  pointer-events: none;
  animation: miniScan 4.6s linear infinite;
}
.minimap-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(138deg, rgba(255, 255, 255, .14), transparent 36%);
}
@keyframes miniScan {
  0% { top: -24%; }
  100% { top: 108%; }
}
#minimap { width: 100%; height: 100%; display: block; }
.mini-label {
  position: absolute;
  left: 6px; top: 4px;
  font-size: 8px;
  letter-spacing: .18em;
  color: rgba(214, 255, 250, .62);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  pointer-events: none;
}
.mini-compass {
  position: absolute;
  right: 5px; top: 3px;
  width: 13px; height: 13px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 7px;
  font-weight: 800;
  color: rgba(190, 255, 248, .8);
  border: 1px solid rgba(46, 230, 214, .35);
  background: rgba(3, 13, 19, .55);
  pointer-events: none;
}

.cmd-right { display: flex; align-items: flex-end; gap: 8px; flex: none; }
.select-btn {
  width: 42px; height: 46px;
  border-radius: 12px;
  background: rgba(7, 22, 31, .82);
  border: 1px solid rgba(46, 230, 214, .2);
  color: #9dbfc0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 8px;
  letter-spacing: .04em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
}
.select-btn .ic { width: 19px; height: 19px; }
.select-btn.is-on {
  color: var(--teal);
  border-color: rgba(46, 230, 214, .7);
  background: rgba(46, 230, 214, .13);
  box-shadow: 0 0 0 3px rgba(46, 230, 214, .08), 0 0 20px rgba(46, 230, 214, .18);
}
.stance-btn {
  position: relative;
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #cfe9e7;
  font-size: 10px;
  letter-spacing: .04em;
  background: radial-gradient(circle at 35% 25%, rgba(30, 76, 82, .9), rgba(6, 19, 27, .96));
  border: 1px solid rgba(242, 195, 92, .38);
  box-shadow: 0 0 0 2px rgba(242, 195, 92, .07), 0 8px 20px rgba(0, 0, 0, .45), inset 0 1px rgba(255, 255, 255, .06);
}
.stance-btn::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .07);
  pointer-events: none;
}
.stance-btn .ic { width: 21px; height: 21px; }
.stance-btn:active { transform: scale(.94); }
.stance-btn.is-on {
  color: #062722;
  background: radial-gradient(circle at 35% 25%, #6FF7EA, #22c9bc);
  border-color: #9dfff5;
  box-shadow: 0 0 0 3px rgba(46, 230, 214, .14), 0 8px 24px rgba(46, 230, 214, .3);
}
.stance-btn.auto {
  color: #ffe6b0;
  background: radial-gradient(circle at 35% 25%, rgba(120, 92, 34, .9), rgba(28, 21, 9, .96));
  border-color: rgba(242, 195, 92, .48);
}
.stance-btn.auto.is-on {
  color: #2a1c02;
  background: radial-gradient(circle at 35% 25%, #FFE39C, #E3AE3E);
  border-color: #ffe8a8;
  box-shadow: 0 0 0 3px rgba(242, 195, 92, .14), 0 8px 24px rgba(242, 195, 92, .28);
}

.dock {
  position: relative;
  height: 62px;
  border-radius: 17px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background:
    linear-gradient(180deg, rgba(16, 42, 54, .55), transparent 32%),
    linear-gradient(180deg, rgba(9, 27, 38, .97), rgba(4, 15, 23, .99));
  border: 1px solid rgba(46, 230, 214, .2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55), inset 0 1px rgba(255, 255, 255, .06), inset 0 -1px rgba(0, 0, 0, .4);
  overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.dock-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: #78989c;
  transition: color .15s, background .15s;
}
.dock-btn + .dock-btn::after {
  content: "";
  position: absolute;
  left: 0; top: 22%; bottom: 22%;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .075), transparent);
  pointer-events: none;
}
.dock-btn .ic { width: 22px; height: 22px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35)); }
.dock-btn.is-on {
  color: var(--teal);
  background: radial-gradient(ellipse at 50% 118%, rgba(46, 230, 214, .2), transparent 68%);
}
.dock-btn.is-on .ic { filter: drop-shadow(0 0 7px rgba(46, 230, 214, .55)); }
.dock-btn.is-on::before {
  content: "";
  position: absolute;
  top: 0; left: 26%; right: 26%;
  height: 2px;
  border-radius: 2px;
  background: var(--teal);
  box-shadow: 0 0 12px var(--teal);
}
.dock-btn:active { background: rgba(46, 230, 214, .1); }
.dock-btn .dot {
  position: absolute;
  top: 9px;
  right: calc(50% - 18px);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}
.dock::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .055);
  box-shadow: inset 0 1px rgba(255, 255, 255, .04);
  pointer-events: none;
}
.dock::before {
  content: "";
  position: absolute;
  top: 0; left: 8%; right: 8%;
  height: 1px;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(242, 195, 92, .5), transparent);
}

.build-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 7px 0 12px;
  border-radius: 12px;
  background: rgba(7, 23, 31, .95);
  border: 1px solid rgba(242, 195, 92, .45);
  color: #f7e4b6;
  font-size: 11.5px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .45);
}
.build-hint .ic { width: 16px; height: 16px; color: var(--gold); }
.build-hint span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.build-hint button {
  height: 28px;
  padding: 0 11px;
  border-radius: 8px;
  background: var(--gold);
  color: #211703;
  font-size: 11px;
  font-weight: 800;
}

.sel-bar {
  min-height: 46px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(10, 31, 42, .95), rgba(6, 20, 28, .96));
  border: 1px solid rgba(46, 230, 214, .22);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .4);
  display: flex;
  align-items: center;
  padding: 5px 7px;
}
#selBarInner { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.sel-chips { display: flex; gap: 3px; flex: none; }
.sel-chip {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 5px;
  border-radius: 7px;
  color: #cffff9;
  background: rgba(46, 230, 214, .1);
  border: 1px solid rgba(46, 230, 214, .16);
  font-size: 11px;
}
.sel-chip .ic { width: 14px; height: 14px; }
.sel-chip b { font-weight: 800; }
.sel-icon {
  width: 32px; height: 32px;
  flex: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: rgba(46, 230, 214, .1);
  border: 1px solid rgba(46, 230, 214, .2);
}
.sel-icon .ic { width: 18px; height: 18px; }
.sel-info { flex: 1; min-width: 0; }
.sel-portrait {
  width: 42px;
  height: 42px;
  flex: none;
  position: relative;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: radial-gradient(circle at 35% 25%, rgba(46, 230, 214, .2), rgba(6, 20, 28, .92));
  border: 1px solid rgba(46, 230, 214, .42);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35), inset 0 1px rgba(255, 255, 255, .08);
}
.sel-portrait .ic { width: 23px; height: 23px; filter: drop-shadow(0 0 6px currentColor); }
.sel-portrait em {
  position: absolute;
  right: -5px; bottom: -5px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 9px;
  font-weight: 800;
  color: #211703;
  background: linear-gradient(180deg, #ffe39c, #E3AE3E);
  border: 1px solid rgba(0, 0, 0, .4);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.sel-portrait.type-villager { color: #F2C35C; border-color: rgba(242, 195, 92, .5); background: radial-gradient(circle at 35% 25%, rgba(242, 195, 92, .18), rgba(6, 20, 28, .92)); }
.sel-portrait.type-infantry { color: #B9CBD6; border-color: rgba(185, 203, 214, .45); background: radial-gradient(circle at 35% 25%, rgba(185, 203, 214, .16), rgba(6, 20, 28, .92)); }
.sel-portrait.type-archer { color: #8FD66B; border-color: rgba(143, 214, 107, .42); background: radial-gradient(circle at 35% 25%, rgba(143, 214, 107, .16), rgba(6, 20, 28, .92)); }
.sel-portrait.type-cavalry { color: #C98F5A; border-color: rgba(201, 143, 90, .45); background: radial-gradient(circle at 35% 25%, rgba(201, 143, 90, .18), rgba(6, 20, 28, .92)); }
.sel-title { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.sel-title b { display: block; font-size: 13px; color: #e8fffc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-title span { flex: none; font-size: 9px; color: #7f9fa2; letter-spacing: .02em; }
.sel-info b { display: block; font-size: 12px; color: #e8fffc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-info small { display: block; font-size: 9px; color: var(--muted); margin-top: 1px; white-space: nowrap; }
.sel-hp {
  display: block;
  height: 3px;
  margin-top: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .09);
  overflow: hidden;
}
.sel-hp i {
  display: block;
  height: 100%;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(46, 230, 214, .35);
  transition: width .2s linear;
}
.sel-queue { font-size: 9px; color: var(--gold); flex: none; }
.sel-btn {
  height: 28px;
  padding: 0 10px;
  flex: none;
  border-radius: 8px;
  font-size: 11px;
  color: #bffaf4;
  background: rgba(46, 230, 214, .1);
  border: 1px solid rgba(46, 230, 214, .22);
  transition: transform .12s, background .15s;
}
.sel-btn:active { background: rgba(46, 230, 214, .2); transform: scale(.95); }
.sel-btn.icon-only { width: 28px; padding: 0; font-size: 17px; line-height: 1; color: #a7c5c6; }

/* ============ start screen ============ */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse at 50% 8%, rgba(46, 230, 214, .13), transparent 55%),
    radial-gradient(ellipse at 50% 104%, rgba(13, 74, 79, .38), transparent 58%),
    linear-gradient(180deg, rgba(4, 12, 18, .16) 0%, rgba(4, 12, 18, .4) 34%, rgba(4, 12, 18, .86) 58%, #040c12 78%);
}
.start-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(46, 230, 214, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46, 230, 214, .055) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 18%, #000 0%, transparent 68%);
  mask-image: radial-gradient(ellipse at 50% 18%, #000 0%, transparent 68%);
  pointer-events: none;
}
.start-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 38%, transparent 30%, rgba(2, 6, 9, .46) 100%);
}

.start-crest {
  position: absolute;
  top: calc(var(--safe-top) + 96px);
  left: 50%;
  width: 230px;
  height: 230px;
  transform: translateX(-50%);
  color: var(--teal);
  opacity: .07;
  pointer-events: none;
  filter: drop-shadow(0 0 34px rgba(46, 230, 214, .5));
}
.start-crest > .ic { width: 100%; height: 100%; }
.start-crest .crest-crown {
  position: absolute;
  left: 50%; top: 30%;
  width: 62px; height: 62px;
  transform: translateX(-50%);
  opacity: .9;
}
.start-music {
  position: absolute;
  z-index: 3;
  top: calc(var(--safe-top) + 14px);
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #a8d4d1;
  background: rgba(6, 20, 27, .66);
  border: 1px solid rgba(46, 230, 214, .22);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35), inset 0 1px rgba(255, 255, 255, .05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform .12s, background .15s, color .15s;
}
.start-music .ic { width: 18px; height: 18px; }
.start-music:active { transform: scale(.94); background: rgba(46, 230, 214, .14); }
.start-music.is-off { color: #59777a; opacity: .72; }
.start-music.is-off::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 23px;
  height: 1.5px;
  border-radius: 2px;
  background: #7fa7a7;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.start-top {
  position: relative;
  z-index: 1;
  padding: calc(var(--safe-top) + 46px) 22px 0;
  text-align: center;
  animation: startFadeUp .66s cubic-bezier(.2, .8, .25, 1) both;
}
@keyframes startFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .start-top, .start-bottom, .start-btn-glow, .idle-btn, .minimap-wrap::after { animation: none !important; }
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(46, 230, 214, .24);
  background: rgba(6, 20, 27, .55);
  color: #a9d6d4;
  font-size: 9px;
  letter-spacing: .18em;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.eyebrow-line { display: block; width: 16px; height: 1px; background: var(--teal); box-shadow: 0 0 6px var(--teal); }
.start-top h1 {
  margin: 13px 0 7px;
  font-size: clamp(42px, 12vw, 56px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: .07em;
  color: #f4fffd;
  text-shadow: 0 4px 32px rgba(0, 0, 0, .66);
}
.start-top h1 span {
  color: var(--teal);
  text-shadow: 0 0 26px rgba(46, 230, 214, .45), 0 4px 32px rgba(0, 0, 0, .6);
}
.start-top h1::after {
  content: "";
  display: block;
  width: 46px;
  height: 2px;
  margin: 9px auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
  box-shadow: 0 0 12px rgba(46, 230, 214, .55);
}
.start-top p {
  margin: 0 auto;
  max-width: 300px;
  font-size: 11.5px;
  line-height: 1.8;
  color: #a5c2c3;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .8);
}
.start-bottom {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: auto auto 0;
  padding: 26px 16px calc(var(--safe-bottom) + 14px);
  display: flex;
  flex-direction: column;
  gap: 11px;
  animation: startFadeUp .72s .08s cubic-bezier(.2, .8, .25, 1) both;
}
.lord-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 15px;
  background: linear-gradient(160deg, rgba(10, 31, 41, .88), rgba(5, 17, 24, .9));
  border: 1px solid rgba(46, 230, 214, .17);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35), inset 0 1px rgba(255, 255, 255, .05), inset 0 -1px rgba(0, 0, 0, .38);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.lord-main { flex: 1; min-width: 0; }
.lord-main b { display: block; font-size: 14px; letter-spacing: .02em; }
.lord-main small { display: block; margin-top: 3px; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 11px;
  color: #b8e6e2;
  background: rgba(46, 230, 214, .08);
  border: 1px solid rgba(46, 230, 214, .22);
}
.mini-btn:active { background: rgba(46, 230, 214, .18); }

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 9px;
  letter-spacing: .24em;
  color: #6f9294;
  text-transform: uppercase;
}
.section-label span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(46, 230, 214, .22), transparent); }

.diff-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.diff-card {
  position: relative;
  min-height: 88px;
  padding: 9px 6px 9px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: linear-gradient(180deg, rgba(10, 29, 39, .82), rgba(6, 20, 29, .8));
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px rgba(255, 255, 255, .05), inset 0 -1px rgba(0, 0, 0, .3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color .16s, background .16s, transform .12s;
}
.diff-card::before {
  content: "";
  position: absolute;
  left: 22%; right: 22%; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .1), transparent);
}
.diff-card:active { transform: scale(.97); }
.diff-ic {
  width: 18px; height: 18px;
  flex: none;
  fill: currentColor;
  margin-bottom: 2px;
  opacity: .85;
  transition: opacity .16s, filter .16s;
}
.diff-card[data-diff="easy"] .diff-ic { color: #79D6A8; }
.diff-card[data-diff="normal"] .diff-ic { color: #7FE6DC; }
.diff-card[data-diff="hard"] .diff-ic { color: #FF9E9E; }
.diff-card b { font-size: 14px; color: #dcefed; letter-spacing: .08em; }
.diff-card small { font-size: 9px; color: #7f9fa2; line-height: 1.3; }
.diff-card span { margin-top: 2px; font-size: 8px; letter-spacing: .18em; color: #577579; }
.diff-card.is-on {
  background: linear-gradient(180deg, rgba(46, 230, 214, .18), rgba(8, 25, 33, .92));
  border-color: rgba(46, 230, 214, .6);
  box-shadow: 0 0 0 2px rgba(46, 230, 214, .07), 0 10px 26px rgba(46, 230, 214, .12), inset 0 1px rgba(255, 255, 255, .08);
}
.diff-card.is-on .diff-ic { opacity: 1; filter: drop-shadow(0 0 7px currentColor); }
.diff-card.is-on b { color: var(--teal); text-shadow: 0 0 14px rgba(46, 230, 214, .35); }
.diff-card.is-on span { color: rgba(46, 230, 214, .8); }

.start-btn {
  position: relative;
  height: 58px;
  margin-top: 3px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  color: #022522;
  background: linear-gradient(135deg, #46F0DF 0%, #2EE6D6 45%, #18BFB3 100%);
  border: 1px solid rgba(190, 255, 247, .6);
  box-shadow:
    0 14px 32px rgba(46, 230, 214, .26),
    0 0 0 1px rgba(2, 20, 18, .22),
    inset 0 1px rgba(255, 255, 255, .6),
    inset 0 -4px rgba(2, 40, 36, .18);
  transition: transform .12s, filter .12s;
}
.start-btn .ic { width: 26px; height: 26px; }
.start-btn b { display: block; font-size: 17px; font-weight: 900; letter-spacing: .12em; }
.start-btn small { display: block; font-size: 9px; font-weight: 700; opacity: .62; letter-spacing: .08em; margin-top: 1px; }
.start-btn:active { transform: scale(.985); filter: brightness(.96); }
.start-btn-glow {
  position: absolute;
  top: -40%; left: -30%;
  width: 40%; height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: rotate(16deg);
  animation: shine 3.6s infinite;
  pointer-events: none;
}
@keyframes shine {
  0%, 55% { left: -40%; }
  100% { left: 130%; }
}
.start-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 0;
}
.start-links button {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #9ec3c2;
}
.start-links button .ic { width: 14px; height: 14px; }
.start-links span { font-size: 9px; color: #5c7b7e; letter-spacing: .04em; }

/* ============ sheet ============ */
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(2, 8, 12, .52);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.sheet-mask.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  max-height: 74vh;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  border: 1px solid rgba(46, 230, 214, .22);
  border-bottom: 0;
  background: linear-gradient(180deg, #0C2230 0%, #07151E 55%, #06121A 100%);
  box-shadow: 0 -24px 60px rgba(0, 0, 0, .65);
  transform: translateY(103%);
  transition: transform .28s cubic-bezier(.2, .85, .25, 1);
  padding-bottom: calc(var(--safe-bottom) + 2px);
}
.sheet.is-open { transform: translateY(0); }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: rgba(160, 220, 216, .3); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; padding: 9px 18px 6px; flex: none; }
.sheet-head h2 { margin: 0; font-size: 16px; letter-spacing: .04em; }
.sheet-close {
  margin-left: auto;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 21px;
  line-height: 1;
  color: #9fc4c4;
  background: rgba(255, 255, 255, .06);
}
.sheet-close:active { background: rgba(255, 255, 255, .13); }
#sheetBody { overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; padding: 2px 18px calc(18px + var(--safe-bottom)); }
.sheet-scroll { padding: 2px 0 8px; }

.block-label {
  margin: 10px 0 7px;
  font-size: 9px;
  letter-spacing: .22em;
  color: #6f9294;
  text-transform: uppercase;
}
.sheet-note { margin-top: 11px; font-size: 10px; line-height: 1.7; color: #78999b; }
.sheet-note.top { margin: 4px 0 11px; padding: 8px 10px; border-radius: 9px; background: rgba(46, 230, 214, .06); border: 1px solid rgba(46, 230, 214, .12); color: #9bc2c0; }
.empty-line { padding: 12px; border-radius: 10px; text-align: center; font-size: 10px; color: #6e8f91; background: rgba(255, 255, 255, .03); border: 1px dashed rgba(255, 255, 255, .08); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 10px; }
.stat-card {
  padding: 12px 6px;
  border-radius: 12px;
  text-align: center;
  background: linear-gradient(160deg, rgba(46, 230, 214, .08), rgba(255, 255, 255, .02));
  border: 1px solid rgba(46, 230, 214, .14);
}
.stat-card b { display: block; font-size: 19px; color: var(--teal); letter-spacing: .02em; }
.stat-card small { display: block; margin-top: 2px; font-size: 9px; color: #7f9fa2; }

.btn-stack { display: flex; flex-direction: column; gap: 7px; }
.wide-btn {
  min-height: 44px;
  padding: 0 13px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: #d7ebe9;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px rgba(255, 255, 255, .045), inset 0 -1px rgba(0, 0, 0, .26);
  text-align: left;
  transition: transform .12s, background .15s, border-color .15s;
}
.wide-btn .ic { width: 18px; height: 18px; color: #8fb8b8; }
.wide-btn:active { background: rgba(255, 255, 255, .08); transform: scale(.985); }
.wide-btn.accent {
  color: #d9fffb;
  background: linear-gradient(135deg, rgba(46, 230, 214, .19), rgba(46, 230, 214, .07));
  border-color: rgba(46, 230, 214, .46);
}
.wide-btn.accent .ic { color: var(--teal); }
.wide-btn.danger { color: #ffb3b3; border-color: rgba(255, 107, 107, .22); }
.wide-btn.danger .ic { color: #ff8b8b; }

.log-title { margin: 14px 0 6px; font-size: 9px; letter-spacing: .2em; color: #6f9294; }
.log-box {
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(3, 12, 18, .5);
  border: 1px solid rgba(255, 255, 255, .05);
}
.log-row { display: flex; gap: 8px; padding: 3px 0; font-size: 10px; line-height: 1.4; }
.log-row span { flex: none; color: #52767a; font-variant-numeric: tabular-nums; }
.log-row em { font-style: normal; color: #9ab8b9; }

.queue-wrap { display: flex; flex-direction: column; gap: 5px; }
.queue-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(255, 255, 255, .06);
  font-size: 10px;
}
.q-name { flex: none; color: #8fb8b8; }
.q-unit { flex: none; color: #e2fbf7; font-weight: 700; }
.q-bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.q-bar i { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, #1aa99f, var(--teal)); box-shadow: 0 0 8px rgba(46, 230, 214, .5); }
.q-time { flex: none; width: 26px; text-align: right; color: #7f9fa2; font-variant-numeric: tabular-nums; }
.q-count { flex: none; color: var(--gold); font-size: 9px; }

.train-list { display: flex; flex-direction: column; gap: 7px; }
.train-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 74px;
  padding: 8px 9px;
  border-radius: 13px;
  text-align: left;
  background: linear-gradient(135deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .015));
  border: 1px solid rgba(255, 255, 255, .075);
  transition: transform .12s, background .12s;
}
.train-card:active { transform: scale(.985); background: rgba(46, 230, 214, .08); }
.train-card.is-off { opacity: .48; }
.unit-art {
  width: 46px; height: 46px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: radial-gradient(circle at 32% 22%, rgba(46, 230, 214, .22), rgba(7, 23, 32, .92));
  border: 1px solid rgba(46, 230, 214, .22);
}
.unit-art .ic { width: 26px; height: 26px; }
.train-main { flex: 1; min-width: 0; }
.train-title { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: #e9fffc; }
.train-title em { font-style: normal; font-size: 8px; font-weight: 600; color: #86a9ab; padding: 1px 5px; border-radius: 4px; background: rgba(255, 255, 255, .06); }
.train-sub { display: block; margin-top: 3px; font-size: 9.5px; color: #7f9fa2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.train-stats { display: flex; align-items: baseline; gap: 9px; margin-top: 4px; }
.train-stats span { display: inline-flex; align-items: baseline; gap: 3px; font-size: 8.5px; color: #6f9294; }
.train-stats i { font-style: normal; }
.train-stats b { font-size: 10px; font-weight: 800; color: #d8f6f2; font-variant-numeric: tabular-nums; }
.train-cost { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.cost-item { display: inline-flex; align-items: center; gap: 2px; font-size: 10px; font-weight: 700; }
.cost-item .ic { width: 13px; height: 13px; }
.cost-item b { font-weight: 700; }
.train-plus {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--teal);
  font-size: 17px;
  font-weight: 800;
  background: rgba(46, 230, 214, .12);
  border: 1px solid rgba(46, 230, 214, .3);
}
.train-reason { flex: none; padding: 3px 6px; border-radius: 6px; font-size: 8.5px; color: #ffabab; background: rgba(255, 80, 80, .1); white-space: nowrap; }

.build-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.build-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 126px;
  padding: 10px;
  border-radius: 13px;
  text-align: left;
  background: linear-gradient(160deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015));
  border: 1px solid rgba(255, 255, 255, .075);
  transition: transform .12s, background .12s;
}
.build-card:active { transform: scale(.98); background: rgba(46, 230, 214, .08); }
.build-card.is-off { opacity: .46; }
.build-art {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: rgba(46, 230, 214, .08);
  border: 1px solid rgba(46, 230, 214, .18);
}
.build-art .ic { width: 22px; height: 22px; }
.build-main b { display: block; font-size: 13px; }
.build-main small { display: block; margin-top: 3px; min-height: 26px; font-size: 9px; line-height: 1.45; color: #7f9fa2; }
.build-main .train-cost { margin-top: 3px; flex-wrap: wrap; gap: 6px; }
.build-main .train-cost::after { content: attr(data-time); }

.ad-card {
  position: relative;
  overflow: hidden;
  margin-top: 4px;
  padding: 18px 15px 16px;
  border-radius: 18px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(46, 230, 214, .17), transparent 60%),
    linear-gradient(160deg, #0C2A37, #07161F);
  border: 1px solid rgba(46, 230, 214, .28);
  box-shadow: inset 0 1px rgba(255, 255, 255, .05);
}
.ad-art {
  position: relative;
  width: 66px; height: 66px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: radial-gradient(circle, rgba(46, 230, 214, .26), rgba(6, 20, 28, .65));
  border: 1px solid rgba(46, 230, 214, .45);
  box-shadow: 0 0 34px rgba(46, 230, 214, .24);
}
.ad-art .ic { width: 32px; height: 32px; }
.ad-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(46, 230, 214, .2);
  animation: ringPulse 2.4s infinite;
}
@keyframes ringPulse {
  0%, 100% { transform: scale(.94); opacity: .35; }
  50% { transform: scale(1.06); opacity: .9; }
}
.ad-card h3 { margin: 0 0 6px; font-size: 16px; letter-spacing: .02em; }
.ad-card p { margin: 0 0 12px; font-size: 10.5px; line-height: 1.75; color: #93b3b5; }
.ad-card p b { color: var(--teal); }
.boost-state { margin-bottom: 11px; padding: 6px; border-radius: 8px; font-size: 10px; color: #84a5a6; background: rgba(255, 255, 255, .04); }
.boost-state.is-active { color: var(--gold); background: rgba(242, 195, 92, .08); border: 1px solid rgba(242, 195, 92, .18); }

.primary-btn {
  width: 100%;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .06em;
  color: #032421;
  background: linear-gradient(135deg, #4CF3E2, #2EE6D6 48%, #19BFB3);
  box-shadow: 0 12px 26px rgba(46, 230, 214, .22), inset 0 1px rgba(255, 255, 255, .5);
  transition: transform .12s, filter .12s;
}
.primary-btn:active { transform: scale(.985); filter: brightness(.96); }
.primary-btn .ic { width: 20px; height: 20px; }
.primary-btn.mt { margin-top: 12px; }
.ghost-btn {
  width: 100%;
  height: 46px;
  border-radius: 13px;
  font-size: 13px;
  color: #b8d8d7;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .1);
}
.ghost-btn:active { background: rgba(255, 255, 255, .09); }
.text-btn { margin-top: 8px; padding: 8px; font-size: 11px; color: #7fa2a4; }
.text-btn:active { color: var(--teal); }

/* ============ modal ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 8, 12, .74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-card {
  width: 100%;
  max-width: 380px;
  max-height: 84vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, #0C2230, #07151D);
  border: 1px solid rgba(46, 230, 214, .24);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .7), inset 0 1px rgba(255, 255, 255, .04);
}
.modal-head { display: flex; align-items: center; margin-bottom: 10px; }
.modal-head h3 { margin: 0; font-size: 17px; letter-spacing: .04em; }
.modal-head .sheet-close { margin-left: auto; }
.modal-stack { display: flex; flex-direction: column; gap: 7px; }
.help-list { display: flex; flex-direction: column; }
.help-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.help-row:last-child { border-bottom: 0; }
.help-row > b { flex: none; padding-top: 1px; font-size: 10px; font-family: ui-monospace, Menlo, monospace; color: var(--teal); }
.help-row strong { display: block; margin-bottom: 2px; font-size: 12px; color: #dff8f4; }
.help-row p { margin: 0; font-size: 10px; line-height: 1.6; color: #8faeaf; }
.nick-form p { margin: 0 0 10px; font-size: 11px; line-height: 1.6; color: #8faeaf; }
.nick-form input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border-radius: 11px;
  font-size: 16px;
  color: #eafffd;
  background: rgba(3, 12, 18, .7);
  border: 1px solid rgba(46, 230, 214, .28);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.nick-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(46, 230, 214, .1); }
.row-2 { display: flex; gap: 8px; margin-top: 10px; }
.row-2 .wide-btn { justify-content: center; }

/* ============ end screen ============ */
.end-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 16px calc(22px + var(--safe-bottom));
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 16%, rgba(46, 230, 214, .12), transparent 55%),
    rgba(3, 9, 14, .88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.end-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 24px 17px 14px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, rgba(12, 35, 45, .94), rgba(5, 15, 22, .98));
  border: 1px solid rgba(46, 230, 214, .26);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .65), inset 0 1px rgba(255, 255, 255, .05);
  overflow: hidden;
  animation: endIn .42s cubic-bezier(.2, .8, .25, 1) both;
}
.end-card::before {
  content: "";
  position: absolute;
  top: 0; left: 16%; right: 16%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(46, 230, 214, .75), transparent);
}
@keyframes endIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.end-screen.is-lose .end-card { border-color: rgba(255, 107, 107, .24); }
.end-emblem {
  width: 76px; height: 76px;
  margin: 0 auto 9px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: radial-gradient(circle, rgba(46, 230, 214, .2), rgba(3, 12, 18, .65));
  border: 1px solid rgba(46, 230, 214, .38);
  box-shadow: 0 0 44px rgba(46, 230, 214, .2);
}
.end-emblem .ic { width: 38px; height: 38px; }
.end-screen.is-lose .end-emblem {
  color: #ff8b8b;
  background: radial-gradient(circle, rgba(255, 107, 107, .18), rgba(3, 12, 18, .65));
  border-color: rgba(255, 107, 107, .38);
  box-shadow: 0 0 44px rgba(255, 107, 107, .15);
}
.end-kicker { font-size: 9px; letter-spacing: .28em; color: var(--teal); text-transform: uppercase; }
.end-screen.is-lose .end-kicker { color: #ff9b9b; }
.end-card h2 { margin: 5px 0 4px; font-size: 28px; letter-spacing: .06em; }
.end-screen.is-lose .end-card h2 { color: #ffd6d6; }
.end-card > p { margin: 0 0 14px; font-size: 10.5px; line-height: 1.7; color: #8faeaf; }
.end-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 8px; }
.end-stats div {
  padding: 8px 3px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(46, 230, 214, .06), rgba(255, 255, 255, .025));
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow: inset 0 1px rgba(255, 255, 255, .03);
}
.end-stats b { display: block; font-size: 14px; color: #eafffd; font-variant-numeric: tabular-nums; }
.end-stats small { display: block; margin-top: 2px; font-size: 8.5px; color: #7f9fa2; }
.end-score { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 2px 0 6px; }
.end-score small { font-size: 10px; color: #7f9fa2; }
.end-score b { font-size: 31px; color: var(--gold); font-variant-numeric: tabular-nums; text-shadow: 0 0 24px rgba(242, 195, 92, .4); letter-spacing: .02em; }
.end-rank { min-height: 14px; margin-bottom: 13px; font-size: 9.5px; color: #86a9a9; }
.end-actions { display: flex; flex-direction: column; gap: 8px; }

/* ============ ad ============ */
.ad-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 7, 11, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.ad-box {
  width: 100%;
  max-width: 340px;
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, #0B202B, #06131B);
  border: 1px solid rgba(46, 230, 214, .25);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .75);
}
.ad-head { display: flex; justify-content: space-between; padding: 2px 4px 9px; font-size: 9px; letter-spacing: .2em; color: #6f9294; }
.ad-screen {
  position: relative;
  overflow: hidden;
  padding: 20px 14px 16px;
  border-radius: 13px;
  background:
    radial-gradient(circle at 50% 30%, rgba(46, 230, 214, .18), transparent 60%),
    linear-gradient(180deg, #0A2733, #06141D);
  border: 1px solid rgba(46, 230, 214, .16);
}
.ad-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(46, 230, 214, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46, 230, 214, .06) 1px, transparent 1px);
  background-size: 30px 30px;
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000, transparent 72%);
  mask-image: radial-gradient(circle at 50% 40%, #000, transparent 72%);
  pointer-events: none;
}
.ad-brand { display: flex; align-items: center; justify-content: center; gap: 8px; position: relative; }
.ad-brand .ic { width: 24px; height: 24px; color: var(--teal); }
.ad-brand b { display: block; font-size: 14px; letter-spacing: .12em; }
.ad-brand small { display: block; font-size: 7px; letter-spacing: .24em; color: #5f8b8d; margin-top: 2px; }
.ad-orb {
  width: 90px; height: 90px;
  margin: 18px auto 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #bafff7, #2EE6D6 38%, #0c5c59 72%, #062028);
  box-shadow: 0 0 50px rgba(46, 230, 214, .45), inset -10px -14px 28px rgba(0, 0, 0, .45);
  animation: orbFloat 3s ease-in-out infinite;
  position: relative;
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.03); }
}
.ad-screen p { position: relative; margin: 0 0 12px; text-align: center; font-size: 10px; color: #8fb5b6; }
.ad-progress { position: relative; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.ad-progress i { display: block; width: 0; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #1aa99f, var(--teal)); box-shadow: 0 0 10px rgba(46, 230, 214, .6); transition: width .1s linear; }
.ad-box .primary-btn { margin-top: 12px; height: 46px; font-size: 13px; }
.ad-box .text-btn { display: block; margin: 4px auto 0; }

/* ============ toast / marquee ============ */
.toast {
  position: fixed;
  top: calc(var(--safe-top) + 143px);
  left: 50%;
  z-index: 90;
  max-width: calc(100vw - 44px);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.4;
  text-align: center;
  color: #e9fffc;
  background: rgba(7, 24, 33, .95);
  border: 1px solid rgba(46, 230, 214, .38);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 0 24px rgba(46, 230, 214, .1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translate(-50%, -8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.marquee {
  position: fixed;
  z-index: 25;
  border: 1px solid rgba(46, 230, 214, .9);
  background: rgba(46, 230, 214, .1);
  border-radius: 4px;
  box-shadow: inset 0 0 24px rgba(46, 230, 214, .08), 0 0 0 1px rgba(0, 0, 0, .25);
  pointer-events: none;
}

/* ============ wider screens ============ */
@media (max-width: 350px) {
  .minimap-wrap { width: 96px; height: 61px; }
  .lord-mini { padding-right: 6px; gap: 7px; }
  .lord-mini-info .xp-bar { width: 58px; }
  .lord-meta em { display: none; }
  .boost-cta { padding: 0 7px; font-size: 9px; }
  .boost-badge { padding: 0 6px; font-size: 9px; }
  .idle-btn { padding: 0 7px; }
}
@media (min-width: 720px) {
  .hud-top, .res-row { width: 560px; left: 50%; right: auto; transform: translateX(-50%); }
  .hud-bottom { width: 560px; left: 50%; right: auto; transform: translateX(-50%); }
  .start-bottom { max-width: 460px; }
  .sheet { left: 50%; right: auto; transform: translate(-50%, 103%); width: 560px; }
  .sheet.is-open { transform: translate(-50%, 0); }
}
