/* =========================================================
   base.css – helles Pixel-Design (bewusst ein einziger, heller Look)
   Layout: Kopfzeile mit Schneekante · Seiteninhalt auf Pixel-Tafeln · Chat-Blase unten links
   ========================================================= */
:root {
  color-scheme: light;
  /* Farbe */
  --ink: #2b2d42;          /* Konturen */
  --text: #2b2d42;         /* Schrift */
  --on-ink: #ffffff;       /* Schrift auf dunklen Flächen */
  --ink-soft: #5b6283;     /* Nebentext */
  --paper: #fffaf0;        /* Tafeln */
  --paper-2: #fff0d4;      /* Tafeln hervorgehoben */
  --snow: #ffffff;
  --sky: #cfeaff;          /* Seitenhintergrund */
  --sky-2: #e9f6ff;
  --red: #e0453a;   --red-d: #a92d25;
  --green: #3a9e5c; --green-d: #26703f;
  --gold: #f2b33d;  --gold-d: #b57c14;
  --blue: #3b7dd8;  --blue-d: #24569e;
  --purple: #7a5cc4; --purple-d: #4f3a8a;
  --ice: #8fd3f4;
  --r-gewoehnlich: #8a94a6; --r-normal: #3f9a55; --r-selten: #3b7dd8; --r-episch: #8b5cd6; --r-legendaer: #e08a12; --r-mythisch: #e0457a;
  /* Schrift */
  /* Pixel-Schrift nur für Überschriften, alles andere in gut lesbarer Schrift */
  --f-pixel: "Pixelify Sans", "Trebuchet MS", system-ui, sans-serif;
  --f-text: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-tiny: var(--f-text);
  /* Pixel-Rahmen: eingekerbte Ecken über 4 Schatten */
  --b: 4px;
  --frame: 0 calc(-1 * var(--b)) 0 0 var(--ink), 0 var(--b) 0 0 var(--ink), calc(-1 * var(--b)) 0 0 0 var(--ink), var(--b) 0 0 0 var(--ink);
  --frame-thin: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink);
  --drop: 0 calc(var(--b) * 2.5) 0 0 rgba(43, 45, 66, .16);
  --gap: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--sky); color: var(--text);
  font-family: var(--f-text); font-size: 17px; line-height: 1.45;
  min-height: 100vh; -webkit-font-smoothing: none;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 40; background: var(--paper); }
img.spr { image-rendering: pixelated; image-rendering: crisp-edges; display: inline-block; vertical-align: middle; max-width: 100%; height: auto; }
img.spr.ico { width: 1.25em; height: 1.25em; }
img.spr.locked { filter: grayscale(1) opacity(.35); }
img.spr.missing { background: repeating-conic-gradient(#ff4fd8 0 25%, #fff 0 50%) 0 0 / 8px 8px; outline: 2px dashed var(--red); }

/* Seitenhintergrund (assets/bg/*.png) */
.page-bg { position: fixed; inset: 0; z-index: 0; background-size: cover; background-position: center bottom; image-rendering: pixelated; }
.page-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(233, 246, 255, .55), rgba(233, 246, 255, .2)); }
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 5; image-rendering: pixelated; }

.page { position: relative; z-index: 2; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 26px 120px; max-width: 1320px; margin: 0 auto; animation: pageIn .35s steps(5) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } }

h1, h2, h3 { font-family: var(--f-pixel); font-weight: 700; margin: 0; line-height: 1.1; text-wrap: balance; }
h1 { font-size: 40px; letter-spacing: .01em; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
p { margin: 0; }
a { color: var(--blue-d); }
.muted { color: var(--ink-soft); }
.small { font-size: 15px; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--f-tiny); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Kopfzeile ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--paper); box-shadow: 0 4px 0 0 var(--ink); }
.topbar::after { /* Schneekante */
  content: ""; position: absolute; left: 0; right: 0; bottom: -12px; height: 8px; pointer-events: none;
  background: linear-gradient(90deg, var(--snow) 0 12px, transparent 12px 20px, var(--snow) 20px 28px, transparent 28px 40px) 0 0 / 40px 4px repeat-x,
              linear-gradient(90deg, transparent 0 4px, var(--snow) 4px 8px, transparent 8px 40px) 0 4px / 40px 4px repeat-x;
}
.topbar-inner {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
  max-width: 1600px; margin: 0 auto; padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { justify-self: start; font-family: var(--f-pixel); font-weight: 700; font-size: 22px; color: var(--red-d); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--red); }

