/* Dead End Town — frontier board, parchment rail, dirt road. */
.td-root { display: flex; flex-direction: column; height: 100%; padding: 10px 14px; box-sizing: border-box; gap: 8px; }
.td-header { display: flex; align-items: center; gap: 14px; }
.td-back { font-size: 26px; line-height: 1; padding: 2px 12px; border-radius: 10px; border: 2px solid #8a6b45; background: #f3e5c8; color: #4a3319; cursor: pointer; }
.td-titles { min-width: 180px; }
.td-game-title { font-size: 22px; font-weight: 800; color: #f7e8c9; letter-spacing: 0.4px; }
.td-level-title { font-size: 14px; color: #d9c39a; }
.td-hpwrap { flex: 1; max-width: 460px; }
.td-hpbar { height: 14px; border-radius: 7px; background: #3d2c17; border: 1px solid #8a6b45; overflow: hidden; }
.td-hpfill { height: 100%; background: linear-gradient(90deg, #7dbb4a, #a8d45e); transition: width 200ms linear; }
.td-hptext { font-size: 14px; color: #e8d9b5; margin-top: 2px; }
.td-hud { display: flex; gap: 16px; font-size: 16px; color: #f7e8c9; font-weight: 700; }
.td-xpwrap { display: flex; align-items: center; gap: 8px; min-width: 170px; }
.td-xplabel { font-size: 14px; font-weight: 700; color: #bfe3ff; white-space: nowrap; }
.td-xpbar { flex: 1; height: 10px; border-radius: 5px; background: #1d2c3d; border: 1px solid #5b84a8; overflow: hidden; }
.td-xpfill { height: 100%; background: linear-gradient(90deg, #3f8fd2, #6fc3ff); transition: width 150ms linear; }
.td-bosswrap { display: flex; align-items: center; gap: 10px; }
.td-bossname { color: #ffb3a0; font-weight: 800; font-size: 15px; min-width: 130px; text-align: right; }
.td-bossbar { flex: 1; height: 10px; border-radius: 5px; background: #40201a; border: 1px solid #a04a38; overflow: hidden; }
.td-bossfill { height: 100%; background: linear-gradient(90deg, #c23b2a, #e06a4a); transition: width 200ms linear; }
.td-main { display: flex; gap: 14px; flex: 1; min-height: 0; }
.td-boardwrap { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; }
.td-boardwrap.is-zoomed { align-items: flex-start; justify-content: flex-start; overflow: auto; }
.td-board { position: relative; flex: none; width: min(100%, calc((100vh - 190px) * var(--td-cols) / var(--td-rows))); max-height: 100%; border: 3px solid #8a6b45; border-radius: 12px; background: #c9a86a; overflow: hidden; }
.td-cells { position: absolute; inset: 0; display: grid; }
.td-cell { position: relative; border: 1px solid rgba(90, 62, 30, 0.25); background-color: #c9a86a; background-image: radial-gradient(rgba(120, 84, 40, 0.10) 1px, transparent 1.6px), radial-gradient(rgba(255, 240, 200, 0.10) 1px, transparent 1.6px); background-size: 9px 9px, 13px 13px; background-position: 0 0, 4px 6px; padding: 0; }
.td-cell.is-road { background-color: #e6cb95; background-image: linear-gradient(90deg, rgba(105, 70, 32, 0.42) 0 4%, transparent 12% 88%, rgba(105, 70, 32, 0.42) 96% 100%), linear-gradient(0deg, rgba(105, 70, 32, 0.30) 0 4%, transparent 12% 88%, rgba(105, 70, 32, 0.30) 96% 100%), radial-gradient(rgba(120, 84, 40, 0.13) 1px, transparent 1.6px); background-size: auto, auto, 8px 8px; box-shadow: inset 0 0 0 2px rgba(105, 70, 32, 0.45), inset 0 0 16px rgba(105, 70, 32, 0.40); }
.td-cell.is-open { background-color: #e8cd96; box-shadow: inset 0 0 0 3px #b98548; }
.td-cell.is-open::after { content: ""; position: absolute; left: 50%; top: 50%; width: 20%; height: 20%; margin: -10% 0 0 -10%; background: #ffd75e; transform: rotate(45deg); border: 2px solid #8a5a1d; animation: td-pulse 700ms ease-in-out infinite alternate; }
.td-cell.is-plot { background-color: #b7cf87; background-image: linear-gradient(0deg, rgba(70, 110, 40, 0.13) 50%, transparent 50%); background-size: 100% 7px; box-shadow: inset 0 0 0 3px #7c5a30, inset 0 0 0 6px rgba(255, 248, 220, 0.35); }
.td-cell.is-obstacle { background-color: #8a8172; background-image: radial-gradient(ellipse 62% 44% at 38% 66%, #b0a58e 0 58%, #7d7462 59% 68%, transparent 69%), radial-gradient(ellipse 52% 40% at 68% 38%, #bcb198 0 55%, #847a66 56% 66%, transparent 67%), radial-gradient(ellipse 34% 26% at 80% 74%, #a29a85 0 58%, transparent 59%); box-shadow: inset 0 0 0 2px rgba(60, 50, 35, 0.40), inset 0 -10px 14px rgba(60, 50, 35, 0.35); }
.td-cell.is-town { background: #7a4f2a url("../img/td/town.png") center / cover no-repeat; box-shadow: inset 0 0 0 3px #5d3a1a; }
.td-cell.is-entry { background: radial-gradient(circle at 50% 50%, #2e1f12 0 55%, #57402a 100%); box-shadow: inset 0 0 0 3px #241708, inset 0 0 18px rgba(255, 90, 40, 0.35); }
.td-cell.is-target { cursor: pointer; box-shadow: inset 0 0 0 3px #ffe9a8; animation: td-pulse 900ms ease-in-out infinite alternate; }
@keyframes td-pulse { from { filter: brightness(1); } to { filter: brightness(1.18); } }
.td-town-label { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; display: flex; align-items: center; justify-content: center; background: rgba(40, 24, 8, 0.72); color: #ffe9a8; font-weight: 800; font-size: 14px; line-height: 1; letter-spacing: 1px; }
.td-spawn-label { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; display: flex; align-items: center; justify-content: center; background: rgba(60, 10, 4, 0.78); color: #ffb59d; font-weight: 800; font-size: 14px; line-height: 1; letter-spacing: 0.5px; }
.td-tower { position: absolute; inset: 12%; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff8ea; font-weight: 800; box-shadow: 0 1px 3px rgba(0,0,0,0.45); }
.td-tower-name { font-size: 14px; line-height: 1; letter-spacing: 0.5px; }
.td-tower-pips { display: flex; gap: 2px; margin-top: 1px; }
.td-tower-pips i { width: 5px; height: 5px; border-radius: 50%; background: #ffd75e; display: block; }
.td-tower-gatling { background: url("../img/td/tower-gatling.png") center bottom / contain no-repeat; inset: 0; border-radius: 0; box-shadow: none; justify-content: flex-end; padding-bottom: 2px; }
.td-tower.has-sprite { inset: 0; border-radius: 0; box-shadow: none; justify-content: flex-end; padding-bottom: 2px; background-position: center bottom; background-size: contain; background-repeat: no-repeat; }
.td-tower-gatling .td-tower-name { display: none; }
.td-tower-cannon { background: #6d4c41; }
.td-tower-sharpshooter { background: #33691e; }
.td-tower-dynamite { background: #b03a2e; }
.td-tower-tar-slick { background: #263238; border-radius: 50%; inset: 22%; }
.td-tower-posse { background: #7d5a29; border-radius: 50%; inset: 18%; }
.td-tower-scattergun { background: #0277bd; }
.td-blockbar { width: 80%; height: 4px; background: rgba(0,0,0,0.4); border-radius: 2px; margin-top: 2px; overflow: hidden; }
.td-blockfill { height: 100%; background: #ffd75e; }
.td-enemies { position: absolute; inset: 0; pointer-events: none; }
.td-enemy { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: #8d6e63; border: 2px solid rgba(0,0,0,0.35); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 14px; line-height: 1; animation: td-bob 260ms ease-in-out infinite alternate; }
@keyframes td-bob { from { transform: translateY(0.5px); } to { transform: translateY(-2.5px); } }
.td-enemy-outlaw { width: 54px; height: 54px; margin: -27px 0 0 -27px; border: none; border-radius: 0; background: url("../img/td/enemy-outlaw.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-outlaw .td-enemy-name { display: none; }
.td-enemy-name { line-height: 1; }
.td-enemy-bar { width: 26px; height: 4px; background: rgba(0,0,0,0.45); border-radius: 2px; margin-top: 2px; overflow: hidden; }
.td-enemy-fill { height: 100%; background: #ff7043; }
.td-enemy-runner { width: 48px; height: 48px; margin: -24px 0 0 -24px; border: none; border-radius: 0; background: url("../img/td/enemy-runner.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-runner .td-enemy-name { display: none; }
.td-enemy-rider { width: 68px; height: 48px; margin: -24px 0 0 -34px; border: none; border-radius: 0; background: url("../img/td/enemy-rider.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-rider .td-enemy-name { display: none; }
.td-enemy-brute { width: 56px; height: 56px; margin: -28px 0 0 -28px; border: none; border-radius: 0; background: url("../img/td/enemy-brute.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-brute .td-enemy-name { display: none; }
.td-enemy-stagecoach { width: 100px; height: 50px; margin: -25px 0 0 -50px; border: none; border-radius: 0; background: url("../img/td/enemy-stagecoach.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-stagecoach .td-enemy-name { display: none; }
.td-enemy-balloon { width: 52px; height: 76px; margin: -38px 0 0 -26px; border: none; border-radius: 0; background: url("../img/td/enemy-balloon.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-balloon .td-enemy-name { display: none; }
.td-enemy-glider { width: 84px; height: 44px; margin: -22px 0 0 -42px; border: none; border-radius: 0; background: url("../img/td/enemy-glider.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-glider .td-enemy-name { display: none; }
.td-enemy-zeppelin { width: 108px; height: 54px; margin: -27px 0 0 -54px; border: none; border-radius: 0; background: url("../img/td/enemy-zeppelin.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-zeppelin .td-enemy-name { display: none; }
.td-enemy-iron-mule { width: 96px; height: 72px; margin: -36px 0 0 -48px; border: none; border-radius: 0; background: url("../img/td/enemy-iron-mule.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-iron-mule .td-enemy-name { display: none; }
.td-enemy-golden-express { width: 120px; height: 66px; margin: -33px 0 0 -60px; border: none; border-radius: 0; background: url("../img/td/enemy-golden-express.png") center / contain no-repeat; justify-content: flex-end; }
.td-enemy-golden-express .td-enemy-name { display: none; }
.td-enemy.is-hit { filter: brightness(1.7); }
.td-enemy.is-slowed { outline: 2px solid #80d8ff; }
.td-range { position: absolute; border: 2px dashed rgba(255, 233, 168, 0.8); border-radius: 50%; pointer-events: none; }
.td-rail { width: 300px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.td-panel { background: #f3e5c8; border: 2px solid #8a6b45; border-radius: 12px; padding: 12px; color: #4a3319; }
.td-panel-title { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.td-panel-sub { font-size: 14px; margin-bottom: 8px; }
.td-cards { display: flex; flex-direction: column; gap: 8px; }
.td-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 10px; border: 2px solid #8a6b45; background: #fff6dd; cursor: pointer; width: 100%; }
.td-card-road { background: #efe0ba; }
.td-card-title { font-size: 16px; font-weight: 800; color: #4a3319; }
.td-card-sub { font-size: 14px; color: #7a5c33; }
.td-shape { display: grid; gap: 1px; margin-top: 4px; }
.td-shape i { width: 9px; height: 9px; background: transparent; display: block; }
.td-shape i.is-on { background: #b98548; }
.td-rotrow { display: flex; gap: 8px; margin-bottom: 8px; }
.td-rotbtn { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px 4px; border-radius: 10px; border: 2px solid #8a6b45; background: #fff6dd; cursor: pointer; }
.td-rotbtn.is-off { opacity: 0.35; cursor: default; }
.td-btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.td-btn { padding: 9px 14px; border-radius: 10px; border: 2px solid #8a6b45; background: #fff6dd; color: #4a3319; font-weight: 700; font-size: 15px; cursor: pointer; }
.td-startwave { background: #7dbb4a; border-color: #4e7a2a; color: #1d2b10; width: 100%; font-size: 17px; }
.td-reroll { margin-top: 8px; width: 100%; }
.td-end-title { font-size: 22px; }
.td-end-stars { font-size: 30px; color: #b98548; letter-spacing: 4px; margin-bottom: 6px; }
.td-skills, .td-boosters { background: rgba(243, 229, 200, 0.12); border: 1px solid rgba(138, 107, 69, 0.7); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.td-rail-title { color: #d9c39a; font-size: 14px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.td-skill, .td-booster { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 10px; border: 2px solid #8a6b45; background: #f3e5c8; color: #4a3319; font-weight: 700; font-size: 14px; cursor: pointer; width: 100%; }
.td-skill.is-cooling, .td-booster.is-used { opacity: 0.45; cursor: default; }
.td-skill-cd { font-size: 14px; color: #7a5c33; }
.td-nocash { font-size: 14px; color: #a68d5f; }
.td-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.td-ctl { flex: 1; }
.td-loadout { max-width: 560px; margin: 40px auto; background: #f3e5c8; border: 2px solid #8a6b45; border-radius: 14px; padding: 22px; color: #4a3319; }
.td-loadout-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.td-loadout-sub { font-size: 14px; color: #7a5c33; margin-bottom: 14px; }
.td-loadout-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.td-loadout-skill { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 10px; border: 2px solid #8a6b45; background: #fff6dd; cursor: pointer; width: 100%; opacity: 0.75; }
.td-loadout-skill.is-chosen { opacity: 1; box-shadow: inset 0 0 0 2px #7dbb4a; background: #fdf3d0; }
.td-startwave.is-off { opacity: 0.45; }
.td-board { touch-action: none; }
.td-drag-ghost { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 9px; background: rgba(38, 50, 56, 0.9); color: #fff8ea; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 5; box-shadow: 0 3px 8px rgba(0,0,0,0.5); }

/* td-art-7: firing flash, town shake, card art, sprite ghost, chapter tints */
.td-tower.is-firing { filter: brightness(1.65); }
.td-board.is-shaking { animation: td-shake 300ms linear; }
@keyframes td-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }
.td-card-art { display: block; width: 54px; height: 54px; background-position: center bottom; background-size: contain; background-repeat: no-repeat; }
.td-drag-ghost.has-sprite { background-color: transparent; box-shadow: none; background-size: contain; background-repeat: no-repeat; background-position: center; width: 52px; height: 52px; margin: -26px 0 0 -26px; opacity: 0.55; }
.td-board.td-ch2 { background: #a5683f; }
.td-board.td-ch2 .td-cell:not(.is-road):not(.is-plot):not(.is-town):not(.is-obstacle):not(.is-entry) { background-color: #c08552; }
.td-board.td-ch3 { background: #71808f; }
.td-board.td-ch3 .td-cell:not(.is-road):not(.is-plot):not(.is-town):not(.is-obstacle):not(.is-entry) { background-color: #9fb0bd; }
