:root {
  color-scheme: dark;
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
  background: #08111c;
  color: #eef6ff;
  --ink: #08111c;
  --panel: rgba(15, 30, 46, .88);
  --line: rgba(170, 214, 255, .18);
  --cyan: #55e6d2;
  --blue: #6ca9ff;
  --amber: #ffc867;
  --muted: #91a6ba;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
button { font: inherit; }
button:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 18% 12%, rgba(62, 123, 156, .24), transparent 32rem),
    radial-gradient(circle at 82% 86%, rgba(70, 196, 174, .15), transparent 30rem),
    linear-gradient(145deg, #07101a, #0b1826 55%, #07111c);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}
.shell { width: min(1180px, 100%); min-height: 100dvh; margin: auto; padding: 28px clamp(20px, 5vw, 64px) 40px; display: flex; flex-direction: column; }
body[data-screen="game-screen"] .shell { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
.brand { display: flex; align-items: center; gap: 14px; min-height: 68px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid rgba(85,230,210,.5); color: var(--cyan); transform: rotate(45deg); }
.brand-mark::first-letter { transform: rotate(-45deg); }
.brand p, .brand h1 { margin: 0; }
.brand p { color: var(--muted); font-size: 10px; letter-spacing: .24em; }
.brand h1 { letter-spacing: .08em; font-size: 21px; }
.settings-toggle { margin-left: auto; min-width: 54px; min-height: 36px; padding: 0 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.035); cursor: pointer; font-size: 11px; }
.settings-toggle:hover, .settings-toggle[aria-expanded="true"] { color: var(--cyan); border-color: rgba(85,230,210,.45); }
.connection { margin-left: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 12px; }
.connection.online { color: var(--cyan); border-color: rgba(85,230,210,.35); }
.settings-panel { position: fixed; z-index: 50; top: max(82px, calc(env(safe-area-inset-top) + 64px)); right: max(18px, calc((100vw - 1180px) / 2 + 24px)); width: min(360px, calc(100vw - 36px)); padding: 22px; display: grid; gap: 14px; border-radius: 14px; }
.settings-panel[hidden] { display: none; }
.settings-heading, .setting-row, .setting-slider > span { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.settings-heading h2 { margin: -8px 0 0; font-size: 24px; }
.setting-row, .setting-slider { min-height: 52px; padding-top: 12px; border-top: 1px solid var(--line); }
.setting-row > span { display: grid; gap: 3px; }
.setting-row small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.setting-row input { width: 22px; height: 22px; accent-color: var(--cyan); }
.setting-slider { display: grid; gap: 9px; }
.setting-slider output { color: var(--cyan); font: 11px ui-monospace, monospace; }
.setting-slider input { width: 100%; accent-color: var(--cyan); }
.screen { flex: 1; padding: clamp(44px, 8vh, 92px) 0 32px; }
.screen[hidden] { display: none; }
.auth-screen { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: clamp(40px, 8vw, 110px); align-items: center; }
.eyebrow { margin: 0 0 14px; color: var(--cyan); font-weight: 800; font-size: 12px; letter-spacing: .2em; }
.hero-copy h2, .screen-heading h2, .centered h2 { margin: 0; line-height: 1.04; letter-spacing: -.04em; }
.hero-copy h2 { font-size: clamp(46px, 7vw, 86px); }
.hero-copy > p:last-child { max-width: 520px; color: var(--muted); font-size: clamp(16px, 2vw, 20px); line-height: 1.7; }
.panel { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 30px 80px rgba(0,0,0,.34); backdrop-filter: blur(18px); }
.auth-panel { padding: 30px; display: grid; gap: 12px; }
.auth-panel h3 { margin: 0 0 10px; font-size: 22px; }
.button { min-height: 52px; border: 1px solid transparent; border-radius: 10px; padding: 0 22px; cursor: pointer; font-weight: 800; transition: transform .16s ease, filter .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-2px); filter: brightness(1.08); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button.primary { color: #07131c; background: linear-gradient(135deg, var(--cyan), #7cb5ff); }
.button.secondary { color: #eef6ff; border-color: var(--line); background: rgba(255,255,255,.04); }
.button.compact { min-height: 44px; width: fit-content; }
.fine, .muted { color: var(--muted); }
.fine { margin: 8px 0 0; font-size: 12px; line-height: 1.6; }
.screen-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 42px; }
.screen-heading h2, .centered h2 { font-size: clamp(34px, 5vw, 58px); }
.profile { display: flex; align-items: center; gap: 16px; color: var(--muted); }
.text-button { border: 0; background: none; color: var(--cyan); cursor: pointer; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.mode-card { position: relative; min-height: 280px; padding: 30px; overflow: hidden; text-align: left; color: #eef6ff; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(155deg, rgba(28,50,71,.9), rgba(10,24,38,.92)); cursor: pointer; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.mode-card:hover { transform: translateY(-6px); border-color: rgba(85,230,210,.62); box-shadow: 0 24px 60px rgba(0,0,0,.26); }
.mode-card::after { content: ""; position: absolute; width: 180px; height: 180px; right: -74px; bottom: -76px; border: 28px solid rgba(108,169,255,.08); border-radius: 50%; }
.mode-art { position: absolute; z-index: 1; top: 34px; right: 22px; width: 128px; height: 128px; object-fit: cover; object-position: left center; image-rendering: pixelated; filter: drop-shadow(0 16px 20px rgba(0,0,0,.55)); transform: scale(1.65); transform-origin: right center; pointer-events: none; }
.mode-card:nth-child(2) .mode-art { object-position: 33% center; }
.mode-card:nth-child(3) .mode-art { object-position: 66% center; }
.mode-card.solo { border-color: rgba(255,200,103,.36); }
.mode-card strong, .mode-card small { position: absolute; left: 30px; z-index: 1; }
.mode-card strong { bottom: 58px; font-size: 22px; }
.mode-card small { bottom: 30px; color: var(--muted); }
.mode-count { display: block; font-size: 82px; font-weight: 900; line-height: 1; color: transparent; -webkit-text-stroke: 1px rgba(238,246,255,.34); }
.progression { margin-top: 18px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: rgba(8,22,35,.76); }
.progression-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.progression-head h3 { margin: -8px 0 0; font-size: 24px; }
.progression-stats { display: flex; align-items: center; gap: 12px; }
.progression-stats > span { min-width: 94px; display: grid; gap: 2px; }
.progression-stats small, .loadout-label { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.progression-stats strong { color: var(--amber); }
.loadout-grid { display: grid; grid-template-columns: 1.35fr .8fr .9fr; gap: 10px; margin-top: 18px; }
.loadout-panel { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); }
.loadout-label { margin: 0 0 10px; }
.deck-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.deck-slot, .defender-chip, .map-option { min-width: 0; min-height: 42px; padding: 5px; overflow: hidden; color: #dcecff; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.035); cursor: pointer; font-size: 10px; }
.deck-slot, .defender-chip { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 4px; text-align: left; }
.deck-slot img, .defender-chip img { width: 28px; height: 28px; object-fit: cover; object-position: left center; image-rendering: pixelated; }
.deck-slot span, .defender-chip span { overflow: hidden; text-overflow: ellipsis; }
.deck-slot.selected { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255,200,103,.28); }
.defender-roster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 8px; }
.defender-chip.in-deck { border-color: color-mix(in srgb, var(--defender-color) 58%, transparent); color: var(--defender-color); }
.defender-chip:disabled, .map-option:disabled { cursor: not-allowed; opacity: .36; }
.map-options { display: grid; gap: 7px; }
.map-option { position: relative; min-height: 54px; padding-left: 58px; text-align: left; background-image: linear-gradient(90deg, rgba(8,17,28,.2), rgba(8,17,28,.92) 55%), var(--map-art); background-size: 54px 100%, 54px 54px; background-repeat: no-repeat; }
.map-option.active { color: var(--cyan); border-color: rgba(85,230,210,.55); background: rgba(85,230,210,.08); }
.recent-matches { display: grid; gap: 6px; color: var(--muted); font-size: 10px; }
.recent-match { display: flex; justify-content: space-between; gap: 8px; padding-bottom: 5px; border-bottom: 1px solid rgba(255,255,255,.06); }
.recent-match.win b { color: var(--cyan); }
.recent-match.lose b { color: #ff8fa3; }
.centered { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.queue-orbit { position: relative; width: 150px; height: 150px; margin-bottom: 36px; border: 1px solid var(--line); border-radius: 50%; animation: spin 8s linear infinite; }
.queue-orbit::before { content: ""; position: absolute; inset: 32px; border: 1px solid rgba(85,230,210,.3); border-radius: 50%; }
.queue-orbit span { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 24px var(--cyan); }
.queue-orbit span:nth-child(1) { top: -7px; left: 68px; }
.queue-orbit span:nth-child(2) { right: -7px; top: 68px; }
.queue-orbit span:nth-child(3) { bottom: -7px; left: 68px; }
.queue-orbit span:nth-child(4) { left: -7px; top: 68px; }
.centered .muted { min-height: 28px; margin: 18px 0 28px; }
.match-id { color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; }
.ready-stage { min-height: 360px; display: grid; place-items: center; position: relative; border: 1px solid var(--line); border-radius: 18px; background: radial-gradient(circle, rgba(85,230,210,.12), transparent 28%), rgba(6,16,26,.55); overflow: hidden; }
.match-stage { position: absolute; top: 22px; margin: 0; color: var(--cyan); font-size: 13px; font-weight: 900; letter-spacing: .18em; z-index: 2; }
.core { position: absolute; width: 110px; height: 110px; border: 1px solid rgba(85,230,210,.5); transform: rotate(45deg); animation: breathe 2.4s ease-in-out infinite; }
.core span { position: absolute; inset: 22px; border: 1px solid rgba(108,169,255,.55); }
.roster { width: min(760px, 90%); display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; z-index: 1; }
.roster-card { min-height: 112px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; background: rgba(11,26,41,.9); }
.roster-card span { color: var(--cyan); font: 12px ui-monospace, monospace; }
.roster-card strong { overflow: hidden; text-overflow: ellipsis; }
.roster-card small { color: var(--muted); font-size: 11px; }
.roster-card.offline { opacity: .48; border-style: dashed; }
.ready-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); }
.game-screen { padding-top: 22px; }
.game-hud { display: grid; grid-template-columns: 130px 160px minmax(220px, 1fr) 120px; gap: 10px; margin-bottom: 12px; }
.hud-block, .core-meter { min-height: 62px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(9,23,36,.86); }
.hud-block { display: flex; flex-direction: column; justify-content: space-between; }
.hud-block small, .core-meter small { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.hud-block strong { font-size: 17px; }
.hud-block.essence strong { color: var(--amber); }
.core-meter > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.core-meter small b { margin-left: 6px; color: #8fb9ff; font-size: 9px; }
.core-meter > span { display: block; height: 5px; margin-top: 6px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.08); }
.core-meter > span i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--blue)); transition: width .25s ease; }
.core-meter .bond-label { margin-top: 6px; }
.core-meter .bond-label strong { color: var(--amber); font-size: 11px; }
.core-meter > .bond-track { height: 3px; margin-top: 3px; }
.core-meter > .bond-track i { width: 0; background: linear-gradient(90deg, #c795ff, var(--amber)); }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 12px; min-height: 0; }
.board-shell { position: relative; min-width: 0; height: clamp(430px, calc(100dvh - 270px), 570px); overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #07131f; box-shadow: 0 24px 70px rgba(0,0,0,.26); }
#td-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: manipulation; cursor: crosshair; outline: none; }
#td-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--amber); }
.game-controls { display: grid; align-content: start; gap: 9px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(10,25,39,.9); }
.game-controls h3 { margin: -6px 0 8px; }
.team-tools { display: grid; gap: 9px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.team-tools[hidden] { display: none; }
.team-roster { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.team-member { min-width: 0; padding: 6px 8px; overflow: hidden; color: var(--player-color); text-overflow: ellipsis; white-space: nowrap; border: 1px solid color-mix(in srgb, var(--player-color) 45%, transparent); border-radius: 7px; background: color-mix(in srgb, var(--player-color) 8%, transparent); font-size: 10px; }
.team-member.offline { opacity: .45; border-style: dashed; }
.team-member.me::after { content: " · 나"; color: var(--muted); }
.signal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.signal-grid button { min-height: 34px; padding: 0 7px; color: #dcecff; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.04); cursor: pointer; font-size: 10px; }
.signal-grid button:hover { border-color: rgba(85,230,210,.55); background: rgba(85,230,210,.08); }
.team-signal { position: fixed; z-index: 20; top: max(16px, env(safe-area-inset-top)); left: 50%; max-width: calc(100% - 32px); padding: 9px 14px; overflow: hidden; color: #08111c; text-overflow: ellipsis; white-space: nowrap; border-radius: 99px; background: linear-gradient(135deg, var(--amber), #f4e6b0); box-shadow: 0 10px 30px rgba(0,0,0,.28); font-size: 12px; font-weight: 900; transform: translateX(-50%); animation: signal-pop .24s ease-out; }
.team-signal[hidden] { display: none; }
.relic-choice { position: absolute; inset: 0; z-index: 6; display: grid; align-content: center; padding: clamp(20px, 6vw, 60px); background: rgba(5,14,23,.9); backdrop-filter: blur(10px); }
.relic-choice[hidden] { display: none; }
.relic-choice h2 { max-width: 700px; margin: 0 0 22px; font-size: clamp(28px, 4vw, 44px); line-height: 1.05; }
.relic-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.relic-option { min-height: 130px; padding: 16px; text-align: left; color: #eef6ff; border: 1px solid rgba(199,149,255,.38); border-radius: 11px; background: linear-gradient(145deg, rgba(67,43,89,.72), rgba(16,30,48,.92)); cursor: pointer; }
.relic-option:hover { transform: translateY(-3px); border-color: var(--amber); }
.relic-option strong, .relic-option small { display: block; }
.relic-option small { margin-top: 8px; color: #cbbadb; line-height: 1.45; }
.upgrade { min-height: 58px; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 0 11px; color: #eef6ff; border: 1px solid var(--line); border-left: 4px solid currentColor; border-radius: 9px; background: rgba(255,255,255,.035); cursor: pointer; text-align: left; }
.upgrade img { width: 34px; height: 34px; object-fit: cover; object-position: left center; image-rendering: pixelated; filter: drop-shadow(0 4px 6px rgba(0,0,0,.5)); }
.upgrade[hidden] { display: none; }
.upgrade:hover { background: rgba(255,255,255,.075); }
.upgrade:disabled { opacity: .4; cursor: not-allowed; }
.upgrade small { color: var(--muted); }
.upgrade.ember { color: #ff9c64; }
.upgrade.frost { color: #72cfff; }
.upgrade.thorn { color: #78e39b; }
.upgrade.pulse { color: #c795ff; }
.upgrade.tidal { color: #4ce0df; }
.upgrade.stone { color: #d5ad7d; }
.upgrade.bloom { color: #ff8fc7; }
.upgrade.volt { color: #ffe15f; }
.upgrade span, .upgrade small { color: inherit; }
.selection-help { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.result-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; text-align: center; background: rgba(5,14,23,.86); backdrop-filter: blur(8px); }
.result-overlay[hidden] { display: none; }
.result-overlay h2 { margin: 0; font-size: clamp(42px, 7vw, 76px); }
.result-overlay > p:last-child { color: var(--amber); font-weight: 800; }
.result-overlay.win { background: radial-gradient(circle at 50% 54%, rgba(85,230,210,.22), transparent 34%), rgba(5,14,23,.84); animation: result-in .55s cubic-bezier(.2,.8,.2,1); }
.result-overlay.lose { background: radial-gradient(circle at 50% 54%, rgba(255,113,135,.2), transparent 34%), rgba(5,14,23,.9); animation: result-in .4s ease-out; }
.boss-announcement { position: absolute; z-index: 4; top: 16%; left: 50%; width: min(88%, 520px); padding: 12px 20px; color: #fff3ba; text-align: center; border-block: 1px solid rgba(255,200,103,.55); background: linear-gradient(90deg, transparent, rgba(45,18,29,.88), transparent); text-shadow: 0 2px 12px #000; transform: translateX(-50%); animation: boss-in .55s ease-out; pointer-events: none; }
.boss-announcement[hidden] { display: none; }
.status { min-height: 24px; margin: 0; color: var(--muted); text-align: center; font-size: 13px; }
.status.error { color: #ff8a91; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: rotate(45deg) scale(1.08); box-shadow: 0 0 44px rgba(85,230,210,.22); } }
@keyframes signal-pop { from { opacity: 0; transform: translate(-50%, -8px) scale(.94); } }
@keyframes result-in { from { opacity: 0; transform: scale(1.08); } }
@keyframes boss-in { from { opacity: 0; transform: translate(-50%, -20px) scale(.94); } }
@keyframes shake-soft { 25% { transform: translate(2px, -1px); } 50% { transform: translate(-2px, 1px); } 75% { transform: translate(1px, 1px); } }
@keyframes shake-strong { 18% { transform: translate(5px, -3px); } 36% { transform: translate(-6px, 2px); } 54% { transform: translate(4px, 4px); } 72% { transform: translate(-3px, -2px); } }
body.shake-soft .board-shell { animation: shake-soft .2s linear; }
body.shake-strong .board-shell { animation: shake-strong .4s linear; }
@media (max-width: 760px) {
  .shell { padding: 18px 18px 30px; }
  .auth-screen { grid-template-columns: 1fr; align-content: center; }
  .hero-copy h2 { font-size: clamp(44px, 13vw, 64px); }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 156px; padding: 24px 30px; }
  .mode-art { top: 10px; right: 18px; width: 112px; height: 112px; transform: scale(1.35); }
  .mode-count { position: absolute; top: 20px; right: 26px; font-size: 72px; opacity: .72; }
  .progression-head, .progression-stats { align-items: stretch; flex-direction: column; }
  .progression-stats { display: grid; grid-template-columns: 1fr 1fr; }
  .progression-stats .button { grid-column: 1 / -1; width: 100%; }
  .loadout-grid { grid-template-columns: 1fr; }
  .defender-roster { grid-template-columns: repeat(4, 1fr); }
  .screen-heading { align-items: start; flex-direction: column; }
  .profile { align-self: stretch; justify-content: space-between; }
  .roster { grid-template-columns: repeat(2, 1fr); }
  .ready-footer { align-items: stretch; flex-direction: column; }
  .ready-footer .button { width: 100%; }
  .game-screen { padding-top: 14px; }
  .game-hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .game-hud .hud-block { padding-inline: 10px; }
  .game-hud .hud-block strong { font-size: 14px; white-space: nowrap; }
  .core-meter { grid-column: 1 / -1; grid-row: 2; }
  .game-layout { grid-template-columns: 1fr; min-height: 0; }
  .board-shell { height: 430px; min-height: 430px; }
  .game-controls { grid-template-columns: 1fr 1fr; padding: 14px; }
  .game-controls > div, .team-tools, .selection-help { grid-column: 1 / -1; }
  .upgrade { min-height: 52px; }
  .relic-options { grid-template-columns: 1fr; }
  .relic-option { min-height: 82px; }
}
@media (max-width: 430px) {
  .brand { gap: 9px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand h1 { font-size: 17px; }
  .settings-toggle { min-width: 48px; padding-inline: 8px; }
  .connection { padding-inline: 9px; }
  .board-shell { height: 410px; min-height: 410px; }
  .upgrade { min-height: 56px; grid-template-columns: 30px minmax(0, 1fr); }
  .upgrade img { width: 30px; height: 30px; }
  .upgrade small { grid-column: 1 / -1; margin-top: -10px; padding-left: 38px; font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }

/* NESTLINE generated-art presentation pass */
:root {
  --ink: #17233d;
  --panel: rgba(23, 35, 61, .94);
  --line: rgba(217, 207, 183, .24);
  --cyan: #67b99a;
  --blue: #6ab7c8;
  --amber: #e3b65c;
  --coral: #d96767;
  --cream: #d9cfb7;
  --forest: #3f6b4f;
  --muted: #aebca8;
}

html { image-rendering: pixelated; }
body {
  color: #f4eedc;
  background:
    linear-gradient(rgba(10, 20, 28, .82), rgba(12, 27, 27, .9)),
    url('/td/assets/maps/rootway-background.png') center / cover fixed;
  letter-spacing: .01em;
}
body::before {
  opacity: .16;
  background-image:
    linear-gradient(rgba(217,207,183,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217,207,183,.07) 1px, transparent 1px);
  background-size: 4px 4px;
  mask-image: none;
}
.shell { width: min(1280px, 100%); }
.brand { position: relative; z-index: 10; }
.brand-mark { width: 54px; height: 54px; border: 0; transform: none; image-rendering: pixelated; }
.brand h1 { color: var(--cream); font-weight: 950; letter-spacing: .13em; text-shadow: 0 3px 0 #101727; }
.brand p { color: var(--cyan); font-weight: 900; }
.connection, .settings-toggle {
  color: var(--cream);
  border: 2px solid #895e3f;
  border-radius: 6px;
  background: #17233d;
  box-shadow: 0 3px 0 #0d1423;
}
.settings-toggle { display: flex; align-items: center; gap: 5px; min-width: 72px; min-height: 44px; padding: 3px 9px 3px 4px; }
.settings-icon { width: 28px; height: 28px; }
.connection.online { color: #a9efd1; border-color: #67b99a; }
.screen { position: relative; }
.eyebrow { color: #8fe2bd; text-shadow: 0 2px 0 #17233d; }
.hero-copy { position: relative; z-index: 1; min-height: 390px; display: flex; flex-direction: column; justify-content: center; padding-right: 190px; }
.hero-copy h2, .screen-heading h2, .centered h2 { color: #f4eedc; text-shadow: 0 4px 0 #17233d, 2px 0 0 #17233d, -2px 0 0 #17233d; }
.hero-copy > p:last-child, .fine, .muted { color: #b8c6b3; }
.hero-mori { position: absolute; right: -74px; bottom: 14px; z-index: -1; width: 300px; height: 300px; filter: drop-shadow(0 16px 16px rgba(5,12,18,.6)); animation: mori-float 3.2s steps(8) infinite; }
.settings-mori { flex: 0 0 88px; width: 88px; height: 88px; margin: -22px 0 -14px -12px; }
.settings-heading { justify-content: flex-start; }
.settings-heading .text-button { margin-left: auto; }
.queue-mori { width: 150px; height: 150px; margin-bottom: -88px; z-index: 2; filter: drop-shadow(0 12px 12px rgba(0,0,0,.5)); animation: mori-float 2.8s steps(8) infinite; }
.ready-mori { position: absolute; right: 7%; bottom: -8px; width: 190px; height: 190px; opacity: .92; filter: drop-shadow(0 15px 14px rgba(0,0,0,.55)); }

.panel, .mode-card, .progression, .loadout-panel, .ready-stage, .game-controls,
.relic-option, .roster-card, .board-shell {
  background: rgba(17, 29, 43, .92);
  border-color: rgba(217,207,183,.24);
  backdrop-filter: none;
}
.generated-ui-ready .panel,
.generated-ui-ready .mode-card,
.generated-ui-ready .progression,
.generated-ui-ready .ready-stage,
.generated-ui-ready .game-controls,
.generated-ui-ready .relic-option {
  border: 14px solid transparent;
  border-image-source: var(--panel-frame-image);
  border-image-slice: 12% fill;
  border-image-width: 14px;
  background: transparent;
}
.auth-panel { padding: 34px; box-shadow: 0 20px 0 rgba(7,13,21,.35), 0 34px 70px rgba(0,0,0,.3); }
.button {
  border: 3px solid #17233d;
  border-radius: 7px;
  box-shadow: inset 0 0 0 2px rgba(244,238,220,.24), 0 5px 0 #0d1423;
  text-shadow: 0 1px 0 rgba(0,0,0,.28);
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px rgba(244,238,220,.2), 0 2px 0 #0d1423; }
.button.primary { color: #17233d; background: linear-gradient(#8ed9b5, #67b99a); }
.button.secondary { color: #f4eedc; border-color: #735038; background: linear-gradient(#263751, #17233d); }
.text-button { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding-inline: 6px; color: #8fe2bd; font-weight: 800; text-decoration: underline dotted rgba(143,226,189,.55); text-underline-offset: 4px; }

.mode-grid { gap: 22px; }
.mode-card { min-height: 300px; padding: 34px; color: #f4eedc; box-shadow: 0 12px 0 rgba(8,15,22,.45); }
.mode-card::after { border-color: rgba(103,185,154,.12); }
.mode-card:hover { transform: translateY(-7px) rotate(-.3deg); border-color: transparent; box-shadow: 0 20px 0 rgba(8,15,22,.32); }
.mode-art { top: 20px; right: 16px; width: 156px; height: 156px; object-fit: initial; transform: none; animation: nestling-bob 2.2s steps(6) infinite; }
.mode-card:nth-child(2) .mode-art, .mode-card:nth-child(3) .mode-art { object-position: initial; animation-delay: -.7s; }
.mode-card:nth-child(3) .mode-art { animation-delay: -1.4s; }
.mode-count { color: rgba(227,182,92,.12); -webkit-text-stroke: 2px rgba(227,182,92,.68); }
.mode-card strong { color: #f4eedc; text-shadow: 0 2px 0 #101727; }
.mode-card small { color: #afc4b4; }
.progression { box-shadow: 0 9px 0 rgba(8,15,22,.42); }
.loadout-panel { border: 2px solid rgba(137,94,63,.58); background: rgba(16,30,42,.76); box-shadow: inset 0 0 0 2px rgba(103,185,154,.06); }
.deck-slot, .defender-chip, .map-option, .signal-grid button {
  color: #f4eedc;
  border: 2px solid rgba(137,94,63,.7);
  border-radius: 5px;
  background-color: rgba(23,35,61,.92);
  box-shadow: 0 2px 0 #0d1423;
}
.deck-slot canvas, .defender-chip canvas { width: 34px; height: 34px; image-rendering: pixelated; }
.deck-slot, .defender-chip { grid-template-columns: 34px minmax(0, 1fr); }
.deck-slot.selected { border-color: #e3b65c; box-shadow: 0 0 0 2px rgba(227,182,92,.28), 0 3px 0 #0d1423; }
.map-option { min-height: 64px; padding-left: 74px; background-size: 68px 100%, 68px 68px; background-position: left, left center; }
.map-option.active { color: #a9efd1; border-color: #67b99a; background-image: linear-gradient(90deg, rgba(23,35,61,.08), rgba(23,35,61,.94) 64%), var(--map-art); }

.queue-orbit { border: 4px solid #895e3f; background: rgba(23,35,61,.7); box-shadow: inset 0 0 0 8px rgba(103,185,154,.08), 0 10px 0 rgba(8,15,22,.4); }
.queue-orbit::before { border: 3px dashed rgba(103,185,154,.66); }
.queue-orbit span { border-radius: 3px; background: #e3b65c; box-shadow: 0 0 16px #e3b65c; }
.ready-stage { background: rgba(16,31,42,.9); box-shadow: 0 14px 0 rgba(7,13,21,.36); }
.core { border: 4px solid #67b99a; border-radius: 24px; background: rgba(103,185,154,.12); box-shadow: 0 0 38px rgba(103,185,154,.26); }
.core span { border: 3px solid #e3b65c; border-radius: 12px; }
.roster-card { border: 3px solid rgba(137,94,63,.75); border-radius: 8px; box-shadow: 0 5px 0 #0d1423; }

body[data-screen="game-screen"] { background: #111c27; }
body[data-screen="game-screen"] .shell { width: min(1500px, 100%); padding-top: 10px; }
body[data-screen="game-screen"] .brand { min-height: 50px; }
.game-hud { grid-template-columns: 150px 180px minmax(260px, 1fr) 130px; }
.hud-block, .core-meter { position: relative; min-height: 70px; padding: 12px 14px 10px 50px; border: 3px solid #735038; border-radius: 7px; background: #17233d; box-shadow: inset 0 0 0 2px rgba(103,185,154,.12), 0 4px 0 #0b1320; }
.hud-icon { position: absolute; left: 8px; top: 50%; width: 36px; height: 36px; transform: translateY(-50%); }
.core-meter .core-icon { width: 42px; height: 42px; }
.hud-block small, .core-meter small { color: #afc4b4; }
.hud-block strong, .core-meter strong { color: #f4eedc; text-shadow: 0 2px 0 #101727; }
.core-meter > span:not(.hud-icon) { border: 1px solid rgba(217,207,183,.15); border-radius: 2px; }
.core-meter > span i { border-radius: 1px; background: linear-gradient(90deg, #67b99a, #6ab7c8); }
.game-layout { grid-template-columns: minmax(0, 1fr) 272px; }
.board-shell { height: clamp(500px, calc(100dvh - 210px), 690px); border: 5px solid #493824; border-radius: 9px; box-shadow: inset 0 0 0 3px #17233d, 0 12px 0 #080f18; }
.game-controls { padding: 20px; box-shadow: 0 8px 0 #080f18; }
.team-member { border-radius: 4px; background: rgba(23,35,61,.9); }
.signal-grid button:hover { border-color: #67b99a; background: rgba(103,185,154,.15); }
.upgrade { min-height: 62px; grid-template-columns: 42px minmax(0, 1fr) auto; border: 2px solid #735038; border-left: 5px solid currentColor; border-radius: 6px; background: rgba(23,35,61,.95); box-shadow: 0 3px 0 #0b1320; }
.upgrade canvas { width: 42px; height: 42px; filter: drop-shadow(0 4px 4px rgba(0,0,0,.45)); image-rendering: pixelated; }
.upgrade:hover { transform: translateY(-2px); background: #243650; }
.team-signal { color: #17233d; border: 3px solid #17233d; border-radius: 6px; background: #e3b65c; box-shadow: 0 6px 0 #0b1320; }
.relic-choice, .result-overlay { background: rgba(11,21,31,.9); backdrop-filter: blur(3px); }
.overlay-icon { width: 72px; height: 72px; margin-bottom: 4px; }
.relic-option { position: relative; min-height: 156px; padding: 24px; box-shadow: 0 7px 0 rgba(7,13,21,.5); }
.relic-icon { float: right; width: 58px; height: 58px; margin: -10px -8px 4px 10px; }
.relic-option:hover { transform: translateY(-5px); }
.result-overlay { grid-template-columns: auto; }
.result-mori { width: 190px; height: 190px; margin: -80px auto -12px; filter: drop-shadow(0 14px 12px rgba(0,0,0,.55)); animation: result-mori-in .55s steps(6); }
.result-overlay.win .result-mori-lose, .result-overlay.lose .result-mori-win { display: none; }
.result-overlay h2 { color: #f4eedc; text-shadow: 0 5px 0 #17233d; }
.boss-announcement { color: #fff1c8; border: 4px solid #d96767; border-radius: 7px; background: #3a2028; box-shadow: 0 6px 0 rgba(8,12,18,.65); }

@keyframes mori-float { 50% { transform: translateY(-8px) rotate(1deg); } }
@keyframes nestling-bob { 50% { transform: translateY(-7px) scale(1.03); } }
@keyframes result-mori-in { from { opacity: 0; transform: translateY(20px) scale(.8); } }

@media (max-width: 760px) {
  body { background-attachment: scroll; }
  .shell { padding: 12px 12px 24px; }
  .brand { min-height: 56px; }
  .brand-mark { width: 42px; height: 42px; }
  .auth-screen { gap: 18px; padding-top: 20px; }
  .hero-copy { min-height: 320px; padding-right: 124px; }
  .hero-mori { right: -54px; bottom: 8px; width: 210px; height: 210px; opacity: .9; }
  .auth-panel { padding: 24px; }
  .mode-card { min-height: 180px; }
  .mode-art { top: 9px; right: 8px; width: 138px; height: 138px; }
  .loadout-grid { gap: 12px; }
  .ready-mori { right: -24px; width: 150px; height: 150px; opacity: .72; }
  body[data-screen="game-screen"] .shell { padding-inline: 6px; }
  body[data-screen="game-screen"] .brand { min-height: 42px; }
  .game-hud { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .game-hud .hud-block { min-height: 58px; padding: 8px 6px 7px 40px; }
  .game-hud .hud-block small { font-size: 8px; }
  .game-hud .hud-block strong { font-size: 12px; }
  .hud-icon { left: 4px; width: 30px; height: 30px; }
  .core-meter { min-height: 66px; padding: 8px 10px 7px 45px; }
  .core-meter .core-icon { left: 3px; width: 38px; height: 38px; }
  .game-layout { grid-template-columns: 1fr; }
  .board-shell { height: min(54dvh, 470px); min-height: 390px; }
  .game-controls { grid-template-columns: 1fr 1fr; padding: 14px; }
  .upgrade { min-height: 58px; grid-template-columns: 38px minmax(0, 1fr); }
  .upgrade canvas { width: 38px; height: 38px; }
  .relic-choice { padding: 16px; overflow: auto; }
  .relic-options { gap: 8px; }
  .relic-option { min-height: 98px; padding: 16px; }
  .result-mori { width: 150px; height: 150px; }
}

@media (max-width: 430px) {
  .brand p { display: none; }
  .connection { font-size: 10px; }
  .hero-copy { min-height: 290px; padding-right: 92px; }
  .hero-copy h2 { font-size: 41px; }
  .hero-mori { right: -54px; width: 176px; height: 176px; }
  .defender-roster { grid-template-columns: repeat(2, 1fr); }
  .deck-slots { grid-template-columns: repeat(5, minmax(58px, 1fr)); overflow-x: auto; padding-bottom: 5px; }
  .board-shell { height: 410px; min-height: 410px; }
  .game-controls { padding: 10px; gap: 7px; }
  .upgrade { min-height: 62px; }
  .settings-panel { top: 62px; right: 8px; width: calc(100vw - 16px); }
}