/* Menü mittig: jeder Punkt ein Pixel-Button, aktiv = Gold */
.nav-main { display: flex; gap: 8px; justify-content: center; flex-wrap: nowrap; }
.nav-btn {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text);
  padding: 6px; margin: 3px; position: relative; background: var(--snow);
  box-shadow: var(--frame-thin), inset 0 -4px 0 0 rgba(43, 45, 66, .16);
  transition: transform .1s steps(2), background-color .1s steps(2);
}
.nav-btn img { width: 32px; height: 32px; display: block; }
.nav-btn:hover, .nav-btn:focus-visible { transform: translateY(-3px); background: var(--paper-2); box-shadow: var(--frame-thin), inset 0 -4px 0 0 rgba(43, 45, 66, .16), 0 6px 0 0 rgba(43, 45, 66, .18); }
.nav-btn:hover img, .nav-btn:hover .nav-avatar { animation: hop .45s steps(3); }
.nav-btn:active { transform: translateY(1px); box-shadow: var(--frame-thin), inset 0 2px 0 0 rgba(43, 45, 66, .18); }
.nav-btn[aria-current="page"] { background: var(--gold); box-shadow: var(--frame-thin), inset 0 -4px 0 0 var(--gold-d); }
.nav-btn[aria-current="page"]:hover { background: #f7c45e; }
.nav-avatar { display: block; width: 32px; height: 32px; box-shadow: 0 0 0 2px var(--ink); background: var(--snow); }
.nav-avatar svg { display: block; width: 100%; height: 100%; }

/* Ressourcen rechts oben in der Ecke */
.hud-res { justify-self: end; display: grid; grid-template-columns: repeat(5, auto); gap: 4px 6px; }
.hud-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 4px; background: var(--snow);
  box-shadow: 0 0 0 2px var(--ink); margin: 2px; font-weight: 700; font-size: 14px; line-height: 1.25; white-space: nowrap; cursor: default;
}
.hud-chip img.spr { width: 16px; height: 16px; }
.hud-chip:hover { background: var(--paper-2); transform: translateY(-1px); }
.hud-chip.bump { animation: bump .5s steps(3); }
@keyframes hop { 50% { transform: translateY(-4px); } }

@media (max-width: 1240px) {
  .topbar-inner { grid-template-columns: minmax(0, 1fr); gap: 6px; padding-block: 6px 8px; }
  .brand { display: none; }
  .nav-main { overflow-x: auto; justify-content: safe center; scrollbar-width: none; padding: 2px; }
  .hud-res { justify-self: stretch; display: flex; overflow-x: auto; scrollbar-width: none; justify-content: safe center; }
}
@media (max-width: 640px) { .nav-main { gap: 2px; } .nav-btn { padding: 4px; } .nav-btn img, .nav-avatar { width: 26px; height: 26px; } .hud-res { flex-wrap: wrap; justify-content: center; overflow: visible; } .hud-chip { font-size: 13px; } }

/* Tooltip */
#tip {
  position: fixed; z-index: 200; max-width: 280px; pointer-events: none;
  background: var(--ink); color: var(--on-ink); font-size: 14px; font-weight: 700; line-height: 1.3; padding: 6px 9px;
  box-shadow: 0 4px 0 0 rgba(43, 45, 66, .25); animation: tipIn .12s steps(2);
}
#tip::before { content: ""; position: absolute; left: calc(var(--ax, 50%) - 5px); width: 10px; height: 5px; background: var(--ink); }
#tip[data-side="below"]::before { top: -5px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
#tip[data-side="above"]::before { bottom: -5px; clip-path: polygon(0 0, 100% 0, 50% 100%); }
@keyframes tipIn { from { opacity: 0; transform: translateY(2px); } }

