:root {
  --navy: #0b1d33;
  --navy2: #12365c;
  --ice: #bcdcff;
  --blue: #2a8bd8;
  --yellow: #ffc933;
  --green: #2fb844;
  --green-d: #1f8a31;
  --card: #f3f8fd;
  --ink: #10304f;
  --muted: #6b86a0;
  --danger: #d9473f;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: Impact, "Arial Black", "Haettenschweiler", "Franklin Gothic Heavy", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--navy); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; overscroll-behavior: none; }
body { overflow: hidden; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

/* ---------- Wordmark ---------- */
.wordmark {
  font-family: var(--font-display); font-weight: 900; letter-spacing: 1px; line-height: 1;
  color: #fff; font-size: 17px; text-transform: uppercase;
  -webkit-text-stroke: 1px #0a2a4a; paint-order: stroke fill; text-shadow: 0 2px 0 #0a2a4a;
}
.wordmark b { color: var(--yellow); display: block; font-size: 1.1em; -webkit-text-stroke-color: #6b3d00; }
.wordmark.big { font-size: 38px; text-align: center; }
.wordmark.big b { display: inline; font-size: 1em; }

/* ---------- Auth ---------- */
.auth { background: radial-gradient(120% 90% at 50% 0%, #1d5a96 0%, var(--navy2) 45%, var(--navy) 100%); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: max(18px, env(safe-area-inset-top)) 14px 28px; }
.snow { position: fixed; inset: 0; pointer-events: none; background-image:
  radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%), radial-gradient(3px 3px at 80px 120px, #fff 50%, transparent 51%),
  radial-gradient(2px 2px at 150px 60px, #fff 50%, transparent 51%), radial-gradient(2px 2px at 220px 170px, #fff 50%, transparent 51%),
  radial-gradient(3px 3px at 300px 90px, #fff 50%, transparent 51%), radial-gradient(2px 2px at 60px 220px, #fff 50%, transparent 51%);
  background-size: 340px 260px; opacity: .7; animation: snowfall 14s linear infinite; }
@keyframes snowfall { to { background-position: 60px 260px; } }
.auth-card { position: relative; width: 100%; max-width: 420px; margin: auto; background: var(--card); border-radius: 24px; padding: 26px 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.brand { text-align: center; margin-bottom: 14px; }
.brand-badge { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 8px 22px rgba(12,58,102,.45); }
.brand .wordmark { margin-top: 12px; }
.tagline { margin-top: 6px; font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 6px; background: #dfeaf6; padding: 5px; border-radius: 14px; margin: 14px 0 16px; }
.tab { flex: 1; border: 0; background: transparent; padding: 11px 8px; border-radius: 10px; font: 700 15px var(--font); color: var(--muted); cursor: pointer; }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(16,48,79,.15); }

.form { display: flex; flex-direction: column; gap: 12px; }
.form h3 { margin: 0; font-size: 18px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; color: #34526f; }
input, select {
  width: 100%; padding: 13px 14px; font-size: 16px; border: 2px solid #cfdeed; border-radius: 12px; background: #fff; color: var(--ink); outline: none;
  font-family: inherit;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,139,216,.2); }
.hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.hint.center { text-align: center; }
.msg { margin: 0; min-height: 0; font-size: 14px; line-height: 1.4; }
.msg:empty { display: none; }
.msg.err { color: var(--danger); font-weight: 600; }
.msg.ok { color: #1f7a31; font-weight: 600; }
.banner { padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.banner.ok { background: #dff6e3; color: #1d6a2b; }
.banner.err { background: #fde4e2; color: #a32d27; }

.btn { border: 0; cursor: pointer; font: 800 16px var(--font); letter-spacing: .4px; text-transform: uppercase; padding: 14px 20px; border-radius: 14px; color: #fff; background: var(--blue); border-bottom: 4px solid #1a63a0; transition: transform .06s; }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn.green { background: var(--green); border-bottom-color: var(--green-d); }
.btn.red { background: var(--danger); border-bottom-color: #a32d27; }
.btn.ghost { background: #e4eef8; color: #24527f; border-bottom-color: #c3d6e8; }
.btn.small { font-size: 13px; padding: 9px 14px; border-radius: 11px; border-bottom-width: 3px; text-transform: none; letter-spacing: 0; }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; color: #1d6fb8; font: 600 14px var(--font); cursor: pointer; padding: 4px; align-self: center; }

/* ---------- Spiel ---------- */
.game { background: #dbe6ef; touch-action: none; user-select: none; -webkit-user-select: none; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: max(8px, env(safe-area-inset-top)) 12px 8px; pointer-events: none; z-index: 5; }
#topbar > * { pointer-events: auto; }
.brand-mini { display: flex; align-items: center; gap: 8px; }
.badge-mini { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 3px 8px rgba(0,0,0,.3); }
.brand-mini .wordmark { font-size: 15px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }

.profile-wrap { position: relative; }
.profile-btn { display: flex; align-items: center; gap: 4px; border: 0; background: rgba(11,29,51,.78); backdrop-filter: blur(6px); padding: 4px 8px 4px 4px; border-radius: 999px; color: #fff; cursor: pointer; box-shadow: 0 3px 10px rgba(0,0,0,.3); }
.caret { display: inline-flex; opacity: .85; }
.caret .ico { width: 14px; height: 14px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(145deg, #2a8bd8, #0c3a66); color: #fff; font-weight: 800; font-size: 17px; overflow: hidden; border: 2px solid #fff; flex: none; text-transform: uppercase; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 76px; height: 76px; font-size: 32px; }
.avatar.sm { width: 34px; height: 34px; font-size: 15px; border-width: 1.5px; }

.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; background: #fff; border-radius: 16px; box-shadow: 0 14px 40px rgba(0,0,0,.35); padding: 6px; z-index: 20; }
.dropdown button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px 12px; font: 600 15px var(--font); color: var(--ink); border-radius: 10px; cursor: pointer; }
.dropdown button:hover, .dropdown button:active { background: #e8f1fa; }
.dd-head { padding: 10px 12px 10px; border-bottom: 1px solid #e1ebf5; margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
.dd-head span { font-size: 12px; color: var(--muted); word-break: break-all; }

#hud { position: absolute; left: 0; right: 0; top: calc(max(8px, env(safe-area-inset-top)) + 56px); display: flex; justify-content: space-between; align-items: center; padding: 0 12px; pointer-events: none; z-index: 4; }
.level-chip { display: flex; align-items: center; gap: 8px; }
.lv { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(160deg, #ffd24d, #f0a30c); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.3); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; color: #5a3500; }
.lv small { font-size: 9px; font-weight: 800; }
.lv b { font-size: 18px; font-weight: 900; }
.xpbar { width: 92px; height: 12px; border-radius: 99px; background: rgba(11,29,51,.65); border: 2px solid rgba(255,255,255,.9); overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #7be58a, #2fb844); transition: width .25s; }
.money-pill { display: flex; align-items: center; background: rgba(58,64,70,.82); border-radius: 12px; padding: 0 14px 0 0; height: 40px; color: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.25); min-width: 120px; justify-content: flex-end; position: relative; }
/* Geldschein-Icon links an der Pille */
.money-pill .bill-ico { position: absolute; left: -10px; top: -5px; width: 56px; height: 50px; transform: rotate(-6deg); filter: drop-shadow(0 3px 0 rgba(20,90,40,.7)); }
.money-pill b { font-size: 22px; font-weight: 900; margin-left: 52px; letter-spacing: .5px; text-shadow: 0 2px 0 rgba(0,0,0,.3); }

.shop-btn { position: absolute; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 5; border: 0; background: var(--green); color: #fff; border-bottom: 4px solid var(--green-d); font: 800 16px var(--font); letter-spacing: .4px; padding: 14px 20px; border-radius: 16px; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.shop-btn.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 22px 22px 0 0; padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); z-index: 12; box-shadow: 0 -10px 40px rgba(0,0,0,.35); max-height: 75%; overflow-y: auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.x { border: 0; background: #e4eef8; width: 36px; height: 36px; border-radius: 50%; font-size: 16px; cursor: pointer; color: #34526f; }
.up-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 2px 6px rgba(16,48,79,.08); }
.up-ico { font-size: 28px; width: 44px; height: 44px; border-radius: 12px; background: #e8f1fa; display: flex; align-items: center; justify-content: center; flex: none; }
.up-info { flex: 1; min-width: 0; }
.up-info b { display: block; font-size: 15px; }
.up-info span { font-size: 12px; color: var(--muted); }
.up-pips { display: flex; gap: 3px; margin-top: 5px; }
.up-pips i { width: 100%; max-width: 14px; height: 6px; border-radius: 3px; background: #d5e2ef; }
.up-pips i.on { background: var(--green); }
.up-buy { flex: none; min-width: 86px; }

/* ---------- Modals ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5,15,30,.65); z-index: 50; display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px); }
.modal { width: 100%; max-width: 560px; max-height: 92vh; background: var(--card); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; box-shadow: 0 -10px 50px rgba(0,0,0,.4); }
@media (min-width: 640px) { .overlay { align-items: center; } .modal { border-radius: 22px; max-height: 88vh; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 4px 18px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; }
.modal-body section { background: #fff; border-radius: 16px; padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 6px rgba(16,48,79,.07); }
.modal-body h3 { margin: 0 0 10px; font-size: 16px; }
.avrow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.avrow .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.mtabs { display: flex; gap: 6px; background: #dfeaf6; padding: 5px; border-radius: 14px; margin-bottom: 12px; }
.mtabs .tab { padding: 9px 6px; font-size: 14px; }

.ucard { background: #fff; border-radius: 16px; padding: 12px; margin-bottom: 10px; box-shadow: 0 2px 6px rgba(16,48,79,.08); }
.uhead { display: flex; align-items: center; gap: 10px; }
.uhead .who { min-width: 0; flex: 1; }
.uhead .who b { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.uhead .who span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 2px 7px; border-radius: 99px; background: #ffe7a6; color: #7a4d00; }
.badge.warn { background: #fde0dd; color: #a32d27; }
.badge.me { background: #d9ecff; color: #14548f; }
.uact { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.cheat { margin-top: 10px; padding: 12px; background: #eef5fc; border-radius: 12px; display: flex; flex-direction: column; gap: 10px; }
.cheat .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cheat .quick { display: flex; gap: 6px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; top: calc(max(8px, env(safe-area-inset-top)) + 112px); transform: translate(-50%, -12px); background: rgba(11,29,51,.94); color: #fff; padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; line-height: 1.4; max-width: min(92vw, 420px); text-align: center; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Icons ---------- */
.ico { width: 1.25em; height: 1.25em; vertical-align: -0.28em; flex: none; display: inline-block; }
.dropdown button { display: flex; align-items: center; gap: 10px; }
.dropdown button .ico { width: 20px; height: 20px; color: #2a6fa8; }
.x .ico { width: 16px; height: 16px; vertical-align: middle; }
.shop-btn { display: flex; align-items: center; gap: 8px; }
.shop-btn .ico { width: 20px; height: 20px; }
.up-ico .ico { width: 30px; height: 30px; }
.btn .ico { width: 1.1em; height: 1.1em; vertical-align: -0.2em; margin-right: 2px; }
.hint .ico, .msg .ico { width: 1.1em; height: 1.1em; }
.toast { display: flex; align-items: center; gap: 10px; }
.toast .toast-ico { width: 26px; height: 26px; }

/* ---------- Auftrag & Wärme ---------- */

.hud-stack { position: absolute; left: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 112px); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; z-index: 4; pointer-events: none; max-width: min(84vw, 340px); }
.mission { display: flex; align-items: center; gap: 8px; max-width: min(78vw, 330px); background: rgba(11,29,51,.78); backdrop-filter: blur(6px); color: #fff; padding: 7px 10px; border-radius: 14px; box-shadow: 0 3px 10px rgba(0,0,0,.28); pointer-events: none; z-index: 4; }
.mission > .ico { width: 22px; height: 22px; }
.m-body { min-width: 0; flex: 1; }
.m-text { font-size: 12.5px; font-weight: 700; line-height: 1.25; }
.m-bar { height: 7px; border-radius: 99px; background: rgba(255,255,255,.2); margin-top: 5px; overflow: hidden; }
.m-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd24d, #f0a30c); transition: width .25s; }
.m-reward { display: flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 800; color: #ffe066; }
.m-reward .ico { width: 16px; height: 16px; }
.warm-chip { display: flex; align-items: center; gap: 6px; background: rgba(255,140,40,.92); color: #fff; font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 99px; box-shadow: 0 3px 10px rgba(0,0,0,.25); pointer-events: none; z-index: 4; }
.warm-chip .ico { width: 16px; height: 16px; }

/* ---------- Ton-Schalter ---------- */
.audio-btns { position: absolute; left: 12px; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; gap: 8px; z-index: 5; }
.round-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(11,29,51,.78); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.3); backdrop-filter: blur(6px); }
.round-btn .ico { width: 24px; height: 24px; }
.round-btn.off { opacity: .8; }

.alert { display: flex; align-items: center; gap: 8px; background: rgba(217,71,63,.95); color: #fff; font-size: 13px; font-weight: 800; line-height: 1.3; padding: 8px 12px; border-radius: 14px; box-shadow: 0 3px 12px rgba(0,0,0,.35); animation: pulse 1s infinite; }
.alert .ico { width: 20px; height: 20px; }

/* ---------- Lautstärke ---------- */
.audio-btns { align-items: flex-end; }
.vol-wrap { position: relative; display: flex; }
.vol-pop { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 8px; display: none; z-index: 6; }
.vol-wrap:hover .vol-pop, .vol-wrap:focus-within .vol-pop, .vol-wrap.open .vol-pop { display: block; }
.vol-panel { position: relative; width: 46px; height: 150px; background: rgba(11,29,51,.9); border-radius: 23px; box-shadow: 0 4px 14px rgba(0,0,0,.35); backdrop-filter: blur(6px); }
.vol-panel input[type=range] { position: absolute; left: 50%; top: 50%; width: 112px; height: 24px; margin: 0; padding: 0; border: 0; background: transparent; transform: translate(-50%, -50%) rotate(-90deg); accent-color: #2fb844; cursor: pointer; box-shadow: none; }
.vol-panel input[type=range]:focus { box-shadow: none; }

/* ---------- Datenbank-Banner & Geräte-Dialog ---------- */
.db-banner { position: fixed; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 120; display: flex; align-items: flex-start; gap: 10px; width: min(94vw, 560px); background: #b3261e; color: #fff; padding: 12px 14px; border-radius: 14px; font-size: 14px; font-weight: 600; line-height: 1.4; box-shadow: 0 8px 28px rgba(0,0,0,.45); }
.db-banner .ico { width: 22px; height: 22px; margin-top: 1px; }
.confirm-card { width: min(92vw, 420px); background: var(--card); border-radius: 22px; padding: 26px 22px 22px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.confirm-card h2 { margin: 0; font-size: 21px; }
.confirm-card p { margin: 0; font-size: 14.5px; line-height: 1.5; color: #34526f; }
.confirm-card .big-ico { width: 54px; height: 54px; color: #2a8bd8; }
#conflict { z-index: 110; align-items: center; }

/* Gefahrenzone in den Einstellungen */
.modal-body section.danger-zone { border: 2px solid rgba(217,71,63,.35); }
.modal-body section.danger-zone h3 { color: var(--danger); }
.modal-body .btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* Credit / GitHub */
.credit { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px auto 0; width: fit-content; padding: 7px 14px; border-radius: 999px; background: #e8f1fa; color: var(--ink); text-decoration: none; font: 700 13px var(--font); }
.credit:hover, .credit:focus-visible { background: #d6e7f7; }
.credit .ico { width: 18px; height: 18px; color: var(--ink); }
.dd-credit { display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 12px 12px; border-top: 1px solid #e1ebf5; border-radius: 0 0 10px 10px; text-decoration: none; font: 600 14px var(--font); color: var(--muted); }
.dd-credit:hover, .dd-credit:active { background: #e8f1fa; color: var(--ink); }
.dd-credit .ico { width: 20px; height: 20px; color: var(--ink); }
