/* THE DOOR HOLDS — dark tavern / teal excision */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #07090c; color: #e8e2d4; font-family: Georgia, 'Times New Roman', serif; overflow: hidden; }
#td-wrap { position: fixed; inset: 0; }
#td-canvas { width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#td-hud { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: linear-gradient(180deg, rgba(5,8,10,.88), rgba(5,8,10,0)); z-index: 5; pointer-events: none; }
#td-hud .hud-left, #td-hud .hud-right { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.hud-chip { background: rgba(16,22,26,.9); border: 1px solid #3d4a4a; border-radius: 8px; padding: 6px 12px; font-size: 17px; }
.hud-chip.heart { border-color: #7a3038; }
.hud-btn { background: #1a2422; color: #e8e2d4; border: 1px solid #4a5a54; border-radius: 8px; padding: 8px 14px; font-size: 16px; cursor: pointer; font-family: inherit; }
.hud-btn:hover { background: #24322e; }
.hud-btn.primary { background: #5d3b16; border-color: #c98f2e; }
.hud-btn.primary:hover { background: #75501d; }
.hud-btn:disabled { opacity: .45; cursor: default; }

#td-banner { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); background: rgba(10,16,18,.92); border: 1px solid #2e7f86; color: #bfeef2; padding: 8px 22px; border-radius: 10px; font-size: 19px; z-index: 6; pointer-events: none; }

#td-panel { position: absolute; right: 14px; bottom: 14px; width: 320px; background: rgba(10,14,16,.96); border: 1px solid #46555a; border-radius: 12px; padding: 14px; z-index: 7; }
#td-panel h3 { margin: 0 0 4px; font-size: 20px; color: #ffd98a; }
#td-panel .sub { color: #9fb3ab; font-size: 14px; margin-bottom: 10px; }
.build-btn, .upg-btn { display: block; width: 100%; text-align: left; background: #182220; border: 1px solid #41534c; color: #e8e2d4; border-radius: 8px; padding: 9px 11px; margin: 6px 0; cursor: pointer; font-family: inherit; font-size: 15px; }
.build-btn:hover, .upg-btn:hover { background: #22302b; }
.build-btn:disabled, .upg-btn:disabled { opacity: .45; cursor: default; }
.build-btn b, .upg-btn b { color: #ffd98a; }
.upg-btn .pips { float: right; letter-spacing: 2px; color: #57e6d9; }
.panel-row { display: flex; gap: 8px; }
.panel-row .upg-btn { flex: 1; }
#td-panel .close-line { text-align: right; }
#td-panel .close-line button { background: none; border: none; color: #9fb3ab; cursor: pointer; font-size: 15px; font-family: inherit; }

#td-menu, #td-tree, #td-end { position: absolute; inset: 0; background: rgba(4,6,8,.9); z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; overflow-y: auto; }
/* Batch 3: the story modal is a comms card docked over the live field. */
#td-story { position: absolute; left: 16px; bottom: 16px; z-index: 11; width: min(440px, calc(100vw - 32px)); background: rgba(6,8,10,.9); border: 1px solid #6b5322; border-radius: 12px; padding: 14px 16px; text-align: left; box-shadow: 0 18px 50px rgba(0,0,0,.6); }
#td-story #story-who { margin-bottom: 6px; }
#td-story #story-text { font-size: 17.5px; line-height: 1.5; max-width: none; margin-bottom: 12px; }
#td-menu h1 { font-size: 54px; letter-spacing: 4px; margin: 0 0 6px; color: #ffd98a; text-shadow: 0 0 34px rgba(255,180,60,.35); }
#td-menu h2, #td-tree h2 { font-size: 21px; color: #bfeef2; margin: 18px 0 8px; letter-spacing: 2px; }
.tag { color: #b9c6bd; font-size: 18px; line-height: 1.45; margin: 4px 0; }
.tag em { color: #57e6d9; font-style: normal; }
#menu-marks, #tree-marks2 { color: #ffd98a; font-size: 17px; }
#menu-levels, #menu-classes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 1060px; }
.pick-card { width: 192px; background: #10181a; border: 2px solid #37474a; border-radius: 12px; padding: 12px; cursor: pointer; text-align: left; }
.pick-card:hover { border-color: #6d8579; }
.pick-card.sel { border-color: #c98f2e; background: #1b1710; }
.pick-card.locked { opacity: .45; cursor: default; }
.pick-card h4 { margin: 0 0 5px; font-size: 17px; color: #ffd98a; }
.pick-card p { margin: 0; font-size: 13.5px; color: #a9bab0; line-height: 1.4; }
.pick-card .endless-tag { color: #57e6d9; font-size: 12.5px; }
.menu-row { display: flex; gap: 12px; margin-top: 22px; }
.big-btn { background: #5d3b16; border: 1px solid #c98f2e; color: #ffe9bb; border-radius: 10px; padding: 13px 30px; font-size: 19px; cursor: pointer; font-family: inherit; }
.big-btn:hover { background: #75501d; }
.big-btn.alt { background: #14201e; border-color: #2e7f86; color: #bfeef2; }
.big-btn.alt:hover { background: #1c2c29; }
.fine { color: #77877e; font-size: 13.5px; margin-top: 16px; }

#tree-branches { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 1120px; margin: 10px 0 18px; }
.branch { width: 340px; background: #0d1416; border: 1px solid #37474a; border-radius: 12px; padding: 12px; text-align: left; }
.branch h3 { margin: 0 0 8px; color: #ffd98a; font-size: 19px; letter-spacing: 2px; }
.perk { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 8px; margin: 4px 0; background: #131e20; }
.perk.owned { background: #1c2a1e; border: 1px solid #3f6b3a; }
.perk.locked { opacity: .5; }
.perk .perk-name { font-size: 14.5px; }
.perk .perk-name small { display: block; color: #93a89c; font-size: 12.5px; }
.perk button { background: #5d3b16; border: 1px solid #c98f2e; color: #ffe9bb; border-radius: 7px; padding: 5px 10px; cursor: pointer; font-family: inherit; font-size: 13.5px; white-space: nowrap; }
.perk button:disabled { opacity: .4; cursor: default; }
.perk .owned-tag { color: #8fe08a; font-size: 13.5px; white-space: nowrap; }

/* Immersion Batch 2c: the grove — standing stones over a ground line,
 * the old perk rows retired to a reading ledger below each plot. */
.branch.grove { width: 520px; background: linear-gradient(180deg, #0b1210 0%, #0d1416 62%, #171208 62.2%, #100c06 100%); }
.stones { display: flex; gap: 10px; align-items: flex-end; min-height: 158px; padding: 8px 2px 0; border-bottom: 6px solid #241a0d; }
.stone { flex: 1 1 0; min-width: 0; height: 138px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 14px 4px 8px; text-align: center;
  background: linear-gradient(180deg, #5a6660, #39433e 70%, #2c332f); border: 1px solid #202825; border-bottom: none;
  border-radius: 48% 48% 6px 6px / 26% 26% 5px 5px; color: #d8e2da; box-shadow: inset 0 0 18px rgba(0,0,0,.45); }
.stone .stone-name { font-size: 13.5px; line-height: 1.25; letter-spacing: .4px; text-shadow: 0 1px 3px rgba(0,0,0,.8); overflow-wrap: break-word; }
.stone .stone-cost { background: #5d3b16; border: 1px solid #c98f2e; color: #ffe9bb; border-radius: 7px; padding: 4px 8px; font-size: 13px; white-space: nowrap; }
.stone .stone-state { font-size: 12.5px; color: #a9bab0; letter-spacing: 1px; }
.stone.avail { cursor: pointer; }
.stone.avail:hover { border-color: #c98f2e; box-shadow: inset 0 0 18px rgba(0,0,0,.45), 0 0 14px rgba(201,143,46,.35); }
.stone.avail.poor .stone-cost { opacity: .45; }
.stone.locked { height: 92px; transform: translateY(30px); opacity: .5; filter: saturate(.4); }
.stone.owned { background: linear-gradient(180deg, #7d8a6a, #4c5a41 70%, #39452f); border-color: #3f6b3a; color: #ffeec2;
  box-shadow: inset 0 0 18px rgba(0,0,0,.35), 0 0 16px rgba(143,224,138,.30); }
.stone.owned .stone-state { color: #8fe08a; }
.stone.rising { animation: stoneRise .6s cubic-bezier(.2,.9,.3,1.2); }
@keyframes stoneRise { 0% { transform: translateY(30px); filter: saturate(.4) brightness(.7); } 60% { transform: translateY(-4px); } 100% { transform: translateY(0); filter: none; } }
.branch.grove .ledger { margin-top: 10px; }

#story-who { color: #57e6d9; letter-spacing: 3px; font-size: 15px; margin-bottom: 10px; }
#story-text { font-size: 23px; line-height: 1.55; max-width: 760px; color: #f2ead6; margin-bottom: 24px; }
#td-end h2 { font-size: 40px; color: #ffd98a; margin: 0 0 10px; }
#td-end p { font-size: 19px; color: #b9c6bd; max-width: 640px; line-height: 1.5; margin-bottom: 22px; }

/* #868 — MENU IDENTITY: the Door vista through a vignette, hanging signs, sigils */
#td-menu { background: radial-gradient(120% 90% at 50% 40%, rgba(4,6,8,.04) 0%, rgba(4,6,8,.42) 52%, rgba(3,4,6,.93) 100%), linear-gradient(180deg, rgba(3,4,6,.68) 0%, rgba(3,4,6,0) 20%, rgba(3,4,6,0) 72%, rgba(3,4,6,.9) 100%); }
.menu-sigil { margin-bottom: 10px; filter: drop-shadow(0 0 14px rgba(87,230,217,.35)); }
.menu-sigil svg { width: 52px; height: 52px; display: block; }
#td-menu h1 { display: inline-block; padding: 10px 36px 13px; border: 2px solid #c98f2e; outline: 1px solid rgba(201,143,46,.4); outline-offset: 5px; background: linear-gradient(180deg, rgba(28,20,10,.88), rgba(10,8,5,.93)); box-shadow: 0 12px 34px rgba(0,0,0,.65), inset 0 0 26px rgba(201,143,46,.13); }
#td-menu h2 { display: flex; align-items: center; gap: 14px; }
#td-menu h2::before, #td-menu h2::after { content: ''; height: 1px; width: 76px; }
#td-menu h2::before { background: linear-gradient(90deg, transparent, #8a6a26); }
#td-menu h2::after { background: linear-gradient(90deg, #8a6a26, transparent); }
#menu-levels .pick-card { position: relative; padding-top: 21px; background: linear-gradient(180deg, #2b2114, #17110a 62%, #100b06); border: 1px solid #6b5322; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.55), inset 0 16px 24px rgba(255,190,90,.05), 0 10px 22px rgba(0,0,0,.55); }
#menu-levels .pick-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 9px; border-radius: 10px 10px 0 0; border-bottom: 1px solid #59616b; background: radial-gradient(circle at 15px 50%, #aeb6bf 1.6px, #22262b 2.3px, transparent 2.8px), radial-gradient(circle at calc(100% - 15px) 50%, #aeb6bf 1.6px, #22262b 2.3px, transparent 2.8px), linear-gradient(180deg, #3d434b, #1d2025); }
#menu-levels .pick-card.sel { border-color: #d8a83a; box-shadow: 0 0 0 1px #d8a83a, 0 0 24px rgba(216,168,58,.35), 0 10px 22px rgba(0,0,0,.55); }
#menu-classes .pick-card { text-align: center; background: linear-gradient(180deg, #15211e, #0c1214); box-shadow: 0 10px 22px rgba(0,0,0,.5); }
.sigil-ring { width: 58px; height: 58px; margin: 2px auto 9px; border-radius: 50%; border: 2px solid #4a5a54; background: radial-gradient(circle at 50% 36%, #24332e, #0b1113 76%); color: #ffd98a; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 12px rgba(0,0,0,.7); }
.sigil-ring svg { width: 32px; height: 32px; }
#menu-classes .pick-card.sel .sigil-ring { border-color: #d8a83a; color: #ffe9bb; box-shadow: 0 0 16px rgba(216,168,58,.5), inset 0 0 12px rgba(0,0,0,.7); }
.big-btn { background: linear-gradient(180deg, #73491f, #53320e); border: 1px solid #d8a83a; box-shadow: 0 8px 20px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,220,150,.35); letter-spacing: 1px; }
.big-btn:hover { background: linear-gradient(180deg, #855723, #64400f); }

/* #869 — PAINTED CARD ART */
#menu-levels .pick-card .card-art { width: calc(100% + 24px); height: 88px; object-fit: cover; object-position: 50% 40%; display: block; margin: -12px -12px 10px; border-bottom: 1px solid #6b5322; }
.sigil-ring { position: relative; overflow: hidden; width: 78px; height: 78px; }
.sigil-ring .class-face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 14%; }

/* #869b — flex-overflow title clip fix + card solidity */
#td-menu { justify-content: flex-start; }
.menu-inner { margin: auto 0; }
#td-menu { background: radial-gradient(ellipse at 50% 38%, rgba(4,6,8,.10) 0%, rgba(4,6,8,.5) 52%, rgba(3,4,6,.9) 82%, rgba(2,3,4,.97) 100%), linear-gradient(180deg, rgba(3,4,6,.55) 0%, rgba(3,4,6,0) 18%, rgba(3,4,6,0) 78%, rgba(3,4,6,.72) 100%); }
#menu-levels .pick-card { background: linear-gradient(180deg, rgba(48,37,22,.985), rgba(27,20,12,.99)); }

/* #870 — LEADERBOARD */
#td-lb { position: absolute; inset: 0; background: rgba(4,6,8,.95); z-index: 11; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; overflow-y: auto; padding: 30px 24px; text-align: center; }
#td-lb h4 { color: #ffd98a; margin: 16px 0 4px; font-size: 17px; }
.lb-list { list-style: none; margin: 6px auto 4px; width: min(360px, 86vw); text-align: left; padding: 0; }
.lb-list li { display: flex; justify-content: space-between; padding: 5px 10px; border-bottom: 1px solid rgba(216,168,58,.18); color: #d8d2c2; }
.lb-list li b { color: #ffd98a; }
.lb-none, .lb-loading { color: #9d968a; font-style: italic; }

/* ---------- #893 — UI OVERHAUL (Brody: "the ui is shit") ----------
   Same command language as the RTS: solid bars, tile buttons with a
   real name/cost/desc hierarchy, disabled states you can still read,
   and a colour stripe per turret / upgrade path that matches the
   pip posts on the 3D models. */
#td-hud { background: rgba(5,8,10,.95); border-bottom: 1px solid #37474a; padding: 8px 14px; }
#td-panel { width: 348px; padding: 16px; border-color: #57666c; box-shadow: 0 18px 50px rgba(0,0,0,.6); }
#td-panel h3 { font-size: 22px; }
#td-panel .sub { font-size: 14.5px; }
.build-btn, .upg-btn { min-height: 56px; padding: 10px 12px; margin: 7px 0; background: linear-gradient(180deg, #1b2622, #141d1a); border: 1px solid #4a5d54; border-radius: 9px; font-size: 14px; line-height: 1.35; color: #ffd98a; }
.build-btn b, .upg-btn b { display: block; color: #f2ead6; font-size: 16px; margin-bottom: 2px; }
.build-btn small { display: block; color: #8fa398; font-size: 12px; line-height: 1.35; margin-top: 2px; }
.build-btn:hover, .upg-btn:hover { background: linear-gradient(180deg, #26352e, #1a2621); border-color: #c98f2e; }
.build-btn:disabled, .upg-btn:disabled { background: #0c1013; border-color: #232b2e; color: #66766c; opacity: 1; cursor: default; }
.build-btn:disabled b, .upg-btn:disabled b { color: #7e8f85; }
.build-btn:disabled small { color: #55645c; }
.build-btn[data-build="bolt"] { border-left: 4px solid #c9a24d; }
.build-btn[data-build="ember"] { border-left: 4px solid #e06426; }
.build-btn[data-build="frost"] { border-left: 4px solid #6ec7e8; }
.build-btn[data-build="storm"] { border-left: 4px solid #9a7fe8; }
.upg-btn[data-upg="A"] { border-left: 4px solid #ffd27f; }
.upg-btn[data-upg="B"] { border-left: 4px solid #ff5c47; }
.upg-btn[data-upg="C"] { border-left: 4px solid #57e6d9; }
.upg-btn .pips { color: #ffd27f; font-size: 15px; }
#td-panel .close-line button { font-size: 16px; padding: 6px 4px; color: #c3d2c9; }
#td-panel .close-line button:hover { color: #ffd98a; }
.hud-btn:focus-visible, .build-btn:focus-visible, .upg-btn:focus-visible, .big-btn:focus-visible, .perk button:focus-visible { outline: 2px solid #57e6d9; outline-offset: 1px; }

/* #894 — build palette icons */
.b-ico { width: 100%; height: 62px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 6px; }

/* ---------- #931 — QoL BATCH: preview chip, damage floaters, paused state ---------- */
#td-preview { position: absolute; top: 64px; left: 14px; max-width: 44vw; background: rgba(10,16,18,.92); border: 1px solid #2e7f86; color: #bfeef2; padding: 7px 14px; border-radius: 10px; font-size: 15px; z-index: 5; pointer-events: none; line-height: 1.45; }
#td-preview b { color: #ffd98a; }
#td-dmg931 { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 4; }
.dmgnum931 { position: absolute; transform: translate(-50%, -100%); font-weight: bold; font-size: 15px; color: #ffe9bb; text-shadow: 0 1px 3px #000, 0 0 7px rgba(0,0,0,.65); white-space: nowrap; display: none; }
.dmgnum931.crit931 { color: #ffd24d; font-size: 22px; }
#td-paused931 { position: absolute; top: 118px; left: 50%; transform: translateX(-50%); background: rgba(10,16,18,.94); border: 1px solid #c98f2e; color: #ffd98a; padding: 9px 26px; border-radius: 10px; font-size: 21px; letter-spacing: 3px; z-index: 8; pointer-events: none; }

/* ---------- #933 — back-to-games anchors + panel can never overflow the screen ---------- */
a.hud-btn, a.big-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
#td-panel { max-height: calc(100vh - 30px); overflow-y: auto; }

/* #946 painted UI icon tiles (ICON LAW) */
.tico{width:32px;height:32px;vertical-align:-9px;flex:none;pointer-events:none}
.tico.sm{width:28px;height:28px;vertical-align:-7px}
.tico.lg{width:40px;height:40px;vertical-align:-11px}
.tico.cart{width:36px;height:36px;vertical-align:-10px}
button .tico{vertical-align:middle}

/* Immersion Phase 3 step 3: the readout strip (replaces the panel) */
#td-readout { position: absolute; left: 14px; bottom: 14px; background: rgba(10,14,16,.92); border: 1px solid #46555a; border-radius: 10px; padding: 10px 16px; z-index: 7; display: flex; gap: 18px; align-items: baseline; font-size: 16px; color: #cfe0d8; box-shadow: 0 12px 34px rgba(0,0,0,.5); }
#td-readout .ro-name { color: #ffd98a; font-size: 20px; }
#td-readout small { color: #9fb3ab; font-size: 13px; }
#td-readout .ro-inv { color: #9fb3ab; }
#td-readout .ro-inv span, #td-readout .ro-dmg b { color: #e8f2ec; }