/* ---------- Tafeln & Chips ---------- */
.panel { background: var(--paper); box-shadow: var(--frame), var(--drop); padding: 18px; margin: var(--b); min-width: 0; position: relative; }
.panel.sky { background: var(--sky-2); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; background: var(--snow); box-shadow: var(--frame-thin); margin: 3px; font-weight: 700; white-space: nowrap; }
.chip img.spr { width: 22px; height: 22px; }
.chip.bump { animation: bump .5s steps(4); }
@keyframes bump { 30% { transform: translateY(-6px) scale(1.08); background: var(--gold); } }
.tag { display: inline-block; font-family: var(--f-tiny); font-size: 11px; padding: 1px 6px; background: var(--ink); color: var(--on-ink); text-transform: uppercase; }
.tag.HH { background: var(--blue); } .tag.DA { background: var(--red); }
.tag.good { background: var(--green); } .tag.warn { background: var(--purple); }

/* ---------- Buttons & Formulare ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 17px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; margin: 4px; background: var(--snow); color: var(--text);
  box-shadow: var(--frame-thin), inset 0 -4px 0 0 rgba(43, 45, 66, .18);
  transition: transform .08s steps(2);
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn:active { transform: translateY(2px); box-shadow: var(--frame-thin), inset 0 2px 0 0 rgba(43, 45, 66, .18); }
.btn.primary { background: var(--gold); }
.btn.good { background: var(--green); color: var(--on-ink); }
.btn.red { background: var(--red); color: var(--on-ink); }
.btn.blue { background: var(--blue); color: var(--on-ink); }
.btn.danger { background: var(--snow); color: var(--red-d); }
.btn.small { padding: 4px 10px; font-size: 15px; }
.btn.big { padding: 12px 24px; font-size: 21px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: grayscale(.6); }
.btn img.spr { width: 24px; height: 24px; }
:focus-visible { outline: 4px solid var(--blue); outline-offset: 4px; }

label { font-weight: 700; font-size: 15px; display: block; margin-bottom: 6px; }
input[type="text"], input[type="number"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--snow); border: 0;
  box-shadow: var(--frame-thin); padding: 8px 12px; margin: 3px 0;
}
input:focus-visible, select:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 400; font-size: 16px; margin: 0; }
.toggle input { width: 20px; height: 20px; accent-color: var(--green); }

/* ---------- Balken ---------- */
.bar { height: 18px; background: var(--snow); box-shadow: var(--frame-thin); position: relative; margin: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: calc(var(--p) * 1%); background: var(--fill, var(--gold));
  background-image: repeating-linear-gradient(90deg, transparent 0 8px, rgba(255, 255, 255, .35) 8px 12px); transition: width .6s steps(8); }
.bar.anim > i { animation: barStripes 1s steps(4) infinite; }
@keyframes barStripes { to { background-position: 12px 0; } }
.bar .mark { position: absolute; top: 0; bottom: 0; width: 4px; background: var(--ink); left: calc(var(--m) * 1%); }

/* ---------- Seltenheit ---------- */
.rarity { font-family: var(--f-tiny); font-size: 11px; text-transform: uppercase; }
.rarity.gewoehnlich { color: var(--r-gewoehnlich); } .rarity.normal { color: var(--r-normal); } .rarity.mythisch { color: var(--r-mythisch); } .rarity.selten { color: var(--r-selten); } .rarity.episch { color: var(--r-episch); } .rarity.legendaer { color: var(--r-legendaer); }
.frame-r { box-shadow: 0 -4px 0 0 var(--rc), 0 4px 0 0 var(--rc), -4px 0 0 0 var(--rc), 4px 0 0 0 var(--rc); }
.frame-r.gewoehnlich { --rc: var(--r-gewoehnlich); } .frame-r.normal { --rc: var(--r-normal); } .frame-r.mythisch { --rc: var(--r-mythisch); } .frame-r.selten { --rc: var(--r-selten); } .frame-r.episch { --rc: var(--r-episch); } .frame-r.legendaer { --rc: var(--r-legendaer); }
.frame-r.legendaer, .frame-r.episch, .frame-r.mythisch { animation: shimmer 2s steps(6) infinite; }
.frame-r.mythisch { box-shadow: 0 -4px 0 0 var(--rc), 0 4px 0 0 var(--rc), -4px 0 0 0 var(--rc), 4px 0 0 0 var(--rc), 0 0 14px 2px rgba(224, 69, 122, .55); }
.rarity.mythisch { text-shadow: 0 0 6px rgba(224, 69, 122, .45); }
@keyframes shimmer { 50% { filter: brightness(1.12); } }

