/* Spielschrift: Lilita One (SIL Open Font License, siehe fonts/OFL.txt), lokal eingebunden */
@font-face { font-family: "Lilita One"; src: url("fonts/LilitaOne-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
:root { --display: "Lilita One", "Trebuchet MS", "Segoe UI", system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color: #e6e9ef; font-family: system-ui, "Segoe UI", sans-serif; }
body { background: radial-gradient(ellipse at 50% 0%, #232b3d 0%, #12151c 60%) fixed; }
#app { max-width: 1260px; margin: 0 auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 100%; }

#hud { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stat { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; min-width: 84px;
    background: linear-gradient(180deg, #2a3245, #1d2331); border: 1px solid #39435a; border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06); }
.stat .ic { font-size: 20px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .5)); }
.stat div { display: flex; flex-direction: column; line-height: 1.1; }
.stat span { font-size: 10px; color: #8b93a5; text-transform: uppercase; letter-spacing: .08em; }
.stat b { font-size: 19px; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

button, select { background: linear-gradient(180deg, #2f3749, #232a39); color: inherit; border: 1px solid #424c64; border-radius: 8px;
    padding: 8px 12px; font: inherit; cursor: pointer; transition: transform .08s, filter .12s; }
button:hover:not(:disabled) { filter: brightness(1.2); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: linear-gradient(180deg, #4a86f5, #2a62d6); border-color: #5b95ff; font-weight: 600;
    box-shadow: 0 2px 8px rgba(47, 111, 237, .4); }

#stage { position: relative; border-radius: 12px; box-shadow: 0 0 0 3px #2c3446, 0 0 0 5px #151a24, 0 10px 30px rgba(0, 0, 0, .55); }
canvas#game { width: 100%; height: auto; display: block; border-radius: 12px; touch-action: manipulation; cursor: crosshair; background: #1d2d1d; }

#overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    background: radial-gradient(ellipse at center, rgba(40, 10, 10, .72), rgba(6, 8, 12, .9)); border-radius: 12px; text-align: center; }
#overlay[hidden] { display: none; }
#overlay h2 { margin: 0; font-size: 38px; color: #ff6b5e; text-shadow: 0 2px 12px rgba(255, 60, 40, .5); }

#overlay .row { display: flex; gap: 8px; margin-top: 6px; }

#mapMenu { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    padding: 12px; background: radial-gradient(ellipse at center, rgba(20, 30, 20, .9), rgba(6, 8, 12, .96)); border-radius: 12px; z-index: 2; }
#mapMenu[hidden] { display: none; }
#mapMenu h2 { margin: 0; font-size: 28px; text-shadow: 0 2px 12px rgba(0, 0, 0, .6); }
#mapCards { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; width: 100%; max-height: 100%; overflow: auto; padding: 10px 8px; }
.map-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px; width: clamp(140px, 29%, 252px); text-align: left; border-radius: 12px; position: relative; }
.map-card:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0, 0, 0, .5); }
@media (max-width: 600px) {
    #mapMenu { gap: 8px; }
    #mapMenu h2 { font-size: 22px; }
    #mapCards { gap: 8px; }
    .map-card { width: 31%; padding: 5px; }
    .map-card b { font-size: 14px; }
    .map-card small { display: none; }
}
.map-card.current { border-color: #5b95ff; box-shadow: inset 0 0 0 1px #5b95ff; }
.map-card.current::before { content: "Zuletzt gespielt"; position: absolute; bottom: 10px; right: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(32, 90, 220, .92); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.map-card .map-prev { width: 100%; height: auto; border-radius: 8px; border: 1px solid #2c3446; }
.map-card b { font-size: 17px; margin-top: 2px; }
.map-card small { color: #9aa3b6; }
.map-card .rec { font-size: 12px; color: #e8c547; }

#main { display: flex; gap: 12px; align-items: flex-start; }
#stage { flex: 1; min-width: 0; }
#side { width: 252px; flex: none; display: flex; flex-direction: column; gap: 8px; }
#side h3 { margin: 2px 0 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: #8b93a5; }
#shop { display: flex; flex-direction: column; gap: 6px; }
.tower-btn { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; width: 100%; text-align: left; }
.tower-btn .ico { width: 40px; height: 40px; flex: none; background: radial-gradient(circle at 50% 40%, #3b6a36, #213a20); border-radius: 8px; }
.tower-btn .txt { display: flex; flex-direction: column; line-height: 1.25; }
.tower-btn small { color: #9aa3b6; }
.tower-btn.active { outline: 2px solid #5b95ff; box-shadow: 0 0 12px rgba(91, 149, 255, .45); }
#info { background: linear-gradient(180deg, #1c2230, #161b27); border: 1px solid #2c3548; border-radius: 10px;
    padding: 10px 12px; font-size: 14px; display: flex; flex-direction: column; gap: 8px; }
#info { gap: 10px; }
.ti-head { display: flex; align-items: center; gap: 10px; }
.ti-head canvas { width: 40px; height: 40px; flex: none; background: radial-gradient(circle at 50% 40%, #3b6a36, #213a20); border-radius: 8px; }
.ti-head > div { flex: 1; line-height: 1.2; }
.ti-head b { font-size: 16px; }
.stars { color: #ffd54a; letter-spacing: 2px; font-size: 15px; }
.stars i { font-style: normal; color: #3a4254; }
.ti-x { padding: 2px 8px; border-radius: 6px; background: none; border-color: transparent; color: #8b93a5; }

.ti-stats { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; background: rgba(0, 0, 0, .22); border-radius: 8px; }
.ti-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: baseline; font-size: 13px; }
.ti-row span { color: #9aa3b6; }
.ti-row b { font-variant-numeric: tabular-nums; }
.ti-row em { font-style: normal; color: #4be06a; font-size: 12px; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

.ti-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8b93a5; margin-bottom: -4px; }
.ti-label small { text-transform: none; letter-spacing: 0; }
.ti-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.ti-modes button { padding: 5px 2px; font-size: 12px; border-radius: 6px; }
.ti-modes button.on { background: linear-gradient(180deg, #4a86f5, #2a62d6); border-color: #5b95ff; font-weight: 600; }

#info .ti-up, #info .ti-sell { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 100%; padding: 9px 12px; text-align: center; }
#info .ti-up b, #info .ti-sell b { font-size: 14px; }
#info .ti-up small { font-weight: 400; opacity: .7; }
#info .ti-up span, #info .ti-sell span { font-size: 12px; opacity: .85; }
#info .ti-up:disabled { opacity: .6; }
#info .ti-sell { background: none; border-color: #4a3036; color: #e9a0a0; padding: 6px 12px; }
#info .ti-sell:hover { background: rgba(255, 90, 90, .1); }
#info .ti-sell.armed { background: linear-gradient(180deg, #d64545, #a82d2d); border-color: #ff7b7b; color: #fff; animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 12px rgba(255, 80, 80, .6); } }

/* Schmale Bildschirme: Leiste unter das Spielfeld, Türme in zwei Spalten */
@media (max-width: 820px) {
    #main { flex-direction: column; }
    #stage { width: 100%; flex: none; }
    #side { width: 100%; }
    #shop { display: grid; grid-template-columns: 1fr 1fr; }
}

/* Schrift für Zahlen, Überschriften und wichtige Buttons (Lilita One kennt nur eine Stärke) */
/* Nur große Überschriften, Zahlen und Turmname im Kopf des Info-Blocks; Buttons und Listen bleiben in der Systemschrift (besser lesbar) */
.stat b, #overlay h2, #mapMenu h2, .ti-head b {
    font-family: var(--display); font-weight: 400; letter-spacing: .03em; }
.stat b { font-size: 21px; }
button.primary { font-weight: 600; }
#overlay h2 { font-size: 44px; }
#mapMenu h2 { font-size: 34px; }
.ti-head b { font-size: 18px; }
@media (max-width: 600px) { #mapMenu h2 { font-size: 26px; } }

/* Info-Block im Bau-Modus (Turm im Shop gewählt) */
.ti-cost { font-size: 13px; color: #e8c547; }
.ti-cost.lack { color: #ff9a8a; }
.ti-desc { color: #9aa3b6; font-size: 13px; margin-top: -4px; }
.ti-hrow { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8b93a5; padding-bottom: 3px; border-bottom: 1px solid #2c3548; margin-bottom: 2px; }
.ti-hrow b, .ti-hrow em { color: #8b93a5; font-weight: 400; }
.ti-row em.max { color: #c9d1dd; font-size: 13px; }
.ti-hint { font-size: 12px; color: #8b93a5; }
.tower-btn.poor { opacity: .55; }
.ti-kill { margin-top: 3px; padding-top: 4px; border-top: 1px solid #2c3548; }
.ti-kill b { color: #ffd54a; }

#btnAuto.on { background: linear-gradient(180deg, #3aa86a, #247a47); border-color: #52c785; }

/* Feste Breite, damit der Countdown im Button die anderen Buttons nicht verschiebt */
#btnWave { width: 20.5em; text-align: center; white-space: nowrap; }
@media (max-width: 600px) { #btnWave { width: auto; flex: 1 1 100%; } }
#btnAuto { min-width: 9.5em; white-space: nowrap; }
@media (max-width: 600px) { .map-card.current::before { content: "Zuletzt"; bottom: 6px; right: 6px; } }

/* Freischaltungen: gesperrte Türme, Aufgabe, Fortschrittsbalken, Meldung */
#side h3 #unlockCount { float: right; text-transform: none; letter-spacing: 0; color: #e8c547; font-weight: 600; }
.tower-btn.locked { opacity: .75; }
.tower-btn.locked .ico { filter: grayscale(1) brightness(.7); }
.tower-btn.locked .txt { flex: 1; min-width: 0; }
.tower-btn.locked small { white-space: normal; }
.bar { display: block; height: 5px; margin: 3px 0 1px; border-radius: 3px; background: #1a1f2b; overflow: hidden; }
.bar u { display: block; height: 100%; background: linear-gradient(90deg, #e8c547, #ffd54a); border-radius: 3px; text-decoration: none; }
.tower-btn small.cnt { color: #e8c547; font-size: 11px; }
.ti-lock { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px dashed #5a4a2a; border-radius: 8px; background: rgba(232, 197, 71, .06); font-size: 13px; }
.ti-lock b { color: #e8c547; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.ti-lock small { color: #e8c547; }

#toast { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 3; padding: 10px 18px; border-radius: 12px; text-align: center;
    background: linear-gradient(180deg, rgba(232, 197, 71, .96), rgba(196, 150, 30, .96)); color: #2a2008; font-size: 15px; line-height: 1.5;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .55); pointer-events: none; }
#toast[hidden] { display: none; }
#toast.show { animation: toast-in .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -16px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

.link-btn { align-self: flex-start; background: none; border: none; padding: 4px 2px; font-size: 12px; color: #7a8399; text-decoration: underline; }
.link-btn:hover:not(:disabled) { color: #ff9a8a; filter: none; }

/* Teilaufgaben im Info-Block */
.ti-lock { gap: 8px; }
.ti-lock .qp { display: flex; flex-direction: column; gap: 2px; }
.ti-lock .qp.done { opacity: .6; }
.ti-lock .qp.done > div { text-decoration: line-through; }
.ti-lock .qp.done > div::first-letter { text-decoration: none; }

/* Meisterstufe (Stufe 5) */
.stars.master { text-shadow: 0 0 8px rgba(255, 213, 74, .9); }
.mtag { display: inline-block; margin-top: 1px; padding: 0 7px; border-radius: 999px; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: #2a2008; background: linear-gradient(90deg, #ffd54a, #c9a0ff); }
