/* ==========================================================================
   Kachel-Echo – Stylesheet & individuelle Map-Themes
   100 % lokal, Mobile First, Touch-optimiert
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100dvh;
    font-family: var(--le-font-sans);
    color: var(--le-ink);
    background: var(--le-bg);
    overflow-x: hidden;
}

.mono {
    font-family: var(--le-font-mono);
    font-variant-numeric: tabular-nums;
}

.ke-shell {
    --stage-bg: linear-gradient(160deg, #fdfaf3 0%, #f5efe2 100%);
    --stage-ink: #2b2118;
    --stage-muted: #66584b;
    --stage-surface: rgba(255, 255, 255, 0.88);
    --stage-border: rgba(74, 53, 32, 0.14);
    --stage-accent: #16a34a;
    --board-bg: rgba(255, 255, 255, 0.72);
    --board-shadow: 0 18px 44px rgba(43, 33, 24, 0.12);

    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--stage-bg);
    color: var(--stage-ink);
    transition: background 0.35s ease, color 0.25s ease;
    padding-bottom: env(safe-area-inset-bottom, 12px);
}

/* ---------------- INDIVIDUELLE MAP-THEMES ---------------- */

.ke-shell.theme-klassik {
    --stage-bg: radial-gradient(circle at 18% 12%, #fef3c7 0%, #ecfccb 48%, #dcfce7 100%);
    --stage-ink: #1e293b;
    --stage-muted: #475569;
    --stage-surface: rgba(255, 255, 255, 0.90);
    --stage-border: rgba(22, 163, 74, 0.22);
    --stage-accent: #16a34a;
    --board-bg: rgba(255, 255, 255, 0.82);
    --board-shadow: 0 20px 48px rgba(22, 163, 74, 0.16);
}

.ke-shell.theme-spiegel {
    --stage-bg: radial-gradient(circle at 50% 0%, #0ea5e9 0%, #0369a1 38%, #082f49 100%);
    --stage-ink: #f0f9ff;
    --stage-muted: #bae6fd;
    --stage-surface: rgba(12, 74, 110, 0.65);
    --stage-border: rgba(125, 211, 252, 0.34);
    --stage-accent: #38bdf8;
    --board-bg: rgba(8, 47, 73, 0.68);
    --board-shadow: 0 22px 54px rgba(2, 132, 199, 0.35);
}

.ke-shell.theme-pfeil {
    --stage-bg: radial-gradient(circle at 80% 10%, #4d7c0f 0%, #14532d 48%, #052e16 100%);
    --stage-ink: #f7fee7;
    --stage-muted: #bef264;
    --stage-surface: rgba(20, 83, 45, 0.72);
    --stage-border: rgba(163, 230, 53, 0.30);
    --stage-accent: #84cc16;
    --board-bg: rgba(5, 46, 22, 0.72);
    --board-shadow: 0 22px 54px rgba(5, 46, 22, 0.45);
}

.ke-shell.theme-umkehren {
    --stage-bg: radial-gradient(circle at 20% 20%, #7e22ce 0%, #3b0764 46%, #0f0720 100%);
    --stage-ink: #faf5ff;
    --stage-muted: #e9d5ff;
    --stage-surface: rgba(59, 7, 100, 0.68);
    --stage-border: rgba(216, 180, 254, 0.28);
    --stage-accent: #c084fc;
    --board-bg: rgba(30, 27, 75, 0.74);
    --board-shadow: 0 22px 54px rgba(147, 51, 234, 0.35);
}

.ke-shell.theme-turbo {
    --stage-bg: radial-gradient(circle at 50% 10%, #0f172a 0%, #020617 68%, #083344 100%);
    --stage-ink: #ecfeff;
    --stage-muted: #67e8f9;
    --stage-surface: rgba(15, 23, 42, 0.82);
    --stage-border: rgba(34, 211, 238, 0.34);
    --stage-accent: #22d3ee;
    --board-bg: rgba(2, 6, 23, 0.86);
    --board-shadow: 0 0 42px rgba(6, 182, 212, 0.28);
}

.ke-shell.theme-schatten {
    --stage-bg: radial-gradient(circle at 50% 15%, #1e293b 0%, #0f172a 55%, #020617 100%);
    --stage-ink: #fef9c3;
    --stage-muted: #cbd5e1;
    --stage-surface: rgba(15, 23, 42, 0.82);
    --stage-border: rgba(250, 204, 21, 0.28);
    --stage-accent: #facc15;
    --board-bg: rgba(15, 23, 42, 0.88);
    --board-shadow: 0 22px 54px rgba(0, 0, 0, 0.55);
}

.ke-shell.theme-rhythmus {
    --stage-bg: radial-gradient(circle at 30% 10%, #881337 0%, #4c0519 48%, #1f0710 100%);
    --stage-ink: #fff1f2;
    --stage-muted: #fda4af;
    --stage-surface: rgba(76, 5, 25, 0.72);
    --stage-border: rgba(251, 113, 133, 0.34);
    --stage-accent: #fb7185;
    --board-bg: rgba(45, 6, 18, 0.78);
    --board-shadow: 0 22px 54px rgba(190, 18, 60, 0.35);
}

.ke-shell.theme-falle {
    --stage-bg: radial-gradient(circle at 75% 10%, #9a3412 0%, #431407 48%, #1c1917 100%);
    --stage-ink: #ffedd5;
    --stage-muted: #fdba74;
    --stage-surface: rgba(41, 37, 36, 0.76);
    --stage-border: rgba(251, 146, 60, 0.34);
    --stage-accent: #fb923c;
    --board-bg: rgba(28, 25, 23, 0.82);
    --board-shadow: 0 22px 54px rgba(194, 65, 12, 0.38);
}

.ke-shell.theme-chaos {
    --stage-bg: radial-gradient(circle at 20% 15%, #0f766e 0%, #312e81 48%, #701a75 100%);
    --stage-ink: #f8fafc;
    --stage-muted: #e9d5ff;
    --stage-surface: rgba(30, 27, 75, 0.68);
    --stage-border: rgba(244, 114, 182, 0.35);
    --stage-accent: #f472b6;
    --board-bg: rgba(15, 23, 42, 0.68);
    --board-shadow: 0 22px 54px rgba(236, 72, 153, 0.32);
}

.ke-shell.theme-ohren {
    --stage-bg: radial-gradient(circle at 50% 10%, #1d4ed8 0%, #0f172a 56%, #020617 100%);
    --stage-ink: #eff6ff;
    --stage-muted: #93c5fd;
    --stage-surface: rgba(15, 23, 42, 0.76);
    --stage-border: rgba(96, 165, 250, 0.34);
    --stage-accent: #38bdf8;
    --board-bg: rgba(15, 23, 42, 0.82);
    --board-shadow: 0 22px 54px rgba(29, 78, 216, 0.38);
}

.ke-shell.theme-takt-starter {
    --stage-bg: radial-gradient(circle at 25% 15%, #fef3c7 0%, #fed7aa 48%, #fde68a 100%);
    --stage-ink: #451a03;
    --stage-muted: #92400e;
    --stage-surface: rgba(255, 255, 255, 0.88);
    --stage-border: rgba(217, 119, 6, 0.28);
    --stage-accent: #d97706;
    --board-bg: rgba(255, 255, 255, 0.80);
    --board-shadow: 0 20px 46px rgba(217, 119, 6, 0.22);
}

.ke-shell.theme-nebel {
    --stage-bg: radial-gradient(circle at 50% 18%, #334155 0%, #0f172a 55%, #020617 100%);
    --stage-ink: #f1f5f9;
    --stage-muted: #94a3b8;
    --stage-surface: rgba(15, 23, 42, 0.75);
    --stage-border: rgba(148, 163, 184, 0.24);
    --stage-accent: #e0f2fe;
    --board-bg: rgba(2, 6, 23, 0.56);
    --board-shadow: 0 22px 54px rgba(0, 0, 0, 0.52);
}

.ke-shell.theme-karussell {
    --stage-bg: radial-gradient(circle at 50% 10%, #0891b2 0%, #164e63 52%, #083344 100%);
    --stage-ink: #ecfeff;
    --stage-muted: #a5f3fc;
    --stage-surface: rgba(8, 51, 68, 0.75);
    --stage-border: rgba(34, 211, 238, 0.35);
    --stage-accent: #22d3ee;
    --board-bg: rgba(14, 116, 144, 0.45);
    --board-shadow: 0 22px 54px rgba(6, 182, 212, 0.34);
}

.ke-shell.theme-doppel {
    --stage-bg: radial-gradient(circle at 50% 10%, #854d0e 0%, #422006 52%, #1c1917 100%);
    --stage-ink: #fefce8;
    --stage-muted: #fde047;
    --stage-surface: rgba(66, 32, 6, 0.76);
    --stage-border: rgba(250, 204, 21, 0.34);
    --stage-accent: #facc15;
    --board-bg: rgba(28, 25, 23, 0.80);
    --board-shadow: 0 22px 54px rgba(234, 179, 8, 0.28);
}

.ke-shell.theme-duett {
    --stage-bg: linear-gradient(135deg, #1e3a8a 0%, #4c1d95 50%, #9a3412 100%);
    --stage-ink: #f8fafc;
    --stage-muted: #e2e8f0;
    --stage-surface: rgba(15, 23, 42, 0.72);
    --stage-border: rgba(255, 255, 255, 0.26);
    --stage-accent: #60a5fa;
    --board-bg: rgba(15, 23, 42, 0.70);
    --board-shadow: 0 22px 54px rgba(0, 0, 0, 0.38);
}

.ke-shell.theme-dreifach {
    --stage-bg: radial-gradient(circle at 25% 15%, #9d174d 0%, #312e81 55%, #0f172a 100%);
    --stage-ink: #fdf2f8;
    --stage-muted: #fbcfe8;
    --stage-surface: rgba(49, 46, 129, 0.72);
    --stage-border: rgba(244, 114, 182, 0.34);
    --stage-accent: #f472b6;
    --board-bg: rgba(15, 23, 42, 0.76);
    --board-shadow: 0 22px 54px rgba(190, 24, 93, 0.34);
}

.ke-shell.theme-duell {
    --stage-bg: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 50%, #be123c 100%);
    --stage-ink: #f8fafc;
    --stage-muted: #e2e8f0;
    --stage-surface: rgba(15, 23, 42, 0.72);
    --stage-border: rgba(255, 255, 255, 0.28);
    --stage-accent: #a855f7;
    --board-bg: rgba(15, 23, 42, 0.72);
    --board-shadow: 0 22px 54px rgba(0, 0, 0, 0.40);
}

.ke-shell.theme-geheim-falle {
    --stage-bg: radial-gradient(circle at 25% 15%, #065f46 0%, #022c22 52%, #0f172a 100%);
    --stage-ink: #ecfdf5;
    --stage-muted: #6ee7b7;
    --stage-surface: rgba(2, 44, 34, 0.78);
    --stage-border: rgba(52, 211, 153, 0.30);
    --stage-accent: #34d399;
    --board-bg: rgba(15, 23, 42, 0.78);
    --board-shadow: 0 22px 54px rgba(6, 78, 59, 0.45);
}

/* ---------------- TOPBAR ---------------- */

.ke-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
    max-width: 1040px;
    width: 100%;
    margin: 0 auto;
    z-index: 20;
}

.ke-topbar-left,
.ke-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ke-home-btn,
.ke-maps-btn,
.ke-icon-btn,
.ke-coins-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 13px;
    border-radius: 999px;
    border: 1.5px solid var(--stage-border);
    background: var(--stage-surface);
    color: var(--stage-ink);
    font-size: 0.92rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.14s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.ke-home-btn:active,
.ke-maps-btn:active,
.ke-icon-btn:active {
    transform: scale(0.95);
}

.ke-icon-btn {
    padding: 0 12px;
}

.ke-coins-pill {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #78350f;
    border-color: rgba(217, 119, 6, 0.35);
    cursor: default;
}

.ke-badge-count {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ---------------- MENU / MAP-AUSWAHL ---------------- */

.ke-menu-view {
    flex: 1;
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 4px 16px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ke-hero {
    text-align: center;
    padding: 10px 12px 4px;
}

.ke-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid rgba(2, 132, 199, 0.22);
}

.ke-hero-title {
    margin: 8px 0 4px;
    font-size: clamp(1.75rem, 4.5vw, 2.5rem);
    font-weight: 900;
    letter-spacing: -0.02em;
}

.ke-hero-sub {
    margin: 0 auto;
    max-width: 540px;
    font-size: 0.98rem;
    color: var(--le-ink-muted);
    line-height: 1.45;
}

.ke-maps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px;
}

.ke-map-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 22px;
    border: 2px solid rgba(255, 255, 255, 0.55);
    color: #ffffff;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.14);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ke-map-card.is-light-card {
    color: #1e293b;
    border-color: rgba(22, 163, 74, 0.26);
}

.ke-map-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.20);
}

.ke-map-card:active {
    transform: scale(0.98);
}

.ke-map-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.ke-map-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.ke-map-card.is-light-card .ke-map-icon-wrap {
    background: rgba(255, 255, 255, 0.72);
}

.ke-map-grid-pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    background: rgba(0, 0, 0, 0.24);
}

.ke-map-card.is-light-card .ke-map-grid-pill {
    background: rgba(255, 255, 255, 0.72);
    color: #1e293b;
}

.ke-map-name {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: -0.01em;
}

.ke-map-rule {
    margin: 2px 0 0;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.92;
}

.ke-map-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.ke-map-card.is-light-card .ke-map-card-foot {
    border-top-color: rgba(30, 41, 59, 0.12);
}

.ke-map-best {
    font-size: 0.84rem;
    font-weight: 800;
}

.ke-map-medals {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ke-medal-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    background: rgba(0, 0, 0, 0.22);
    opacity: 0.55;
}

.ke-map-card.is-light-card .ke-medal-dot {
    background: rgba(255, 255, 255, 0.65);
    color: #334155;
}

.ke-medal-dot.is-done {
    opacity: 1;
    background: rgba(255, 255, 255, 0.94);
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.ke-medal-dot.is-diamond.is-done {
    background: linear-gradient(135deg, #cffafe 0%, #67e8f9 100%);
    color: #083344;
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.55);
}

/* ---------------- SPIELFELD-ANSICHT ---------------- */

.ke-stage-view {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px 14px 18px;
}

.ke-stage-inner {
    width: 100%;
    max-width: 540px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ke-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 18px;
    background: var(--stage-surface);
    border: 1.5px solid var(--stage-border);
    backdrop-filter: blur(10px);
}

.ke-stage-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ke-stage-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    display: grid;
    place-items: center;
    font-size: 1.45rem;
    flex-shrink: 0;
}

.theme-klassik .ke-stage-icon {
    background: #dcfce7;
}

.ke-stage-name {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 900;
    line-height: 1.2;
}

.ke-stage-rule {
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--stage-muted);
}

.ke-stage-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ke-stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 56px;
    padding: 4px 9px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.12);
}

.theme-klassik .ke-stat-box {
    background: rgba(22, 163, 74, 0.10);
}

.ke-stat-label {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--stage-muted);
}

.ke-stat-val {
    font-size: 1.12rem;
    font-weight: 900;
}

/* Status-Zeile & Etappen */

.ke-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.ke-phase-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 800;
    background: var(--stage-surface);
    border: 1.5px solid var(--stage-border);
    transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease;
}

.ke-phase-pill.is-watching {
    background: #fef3c7;
    color: #92400e;
    border-color: #f59e0b;
}

.ke-phase-pill.is-playing {
    background: #dcfce7;
    color: #14532d;
    border-color: #22c55e;
    transform: scale(1.03);
}

.ke-phase-pill.is-win {
    background: #dbeafe;
    color: #1e3a8a;
    border-color: #3b82f6;
}

.ke-phase-pill.is-fail {
    background: #ffe4e6;
    color: #9f1239;
    border-color: #f43f5e;
}

.ke-phase-pill.is-p1 {
    background: #dbeafe;
    color: #1e3a8a;
    border-color: #3b82f6;
    transform: scale(1.03);
}

.ke-phase-pill.is-p2 {
    background: #ffedd5;
    color: #7c2d12;
    border-color: #f97316;
    transform: scale(1.03);
}

.ke-milestones-bar {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ke-ms-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    background: var(--stage-surface);
    border: 1px solid var(--stage-border);
    opacity: 0.65;
}

.ke-ms-chip.is-done {
    opacity: 1;
    background: #fef3c7;
    color: #78350f;
    border-color: #f59e0b;
}

.ke-ms-chip.is-diamond.is-done {
    background: linear-gradient(135deg, #cffafe 0%, #67e8f9 100%);
    color: #083344;
    border-color: #06b6d4;
}

/* Fortschrittspunkte */

.ke-progress-pips {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 14px;
    flex-wrap: wrap;
}

.ke-pip {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: var(--stage-border);
    transition: transform 0.15s ease, background 0.15s ease;
}

.ke-pip.is-done {
    background: #22c55e;
    transform: scale(1.1);
}

.ke-pip.is-current {
    background: #facc15;
    transform: scale(1.25);
    box-shadow: 0 0 8px rgba(250, 204, 21, 0.7);
}

/* ---------------- RASTER / BRETT ---------------- */

.ke-board-frame {
    position: relative;
    width: 100%;
    max-width: min(460px, 92vw, 56dvh);
    aspect-ratio: 1 / 1;
    margin: 2px auto 0;
    padding: 14px;
    border-radius: 26px;
    background: var(--board-bg);
    border: 2px solid var(--stage-border);
    box-shadow: var(--board-shadow);
    backdrop-filter: blur(12px);
    user-select: none;
    touch-action: manipulation;
}

.ke-board {
    width: 100%;
    height: 100%;
    display: grid;
    gap: 11px;
    grid-template-columns: repeat(var(--cols, 3), 1fr);
    grid-template-rows: repeat(var(--rows, 3), 1fr);
}

.ke-board-rotator {
    position: relative;
    width: 100%;
    height: 100%;
    transform: rotate(var(--rot, 0deg));
    transition: transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
}

.ke-rotate-marker {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #22d3ee;
    color: #083344;
    border: 2px solid #ffffff;
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 900;
    box-shadow: 0 3px 10px rgba(8, 51, 68, 0.45);
    z-index: 4;
    pointer-events: none;
}

/* Spiegel-Achse für Spiegel-See */
.ke-mirror-axis {
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 50%;
    width: 4px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(125, 211, 252, 0.2), #7dd3fc 50%, rgba(125, 211, 252, 0.2));
    border-radius: 999px;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.85);
    pointer-events: none;
    z-index: 4;
}

.ke-mirror-chip {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: #0284c7;
    border: 2px solid #bae6fd;
    display: grid;
    place-items: center;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.5);
}

/* Kacheln */

.ke-tile {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 18px;
    border: 2.5px solid var(--tile-border, #cbd5e1);
    background: var(--tile-bg, #ffffff);
    color: var(--tile-ink, #1e293b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.3rem, 4.5vw, 2rem);
    font-weight: 900;
    box-shadow:
        0 6px 0 rgba(0, 0, 0, 0.16),
        inset 0 2px 0 rgba(255, 255, 255, 0.35);
    transition:
        transform 0.11s ease,
        background 0.12s ease,
        box-shadow 0.12s ease,
        border-color 0.12s ease,
        filter 0.12s ease;
}

.ke-tile:disabled {
    cursor: default;
}

.ke-tile:not(:disabled):active {
    transform: translateY(3px) scale(0.97);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

/* Map-spezifische Kachel-Details */
.theme-spiegel .ke-tile {
    border-radius: 16px;
    background: linear-gradient(155deg, rgba(224, 242, 254, 0.25) 0%, rgba(14, 165, 233, 0.22) 100%);
    border-color: rgba(125, 211, 252, 0.45);
    color: #e0f2fe;
}

.theme-pfeil .ke-tile {
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(132, 204, 22, 0.22) 0%, rgba(20, 83, 45, 0.72) 100%);
    border-color: rgba(163, 230, 53, 0.42);
    color: #ecfccb;
}

.theme-umkehren .ke-tile {
    border-radius: 22px;
    background: linear-gradient(155deg, rgba(168, 85, 247, 0.24) 0%, rgba(30, 27, 75, 0.76) 100%);
    border-color: rgba(192, 132, 252, 0.42);
    color: #faf5ff;
}

.theme-turbo .ke-tile {
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(30, 41, 59, 0.92) 0%, rgba(15, 23, 42, 0.96) 100%);
    border-color: var(--tile-border);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.42), 0 0 10px rgba(34, 211, 238, 0.12);
}

.theme-schatten .ke-tile {
    border-radius: 18px;
    background: linear-gradient(155deg, #1e293b 0%, #0f172a 100%);
    border-color: rgba(148, 163, 184, 0.30);
    color: rgba(248, 250, 252, 0.22);
}

/* Aktives Aufblinken */
.ke-tile.is-lit {
    background: var(--tile-glow, #facc15) !important;
    border-color: #ffffff !important;
    color: #0f172a !important;
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 0 28px var(--tile-glow, #facc15),
        0 6px 0 rgba(0, 0, 0, 0.16),
        inset 0 0 14px rgba(255, 255, 255, 0.65);
    z-index: 2;
}

.theme-schatten .ke-tile.is-lit {
    color: #451a03 !important;
}

.theme-falle .ke-tile {
    border-radius: 16px;
    background: linear-gradient(155deg, rgba(68, 64, 60, 0.92) 0%, rgba(41, 37, 36, 0.96) 100%);
    border-color: rgba(251, 146, 60, 0.38);
    color: #fed7aa;
}

.theme-ohren .ke-tile {
    border-radius: 22px;
    background: var(--tile-bg, #1e3a8a);
    border-color: var(--tile-border, #3b82f6);
    color: var(--tile-ink, #dbeafe);
}

.ke-tile.is-trap {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
    border-color: #fecaca !important;
    color: #ffffff !important;
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 0 26px rgba(239, 68, 68, 0.85), 0 6px 0 rgba(0, 0, 0, 0.22);
    z-index: 2;
}

.ke-trap-svg {
    width: 54%;
    height: 54%;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.ke-tile-ear-bar {
    font-size: clamp(1.4rem, 5vw, 2.2rem);
    line-height: 1;
    pointer-events: none;
    opacity: 0.9;
}

.ke-ear-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 66px;
    height: 66px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.88);
    border: 2.5px solid #38bdf8;
    display: grid;
    place-items: center;
    font-size: 1.9rem;
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.5);
    pointer-events: none;
    z-index: 5;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.ke-ear-pulse.is-beat {
    transform: translate(-50%, -50%) scale(1.18);
    box-shadow: 0 0 36px rgba(56, 189, 248, 0.95);
}

.ke-ready-preview {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 14px;
    background: #f1f5f9;
}

.ke-ready-preview-label {
    font-size: 0.78rem;
    font-weight: 800;
    color: #475569;
}

.ke-ready-preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.ke-ear-preview-btn {
    min-height: 44px;
    border-radius: 10px;
    border: 1.5px solid #3b82f6;
    background: #dbeafe;
    color: #1e3a8a;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
}

.ke-ear-preview-btn:active {
    transform: scale(0.95);
    background: #93c5fd;
}

.ke-mute-warn-btn {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1.5px solid #f59e0b;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

/* Tap-Feedback des Spielers */
.ke-tile.is-tap {
    background: var(--tile-glow, #38bdf8) !important;
    border-color: #ffffff !important;
    color: #0f172a !important;
    transform: scale(0.96);
    box-shadow: 0 0 22px var(--tile-glow, #38bdf8);
}

.ke-tile.is-tap-p1 {
    background: #3b82f6 !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
    transform: scale(0.96);
    box-shadow: 0 0 24px #60a5fa;
}

.ke-tile.is-tap-p2 {
    background: #f97316 !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
    transform: scale(0.96);
    box-shadow: 0 0 24px #fb923c;
}

.ke-tile.is-double {
    background: linear-gradient(135deg, #fde047 0%, #f59e0b 100%) !important;
    border-color: #ffffff !important;
    color: #451a03 !important;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 30px #facc15, 0 6px 0 rgba(0, 0, 0, 0.18);
    z-index: 2;
}

.ke-tile.is-hit-1 {
    background: linear-gradient(135deg, #7dd3fc 0%, #0284c7 100%) !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 0 26px #38bdf8, 0 6px 0 rgba(0, 0, 0, 0.18);
    z-index: 2;
}

.ke-tile.is-hit-2 {
    background: linear-gradient(135deg, #fde047 0%, #f59e0b 100%) !important;
    border-color: #ffffff !important;
    color: #451a03 !important;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 28px #facc15, 0 6px 0 rgba(0, 0, 0, 0.18);
    z-index: 2;
}

.ke-tile.is-hit-3 {
    background: linear-gradient(135deg, #f472b6 0%, #be185d 100%) !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 0 32px #ec4899, 0 6px 0 rgba(0, 0, 0, 0.18);
    z-index: 2;
}

.ke-double-badge {
    font-size: clamp(1.35rem, 4.8vw, 2.1rem);
    font-weight: 900;
    pointer-events: none;
}

/* Nebel-Feld: Unsichtbare Kacheln mit dezentem Orientierungs-Punkt */
.theme-nebel .ke-tile {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.theme-nebel .ke-tile::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(226, 232, 240, 0.24);
    transition: opacity 0.12s ease;
}

.theme-nebel .ke-tile.is-lit::after,
.theme-nebel .ke-tile.is-tap::after,
.theme-nebel .ke-tile.is-wrong::after,
.theme-nebel .ke-tile.is-expected::after {
    opacity: 0;
}

.theme-nebel .ke-tile.is-lit,
.theme-nebel .ke-tile.is-tap {
    border-radius: 22px;
}

/* Fehler & Hinweis bei Game Over */
.ke-tile.is-wrong {
    background: #f43f5e !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
    animation: keShake 0.36s ease;
}

.ke-tile.is-expected {
    border: 3.5px solid #22c55e !important;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.35), 0 0 22px #22c55e !important;
    animation: kePulseRing 0.8s ease infinite alternate;
}

.ke-arrow-svg {
    width: 58%;
    height: 58%;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.28));
}

.ke-tile-glyph {
    pointer-events: none;
    font-size: clamp(1.1rem, 3.6vw, 1.55rem);
    line-height: 1;
}

/* Start-Overlay direkt über dem Raster */

.ke-board-overlay {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(5px);
    display: grid;
    place-items: center;
    padding: 18px;
    z-index: 10;
}

.ke-ready-card {
    background: #ffffff;
    color: #1e293b;
    padding: 20px 22px;
    border-radius: 20px;
    text-align: center;
    max-width: 290px;
    width: 100%;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.ke-ready-icon {
    font-size: 2.3rem;
    line-height: 1;
}

.ke-ready-rule {
    font-size: 0.98rem;
    font-weight: 800;
    color: #334155;
}

.ke-start-btn {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #16a34a 0%, #0d9488 100%);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.30);
    transition: transform 0.14s ease;
}

.ke-start-btn:active {
    transform: scale(0.97);
}

/* ---------------- MODALS ---------------- */

.ke-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(6px);
    display: grid;
    place-items: center;
    padding: 16px;
    z-index: 50;
}

.ke-modal-card {
    background: #ffffff;
    color: #1e293b;
    border-radius: 24px;
    width: 100%;
    max-width: 440px;
    max-height: 88dvh;
    overflow-y: auto;
    padding: 22px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.30);
}

.ke-badges-card {
    max-width: 680px;
}

.ke-result-card {
    text-align: center;
}

.ke-result-top {
    font-size: 2.6rem;
    line-height: 1;
}

.ke-result-title {
    margin: 8px 0 4px;
    font-size: 1.45rem;
    font-weight: 900;
}

.ke-result-sub {
    margin: 0 0 16px;
    font-size: 0.95rem;
    color: #475569;
}

.ke-result-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.ke-metric {
    padding: 10px 8px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ke-metric span {
    font-size: 0.74rem;
    font-weight: 800;
    color: #64748b;
}

.ke-metric strong {
    font-size: 1.15rem;
    font-weight: 900;
}

.ke-metric.is-coins {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #78350f;
}

.ke-result-unlocks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    text-align: left;
}

.ke-unlock-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 14px;
    background: #ecfdf5;
    border: 1.5px solid #86efac;
    font-size: 0.88rem;
    font-weight: 800;
    color: #14532d;
}

.ke-unlock-svg {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.ke-result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ke-btn {
    min-height: 48px;
    border-radius: 14px;
    font-size: 0.98rem;
    font-weight: 900;
    cursor: pointer;
    border: 0;
    transition: transform 0.13s ease;
}

.ke-btn:active {
    transform: scale(0.97);
}

.ke-btn-primary {
    background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
    color: #ffffff;
}

.ke-btn-ghost {
    background: #f1f5f9;
    color: #334155;
    border: 1.5px solid #cbd5e1;
}

/* Abzeichen Modal */

.ke-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ke-modal-head h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 900;
}

.ke-close-btn {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    font-size: 1.1rem;
    font-weight: 900;
    cursor: pointer;
}

.ke-badges-intro {
    margin: 8px 0 14px;
    font-size: 0.9rem;
    color: #475569;
}

.ke-badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}

.ke-badge-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
}

.ke-badge-card.is-owned {
    background: #fffbeb;
    border-color: #fbbf24;
}

.ke-badge-card.is-locked {
    opacity: 0.72;
}

.ke-badge-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ke-badge-art {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
}

.ke-badge-card.is-locked .ke-badge-art {
    filter: grayscale(0.85);
}

.ke-badge-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 900;
}

.ke-badge-rarity {
    font-size: 0.72rem;
    font-weight: 800;
    color: #d97706;
}

.ke-badge-desc {
    margin: 0;
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.35;
}

.ke-badge-status {
    margin-top: auto;
    font-size: 0.76rem;
    font-weight: 800;
    color: #64748b;
}

.ke-badge-card.is-owned .ke-badge-status {
    color: #15803d;
}

/* Sound-Studio & Sound-Designer */

.ke-sound-card {
    max-width: 700px;
}

.ke-sound-subtitle {
    margin-top: 3px;
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 600;
}

.ke-sound-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 14px 0 12px;
    padding: 4px;
    background: #f1f5f9;
    border-radius: 14px;
}

.ke-tab-btn {
    min-height: 44px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: #475569;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ke-tab-btn.is-active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.ke-sound-feedback {
    margin-bottom: 12px;
    padding: 9px 13px;
    border-radius: 12px;
    background: #dcfce7;
    color: #14532d;
    border: 1.5px solid #86efac;
    font-size: 0.86rem;
    font-weight: 800;
}

.ke-sound-feedback.is-error {
    background: #ffe4e6;
    color: #9f1239;
    border-color: #fda4af;
}

.ke-sound-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.ke-sound-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
}

.ke-sound-item.is-active {
    background: #eff6ff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.ke-sound-item-head {
    display: flex;
    align-items: center;
    gap: 9px;
}

.ke-sound-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.ke-sound-name {
    margin: 0;
    font-size: 0.94rem;
    font-weight: 900;
}

.ke-sound-desc {
    margin: 0;
    font-size: 0.79rem;
    color: #475569;
    line-height: 1.35;
}

.ke-sound-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
}

.ke-mini-btn {
    min-height: 40px;
    padding: 0 11px;
    border-radius: 11px;
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
    color: #1e293b;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.ke-mini-btn.is-grow {
    flex: 1;
}

.ke-mini-btn.is-primary {
    border: 0;
    background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
    color: #ffffff;
}

.ke-mini-btn.is-buy {
    border: 0;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
}

.ke-mini-btn.is-selected {
    border-color: #16a34a;
    background: #dcfce7;
    color: #14532d;
}

.ke-mini-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.ke-designer-lock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1.5px solid #f59e0b;
    color: #78350f;
}

.ke-designer-lock p {
    margin: 3px 0 0;
    font-size: 0.8rem;
    font-weight: 600;
}

.ke-buy-designer-btn {
    padding: 0 16px;
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

.ke-designer-slots {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.ke-slot-btn {
    flex: 1;
    min-width: 100px;
    min-height: 42px;
    padding: 0 10px;
    border-radius: 12px;
    border: 1.5px solid #cbd5e1;
    background: #f8fafc;
    font-size: 0.84rem;
    font-weight: 800;
    color: #334155;
    cursor: pointer;
}

.ke-slot-btn.is-active {
    background: #eef2ff;
    border-color: #4f46e5;
    color: #312e81;
}

.ke-designer-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.ke-designer-name-row label {
    font-size: 0.86rem;
    font-weight: 800;
    color: #334155;
    white-space: nowrap;
}

.ke-text-input {
    flex: 1;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1.5px solid #cbd5e1;
    font-size: 0.92rem;
    font-weight: 700;
    color: #0f172a;
}

.ke-designer-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.ke-control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ke-control-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: #475569;
}

.ke-pill-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ke-opt-pill {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1.5px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.ke-opt-pill.is-active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #ffffff;
}

.ke-designer-test-wrap {
    margin-bottom: 14px;
    padding: 12px;
    border-radius: 16px;
    background: #0f172a;
    color: #f8fafc;
}

.ke-designer-test-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.ke-designer-test-pad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.ke-test-tile {
    min-height: 52px;
    border-radius: 12px;
    border: 2px solid #38bdf8;
    background: #1e293b;
    color: #e0f2fe;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.12s ease;
}

.ke-test-tile:active,
.ke-test-tile.is-lit {
    transform: scale(0.95);
    background: #38bdf8;
    color: #0f172a;
}

.ke-save-sound-btn {
    width: 100%;
}

/* Live Toast */

.ke-toast {
    position: fixed;
    left: 50%;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    background: #0f172a;
    color: #fef08a;
    border: 2px solid #facc15;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 900;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    z-index: 60;
    white-space: nowrap;
}

@keyframes keShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
}

@keyframes kePulseRing {
    from { transform: scale(1); }
    to { transform: scale(1.04); }
}

@media (max-width: 520px) {
    .ke-hide-xs {
        display: none;
    }

    .ke-board-frame {
        padding: 10px;
        border-radius: 20px;
        max-width: min(94vw, 54dvh);
    }

    .ke-board {
        gap: 8px;
    }

    .ke-tile {
        border-radius: 14px;
    }

    .ke-result-metrics {
        gap: 6px;
    }
}