/* ---------- Toast & Modal ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(86px + env(safe-area-inset-top, 0px)); align-items: center; z-index: 70; display: flex; flex-direction: column; gap: 12px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--paper); box-shadow: var(--frame-thin), 0 6px 0 rgba(43, 45, 66, .2); padding: 10px 14px; margin: 3px; font-weight: 700; animation: toastIn .3s steps(4); border-left: 8px solid var(--gold); }
.toast.good { border-left-color: var(--green); } .toast.bad { border-left-color: var(--red); } .toast.epic { border-left-color: var(--purple); }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } }
.modal-back { position: fixed; inset: 0; background: rgba(43, 45, 66, .45); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fadeIn .2s steps(3); }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: var(--paper); box-shadow: var(--frame), 0 14px 0 rgba(43, 45, 66, .25); width: min(580px, calc(100% - 8px)); max-height: calc(100vh - 40px); overflow: auto; padding: 24px; animation: popIn .32s steps(4); }
@keyframes popIn { 0% { transform: scale(.6); } 70% { transform: scale(1.04); } }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 18px; flex-wrap: wrap; }

.rewards { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; justify-content: center; }
.res-row { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.tabs button { font: inherit; font-weight: 700; font-size: 17px; color: var(--text); background: var(--snow); border: 0; box-shadow: var(--frame-thin); padding: 6px 14px; margin: 4px; cursor: pointer; }
.tabs button:hover { transform: translateY(-2px); }
.tabs button[aria-selected="true"] { background: var(--gold); }

.empty { padding: 26px; text-align: center; color: var(--ink-soft); background: var(--sky-2); box-shadow: var(--frame-thin); margin: 4px; }
.notice { padding: 10px 14px; background: #ece4ff; box-shadow: 0 -3px 0 0 var(--purple), 0 3px 0 0 var(--purple), -3px 0 0 0 var(--purple), 3px 0 0 0 var(--purple); margin: 4px; font-size: 16px; }
.notice.info { background: var(--sky-2); box-shadow: var(--frame-thin); }

/* ---------- Chat-Blase (global) ---------- */
.chat-fab { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 55; border: 0; background: none; cursor: pointer; padding: 0; animation: bob 2.4s steps(4) infinite; }
.chat-fab img { width: 72px; height: 72px; filter: drop-shadow(0 6px 0 rgba(43, 45, 66, .25)); }
.chat-fab .count { position: absolute; top: -4px; right: -6px; background: var(--red); color: var(--on-ink); font-family: var(--f-tiny); font-size: 13px; min-width: 26px; height: 26px; display: grid; place-items: center; box-shadow: var(--frame-thin); }
.chat-pop { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(104px + env(safe-area-inset-bottom, 0px)); z-index: 56; width: min(380px, calc(100vw - 32px)); background: var(--paper); box-shadow: var(--frame), 0 12px 0 rgba(43, 45, 66, .25); display: flex; flex-direction: column; max-height: min(560px, calc(100vh - 200px)); transform-origin: bottom left; animation: popIn .3s steps(4); }
.chat-pop[hidden] { display: none; }
.chat-pop header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--blue); color: var(--on-ink); }
.chat-pop header h2 { font-size: 21px; }
.chat-pop header button { background: none; border: 0; color: var(--on-ink); font: inherit; font-size: 26px; cursor: pointer; line-height: 1; }
.chat-list { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 160px; }
.msg { background: var(--snow); box-shadow: var(--frame-thin); padding: 6px 10px; margin: 3px; font-size: 16px; animation: msgIn .25s steps(3); }
.msg b { color: var(--blue-d); }
.msg.me { background: #e3f6e8; align-self: flex-end; max-width: 90%; } .msg.me b { color: var(--green-d); }
.msg.sys { background: #ece4ff; }
@keyframes msgIn { from { transform: translateY(6px); opacity: 0; } }
.chat-form { display: flex; gap: 4px; padding: 10px; background: var(--paper-2); align-items: center; }
.chat-form input { margin: 3px; }
@keyframes bob { 50% { transform: translateY(-5px); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 760px) { h1 { font-size: 30px; } body { font-size: 16px; } }

/* ---------- Hover für Karten & Items (überall gleich) ---------- */
.card, .badge-card, .res-card, .stat, .reveal, .listing { transition: transform .1s steps(2), box-shadow .1s steps(2); }
@media (hover: hover) {
  .card:hover, .badge-card:hover, .res-card:hover, .listing:hover { transform: translateY(-4px); box-shadow: var(--frame), 0 calc(var(--b) * 3.5) 0 0 rgba(43, 45, 66, .2); }
  .card.equipped:hover { box-shadow: 0 -4px 0 0 var(--gold-d), 0 4px 0 0 var(--gold-d), -4px 0 0 0 var(--gold-d), 4px 0 0 0 var(--gold-d), 0 14px 0 0 rgba(43, 45, 66, .2); }
  .card:hover .c-art img.spr, .res-card:hover img.spr, .badge-card:hover img.spr, .listing:hover img.spr { animation: hop .45s steps(3); }
  .stat:hover { transform: translateY(-2px); background: var(--paper-2); }
  .badge-shelf > span:hover img.spr { animation: hop .45s steps(3); }
  .rl-list li:hover { background: var(--paper-2); }
  .chip[title]:hover, .chip[data-tip]:hover { background: var(--paper-2); }
  .btn:not([disabled]):hover { transform: translateY(-2px); }
}

/* =========================================================
   Darstellung: Dunkelmodus, große Schrift, hoher Kontrast, Tageszeit
   ========================================================= */
html[data-theme="dark"] {
  --ink: #07080f; --text: #eef0fa; --ink-soft: #b4bad6; --on-ink: #ffffff;
  --paper: #262b45; --paper-2: #343b60; --snow: #2f3656; --sky: #12162c; --sky-2: #1d2340;
  --drop: 0 calc(var(--b) * 2.5) 0 0 rgba(0, 0, 0, .35);
  color-scheme: dark;
}
html[data-theme="dark"] .page-bg { filter: brightness(.42) saturate(.8); }
html[data-theme="dark"] .page-bg::after { background: linear-gradient(rgba(18, 22, 44, .55), rgba(18, 22, 44, .25)); }
html[data-theme="dark"] :is(.btn.primary, .btn.good, .nav-btn[aria-current="page"], .tabs button[aria-selected="true"], .w-item[aria-pressed="true"], .cc-opt[aria-selected="true"], .seg button[aria-pressed="true"], .st-list button[aria-pressed="true"], .bonus span, .pill.ok, .pill.ph, .pill.now, .chip.bump, .hud-chip.bump, .lot.me) { color: #2b2d42; }
html[data-theme="dark"] .btn.good { color: #fff; }
html[data-theme="dark"] :is(.notice, .msg.sys) { background: #3a3166; }
html[data-theme="dark"] .msg.me, html[data-theme="dark"] .ov-attack.done { background: #1f4a33; }
html[data-theme="dark"] .lot.me { background: linear-gradient(#5c4a22 0 70%, var(--snow) 70%); }
html[data-theme="dark"] .lot.me .plate { color: var(--text); }
html[data-theme="dark"] tr.today { background: #4a3e1c; }
html[data-theme="dark"] .dz-scroll { background: #12162c; }
html[data-theme="dark"] :is(.pod.p2 .step, .podium .p2 .step) { background: #4b5576; }
html[data-theme="dark"] :is(.pod.p3 .step, .podium .p3 .step) { background: #7a5634; }
html[data-theme="dark"] .brand { color: #ff8f84; }
html[data-theme="dark"] .rarity.gewoehnlich { color: #c2cad8; }
html[data-theme="dark"] img.spr { filter: brightness(.95); }

/* große Schrift: Inhalt und Kopfzeile werden gleichmäßig vergrößert */
html[data-font="large"] :is(#topbar, main, .modal, .chat-pop) { zoom: 1.15; }
html[data-font="large"] #tip, html[data-font="large"] .toast { font-size: 17px; }

/* hoher Kontrast: kräftige Schrift, keine Hintergrundbilder, kein Schnee */
html[data-contrast="high"] { --ink-soft: var(--text); }
html[data-contrast="high"]:not([data-theme="dark"]) { --text: #000; --ink: #000; --paper: #fff; --paper-2: #fff3cc; --sky: #fff; --sky-2: #eef4ff; }
html[data-contrast="high"][data-theme="dark"] { --text: #fff; --ink: #000; --paper: #000; --paper-2: #222; --snow: #111; --sky: #000; --sky-2: #0c0c0c; }
html[data-contrast="high"] .page-bg { display: none; }
html[data-contrast="high"] .muted, html[data-contrast="high"] .small { color: var(--text); }
html[data-contrast="high"] :is(.panel, .btn, .nav-btn, .chip, .hud-chip) { outline: 2px solid var(--ink); outline-offset: 0; }
html[data-contrast="high"] a { text-decoration: underline; text-underline-offset: 3px; }

/* Header links: Serie, Glocke, Sound */
.hud-left { justify-self: start; display: flex; align-items: center; gap: 8px; min-width: 0; }
.hud-btn {
  appearance: none; border: 0; font: inherit; color: var(--text); background: var(--snow); box-shadow: 0 0 0 2px var(--ink);
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px; margin: 2px; position: relative; cursor: pointer; height: 30px;
}
.hud-btn:hover { background: var(--paper-2); transform: translateY(-2px); }
.hud-btn .pix { display: block; width: 20px; height: 20px; }
.hud-btn.streak { cursor: default; font-weight: 700; font-size: 15px; }
.hud-btn.streak.cold .pix { filter: grayscale(1) opacity(.55); }
.hud-btn.streak.lit .pix { animation: flick 1.2s steps(2) infinite; }
@keyframes flick { 50% { transform: translateY(-1px) scaleY(1.08); } }
.hud-btn .count { position: absolute; top: -8px; right: -8px; min-width: 18px; height: 18px; padding: 0 4px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--ink); }
.bell-pop {
  position: fixed; z-index: 120; width: min(340px, calc(100vw - 16px)); max-height: min(70vh, 520px); display: flex; flex-direction: column;
  background: var(--paper); box-shadow: var(--frame), var(--drop); animation: tipIn .15s steps(3);
}
.bell-pop header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 3px solid var(--ink); }
.bell-pop h2 { font-size: 20px; }
.bell-pop ul { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.bell-pop li { display: flex; gap: 10px; padding: 8px; font-size: 15px; line-height: 1.3; border-bottom: 2px dashed rgba(91, 98, 131, .25); }
.bell-pop li.new { background: var(--paper-2); font-weight: 700; }
.bell-pop li small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.bell-pop .ni { flex: none; font-size: 18px; width: 24px; text-align: center; }
@media (max-width: 1240px) { .hud-left { justify-self: center; } .hud-left .brand { display: none; } }

/* Einführungs-Tour */
.tour { position: fixed; inset: 0; z-index: 300; }
.tour-hole { position: fixed; box-shadow: 0 0 0 4px var(--gold), 0 0 0 9999px rgba(15, 17, 35, .66); transition: all .25s steps(5); pointer-events: none; }
.tour-bubble { position: fixed; background: var(--paper); box-shadow: var(--frame), var(--drop); padding: 16px 18px; }
.tour-bubble h2 { font-size: 22px; margin: 2px 0 6px; }
.tour-bubble p { margin: 0 0 12px; }

/* Story-Comic */
.story-modal { width: min(620px, calc(100vw - 24px)); }
.comic { display: flex; flex-direction: column; gap: 12px; max-height: min(56vh, 460px); overflow-y: auto; padding: 4px; }
.panel-line { display: flex; gap: 12px; align-items: flex-start; }
.panel-line.pixi, .panel-line.dorf { flex-direction: row-reverse; text-align: right; }
.panel-line .who { flex: none; width: 74px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.panel-line .who img.spr, .panel-line .who svg { width: 56px; height: 56px; display: block; }
.panel-line .who svg { box-shadow: 0 0 0 2px var(--ink); }
.panel-line .say { position: relative; background: var(--snow); box-shadow: var(--frame-thin); margin: 6px 3px; padding: 10px 14px; font-size: 17px; text-align: left; }
.panel-line.grummel .say { background: #efe6ff; color: #2b2d42; }
html[data-theme="dark"] .panel-line.grummel .say { background: #3a3166; color: var(--text); }
.panel-line.fresh { animation: cardIn .3s steps(4) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } }

/* Tageszeit über Karten */
.daytint { position: absolute; inset: 0; pointer-events: none; z-index: 5000; transition: background .6s steps(6); mix-blend-mode: multiply; }
html[data-daytime="morgen"] .daytint { background: rgba(255, 196, 160, .22); }
html[data-daytime="abend"] .daytint { background: rgba(232, 120, 70, .34); }
html[data-daytime="nacht"] .daytint { background: rgba(28, 34, 96, .62); }
.lamp { position: absolute; width: calc(var(--r, 26) * 1px); height: calc(var(--r, 26) * 1px); transform: translate(-50%, -50%); pointer-events: none; z-index: 5001; display: none;
  background: radial-gradient(circle, rgba(255, 226, 120, .95) 0 18%, rgba(255, 200, 80, .45) 35%, rgba(255, 190, 60, 0) 70%); }
html:is([data-daytime="abend"], [data-daytime="nacht"]) .lamp { display: block; animation: lampFlicker 2.4s steps(3) infinite; }
@keyframes lampFlicker { 50% { opacity: .82; } }
@media (prefers-reduced-motion: reduce) { .lamp, .hud-btn.streak.lit .pix { animation: none !important; } }

/* Flug-Effekte & Funken */
.flyer { position: fixed; z-index: 400; pointer-events: none; filter: drop-shadow(0 3px 0 rgba(43, 45, 66, .3)); }
.flyer img.spr { display: block; width: 32px; height: 32px; }
.flyer.item img.spr, .flyer.item svg { width: 48px; height: auto; display: block; }
.spark { position: fixed; z-index: 399; width: 6px; height: 6px; pointer-events: none; box-shadow: 0 0 0 1px rgba(43, 45, 66, .25); }
.hud-chip.jump { animation: goldJump .5s steps(4); }
@keyframes goldJump { 30% { transform: translateY(-9px) scale(1.18); background: var(--gold); color: #2b2d42; } 60% { transform: translateY(2px); } }
.nav-btn.got { animation: gotIt .55s steps(4); }
@keyframes gotIt { 35% { transform: scale(1.22) rotate(-6deg); background: var(--gold); } 70% { transform: scale(.95); } }

/* Fenster-Modus: Seite läuft als Fenster über dem 3D-Dorf */
html.embed .nav-main, html.embed .hud-left, html.embed .topbar::after, html.embed .page-bg, html.embed #snow, html.embed .chat-fab, html.embed .chat-pop, html.embed .gp-back, html.embed a.back { display: none !important; }
html.embed .topbar { position: sticky; top: 0; box-shadow: 0 3px 0 0 var(--ink); }
html.embed .topbar-inner { grid-template-columns: 1fr; padding-block: 6px; }
html.embed .hud-res { justify-self: center; }
html.embed .page { padding-block: 16px 40px; }

/* Dorfplatz: schmale Leiste – links Ton/Glocke, mittig Ressourcen */
.topbar.slim { box-shadow: 0 2px 0 0 var(--ink); }
.topbar.slim::after { display: none; }
.topbar.slim .topbar-inner { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); padding-block: 2px; gap: 10px; }
.topbar.slim .hud-left { display: flex; gap: 4px; align-items: center; }
.topbar.slim .hud-btn { transform: scale(.82); }
.topbar.slim .hud-res { justify-self: center; display: flex; flex-wrap: wrap; justify-content: center; gap: 0 4px; }
.topbar.slim .hud-chip { font-size: 13px; padding: 0 6px 0 3px; margin: 1px; }
@media (max-width: 1240px) { .topbar.slim .topbar-inner { grid-template-columns: auto minmax(0, 1fr); } .topbar.slim .topbar-inner > div:last-child { display: none; } }

/* Event-Leiste (Countdown für alle) */
.ev-bar { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 44px); display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 24px); padding: 6px 8px 6px 12px; background: var(--paper); color: var(--text); box-shadow: 0 0 0 3px var(--ink), 0 5px 0 0 rgba(43, 45, 66, .25); font-size: 14px; }
.ev-bar .ev-ic { font-size: 24px; line-height: 1; }
.ev-bar .ev-t { line-height: 1.3; }
.ev-bar .ev-clock { font-variant-numeric: tabular-nums; }
.ev-bar.live { background: var(--gold); animation: evPulse 1.4s steps(4) infinite; }
@keyframes evPulse { 50% { box-shadow: 0 0 0 3px var(--ink), 0 0 0 7px rgba(242, 179, 61, .45); } }
@media (max-width: 640px) { .ev-bar { font-size: 12.5px; top: calc(env(safe-area-inset-top, 0px) + 70px); } }
