@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700&family=DM+Mono:wght@400;500&display=swap');

:root {
    --bg:          #0b0907;
    --surface:     #161210;
    --surface-2:   #1e1a15;
    --surface-3:   #28231c;
    --surface-4:   #322b22;
    --gold:        #d49020;
    --gold-bright: #f0b030;
    --gold-glow:   rgba(240,176,48,0.22);
    --border:      rgba(210,150,50,0.22);
    --border-dim:  rgba(210,150,50,0.09);
    --text:        #ede0cc;
    --text-dim:    #7a6b58;
    --text-muted:  #40352a;
    --board-bg:    #28211a;
    --cell-bg:     #1d1710;
    --radius:      10px;
    --radius-sm:   6px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 5% -5%,  rgba(190,100,15,0.16) 0%, transparent 55%),
        radial-gradient(ellipse 60% 60% at 95% 105%, rgba(110,55,5,0.12)  0%, transparent 55%),
        var(--bg);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 12px;
    font-family: 'DM Sans', system-ui, sans-serif;
    -webkit-tap-highlight-color: transparent;
    color: var(--text);
}

/* Grain texture overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    pointer-events: none;
    z-index: 200;
}

/* ── Game Container ─────────────── */
#game-container {
    width: min(450px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 18px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    animation: container-in 350ms cubic-bezier(0.22,1,0.36,1) both;
    box-shadow:
        0 0 0 1px var(--border-dim),
        0 2px 0  rgba(255,165,50,0.06) inset,
        0 40px 100px rgba(0,0,0,0.75),
        0  8px  24px rgba(0,0,0,0.50);
}

@keyframes container-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Header ─────────────────────── */
#game-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(34px, 9vw, 46px);
    letter-spacing: 0.05em;
    line-height: 1;
    margin-bottom: 4px;
    color: var(--gold-bright);
    text-shadow: 0 0 40px rgba(240,176,48,0.30);
}

#game-title span {
    color: var(--text-dim);
    font-size: 1em;
}

.sub-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 22px;
    opacity: 0.85;
}

/* ── Scores ─────────────────────── */
#score-container {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-bottom: 12px;
}

.score-box {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    padding: 10px 14px 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.score-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-glow), transparent);
}

.score-box span {
    display: block;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.score-box div {
    font-family: 'DM Mono', monospace;
    font-size: 24px;
    font-weight: 500;
    color: var(--gold-bright);
    line-height: 1;
}

/* ── Buttons ────────────────────── */
#button-row {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-bottom: 12px;
}

.btn {
    flex: 1;
    height: 44px;
    padding: 0 14px;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    transition: background 100ms, border-color 100ms, color 100ms;
}

.btn:active {
    background: rgba(210,150,30,0.20);
    border-color: rgba(210,150,30,0.50);
}

.btn-undo {
    color: var(--gold);
    border-color: rgba(210,150,30,0.20);
}

@media (hover: hover) {
    .btn:hover {
        background: var(--surface-4);
        border-color: rgba(255,255,255,0.10);
    }

    .btn-undo:hover {
        border-color: rgba(210,150,30,0.40);
    }
}

#player-row {
    width: 100%;
    margin-bottom: 12px;
}

#player-name {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    outline: none;
    transition: border-color 150ms;
}

#player-name::placeholder {
    color: var(--text-muted);
}

#player-name:focus {
    border-color: var(--border);
}

/* ── Autopilot ──────────────────── */
#autopilot-controls {
    width: 100%;
    margin-bottom: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.autopilot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-dim);
    user-select: none;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider {
    position: absolute;
    inset: 0;
    background: var(--surface-4);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.knob {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 14px;
    height: 14px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s;
    box-shadow: 0 1px 5px rgba(0,0,0,0.6);
    pointer-events: none;
}

.autopilot-status {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.speed-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-label-text {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-dim);
    white-space: nowrap;
}

#speed-slider {
    flex: 1;
    accent-color: var(--gold);
    cursor: pointer;
}

.speed-value {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--text-dim);
    min-width: 42px;
    text-align: right;
}

/* ── Game Board ─────────────────── */
#game-board {
    width: 100%;
    max-width: 415px;
    aspect-ratio: 1 / 1;
    /* Empty cell wells rendered as SVG background, scales with board */
    background-color: var(--board-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 415 415'%3E%3Crect x='15'  y='15'  width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='115' y='15'  width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='215' y='15'  width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='315' y='15'  width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='15'  y='115' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='115' y='115' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='215' y='115' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='315' y='115' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='15'  y='215' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='115' y='215' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='215' y='215' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='315' y='215' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='15'  y='315' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='115' y='315' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='215' y='315' width='85' height='85' rx='6' fill='%231d1710'/%3E%3Crect x='315' y='315' width='85' height='85' rx='6' fill='%231d1710'/%3E%3C/svg%3E");
    background-size: 100% 100%;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,0.55);
    position: relative;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow:
        inset 0  3px 12px rgba(0,0,0,0.65),
        inset 0 -1px  4px rgba(255,140,20,0.04),
              0  6px 20px rgba(0,0,0,0.45);
}

/* Subtle top-edge highlight on the board */
#game-board::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 10%, rgba(255,160,40,0.08) 50%, transparent 90%);
    pointer-events: none;
    z-index: 1;
}

/* ── Tile animations ────────────── */
@keyframes tile-spawn {
    0%   { transform: scale(0);    opacity: 0; }
    65%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); }
}
/* ── Tiles ──────────────────────── */
.tile {
    position: absolute;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    will-change: transform;
}

.tile-new { animation: tile-spawn 140ms cubic-bezier(0.34,1.56,0.64,1) both; }

/* Cream tier */
.tile-2    { background: #f0e6d5; color: #4a3820; box-shadow: 0 2px 8px rgba(0,0,0,0.30); }
.tile-4    { background: #e8d4a8; color: #4a3820; box-shadow: 0 2px 8px rgba(0,0,0,0.30); }

/* Ember tier */
.tile-8    { background: #e8955a; color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.35); }
.tile-16   { background: #e07840; color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.35); }
.tile-32   { background: #d95f30; color: #fff; box-shadow: 0 2px 12px rgba(217,95,48,0.40); }
.tile-64   { background: #cc3e18; color: #fff; box-shadow: 0 2px 14px rgba(204,62,24,0.45); }

/* Gold tier — the prize tiles */
.tile-128  {
    background: linear-gradient(135deg, #c89010, #b07808);
    color: #fff;
    box-shadow: 0 3px 16px rgba(200,144,16,0.50), 0 0 0 1px rgba(255,200,60,0.15);
}
.tile-256  {
    background: linear-gradient(135deg, #d4a018, #bc8a10);
    color: #fff;
    box-shadow: 0 3px 18px rgba(212,160,24,0.55), 0 0 0 1px rgba(255,210,70,0.18);
}
.tile-512  {
    background: linear-gradient(135deg, #dcb020, #c49818);
    color: #fff;
    box-shadow: 0 3px 22px rgba(220,176,32,0.60), 0 0 0 1px rgba(255,218,80,0.20);
}
.tile-1024 {
    background: linear-gradient(135deg, #e8c028, #d0a820);
    color: #fff;
    box-shadow: 0 4px 28px rgba(232,192,40,0.65), 0 0 0 1px rgba(255,228,90,0.25);
}
.tile-2048 {
    background: linear-gradient(135deg, #f5cc30, #e0b020);
    color: #2a1800;
    box-shadow: 0 4px 36px rgba(245,204,48,0.80), 0 0 0 1px rgba(255,238,100,0.35), 0 0 60px rgba(245,204,48,0.25);
}

/* Beyond — vivid spectrum */
.tile-4096   { background: #14b0a8; color: #fff; box-shadow: 0 3px 20px rgba(20,176,168,0.55); }
.tile-8192   { background: #8820cc; color: #fff; box-shadow: 0 3px 22px rgba(136,32,204,0.55); }
.tile-16384  { background: #de1848; color: #fff; box-shadow: 0 3px 22px rgba(222,24,72,0.55); }
.tile-32768  { background: #f06010; color: #fff; box-shadow: 0 3px 22px rgba(240,96,16,0.55); }
.tile-65536  { background: #1058bc; color: #fff; box-shadow: 0 3px 22px rgba(16,88,188,0.55); }
.tile-131072 { background: #166828; color: #fff; box-shadow: 0 3px 22px rgba(22,104,40,0.55); }

/* ── Game Over overlay ──────────── */
#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(300px, 88%);
    background: rgba(12,9,6,0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 34px 24px;
    z-index: 10;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 0 0 1px var(--border-dim),
        0 30px 70px rgba(0,0,0,0.85);
}

#game-over div {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 52px;
    letter-spacing: 0.06em;
    color: var(--gold-bright);
    margin-bottom: 24px;
    line-height: 1;
    text-shadow: 0 0 30px rgba(240,176,48,0.4);
}

#game-over button {
    height: 46px;
    padding: 0 28px;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 100ms, border-color 100ms;
    min-height: 44px;
}

#game-over button:active {
    background: rgba(210,150,30,0.22);
    border-color: var(--gold);
}

/* ════════════════════════════════════════════════════════════
   DATUMS-PUZZLE  —  Ergänzungen
   ════════════════════════════════════════════════════════════ */

#game-container { width: min(480px, 100%); }

/* ── Datumsanzeige ──────────────── */
#date-display {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-bottom: 14px;
}
.date-part {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    padding: 9px 8px 11px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.date-part::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-glow), transparent);
}
.date-part span {
    display: block;
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 5px;
}
.date-part strong {
    font-family: 'DM Mono', monospace;
    font-size: 22px;
    font-weight: 500;
    color: var(--gold-bright);
    line-height: 1;
}

/* ── Board: 7x7 ─────────────────── */
#game-board {
    background-image: none;            /* 4x4-SVG aus Basis-CSS entfernen */
    max-width: 460px;
    --cell: 60px;                      /* von JS gesetzt */
    --gap: 5px;
}
.board-labels {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    pointer-events: none;
    z-index: 1;
}
.cell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'DM Mono', monospace;
    font-size: clamp(9px, 2.2vw, 13px);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text);
}
.cell::before {
    content: '';
    position: absolute;
    inset: var(--gap);
    background: var(--cell-bg);
    border-radius: 6px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.55);
}
.cell span { position: relative; z-index: 1; }

/* Bereiche farblich abheben (Wells + Schrift) */
.cell-month { color: #f1d49a; }
.cell-month::before {
    background: #322415;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(224,170,70,0.16);
}
.cell-day { color: #d9cdb6; }
.cell-day::before {
    background: #221b13;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(200,180,150,0.07);
}
.cell-year { color: #f1d49a; }
.cell-year::before {
    background: #322415;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(224,170,70,0.16);
}

.cell.is-target {
    color: var(--gold-bright);
}
.cell.is-target::before {
    background: rgba(240,176,48,0.14);
    box-shadow: inset 0 0 0 1px rgba(240,176,48,0.55);
}

/* ── Drop-Vorschau ──────────────── */
#piece-layer { position: absolute; inset: 0; z-index: 2; }
.drop-hint {
    position: absolute;
    inset: var(--gap);
    border-radius: 6px;
    z-index: 3;
    pointer-events: none;
}
.drop-hint.ok  { background: rgba(120,220,120,0.30); box-shadow: inset 0 0 0 1px rgba(150,255,150,0.6); }
.drop-hint.bad { background: rgba(220,80,60,0.25);  box-shadow: inset 0 0 0 1px rgba(255,120,100,0.6); }

/* ── Spielsteine ────────────────── */
.piece {
    position: absolute;
    top: 0; left: 0;
    touch-action: none;
    cursor: grab;
    z-index: 4;
}
.piece.dragging {
    position: fixed;
    cursor: grabbing;
    z-index: 999;
    pointer-events: none;
    filter: drop-shadow(0 12px 22px rgba(0,0,0,0.55));
}
.pcell {
    position: absolute;
    border-radius: 6px;
}
.pcell::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(0,0,0,0.16));
    mix-blend-mode: overlay;
}

/* ── Tray ───────────────────────── */
.tray-title {
    width: 100%;
    margin: 18px 0 8px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-dim);
}
#tray {
    width: 100%;
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: flex-start;
    gap: 12px 14px;
    padding: 14px 12px;
    background: var(--surface-2);
    border: 1px dashed var(--border-dim);
    border-radius: var(--radius-sm);
}
#tray.drag-over { border-color: var(--gold); }
/* Slots haben feste, von JS gesetzte Maße und bleiben immer erhalten,
   damit sich das Tray-Layout beim Herausnehmen nicht verändert. */
.tray-slot {
    position: relative;
    flex: 0 0 auto;
}

/* ── Hinweis ────────────────────── */
.hint {
    width: 100%;
    margin-top: 16px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    line-height: 1.8;
    letter-spacing: 0.04em;
    color: #b6a187;
    text-align: center;
}

/* ── Win-Overlay ────────────────── */
#win-overlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 22px;
    background: rgba(12,9,6,0.90);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 20;
}
#win-overlay.show { display: flex; animation: container-in 300ms both; }
#win-overlay div {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 64px;
    letter-spacing: 0.06em;
    color: var(--gold-bright);
    text-shadow: 0 0 36px rgba(240,176,48,0.45);
}
#win-overlay button {
    height: 46px;
    padding: 0 30px;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
}
#win-overlay button:hover { background: var(--surface-4); }

/* ── Boss-Key-Screen ────────────── */
#boss-screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    background: #f3f3f3;
    color: #222;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}
#boss-screen.show { display: flex; }
.boss-bar {
    background: #217346;
    color: #fff;
    padding: 8px 14px;
    font-size: 13px;
}
.boss-sheet {
    flex: 1;
    overflow: auto;
    display: grid;
    grid-template-columns: 44px repeat(8, minmax(90px, 1fr));
    grid-auto-rows: 24px;
    font-size: 12px;
}
.boss-sheet .bc {
    border-right: 1px solid #d4d4d4;
    border-bottom: 1px solid #d4d4d4;
    padding: 3px 6px;
    background: #fff;
    white-space: nowrap;
    overflow: hidden;
}
.boss-sheet .bh {
    background: #f0f0f0;
    color: #555;
    text-align: center;
    font-weight: 600;
}

/* ── Win-Buttons (Teilen + Nochmal) ─ */
.win-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
#win-share {
    color: var(--gold);
    border-color: rgba(210,150,30,0.45);
}
#win-share:hover { background: rgba(210,150,30,0.18); }

/* ── Footer-Links (Spielregeln · Impressum) ─ */
.footer-links {
    width: 100%;
    margin-top: 18px;
    text-align: center;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.footer-links a {
    color: var(--gold);
    text-decoration: none;
    transition: color 120ms;
}
.footer-links a:hover { color: var(--gold-bright); text-decoration: underline; }
.footer-links .sep { color: var(--text-muted); margin: 0 10px; }

/* ── Spielregeln-Modal ──────────── */
#rules-modal {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: rgba(8,6,4,0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 500;
}
#rules-modal.show { display: flex; animation: container-in 250ms both; }
.rules-card {
    position: relative;
    width: min(440px, 100%);
    max-height: 86vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 26px 30px;
    box-shadow: 0 30px 70px rgba(0,0,0,0.8), 0 0 0 1px var(--border-dim);
}
.rules-card h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 34px;
    letter-spacing: 0.05em;
    color: var(--gold-bright);
    margin-bottom: 16px;
}
.rules-card h3 {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 20px 0 10px;
}
.rules-card p {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
    margin-bottom: 12px;
}
.rules-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rules-card li {
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text);
    padding-left: 16px;
    position: relative;
}
.rules-card li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--gold);
}
.rules-card strong { color: var(--gold-bright); font-weight: 700; }
.rules-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 34px;
    height: 34px;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 120ms, border-color 120ms;
}
.rules-close:hover { background: var(--surface-4); border-color: var(--border); }

/* ── Schwierigkeits-Umschalter (Einfach / Schwer) ─ */
#difficulty-row {
    display: flex;
    width: 100%;
    gap: 6px;
    margin-bottom: 10px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
}
.diff-btn {
    flex: 1;
    height: 36px;
    background: transparent;
    color: var(--text-dim);
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 120ms, color 120ms;
}
.diff-btn:hover { color: var(--text); }
.diff-btn.active {
    background: var(--surface-4);
    color: var(--gold-bright);
    box-shadow: inset 0 0 0 1px rgba(210,150,30,0.35);
}

/* ── Teilen-Menü ────────────────── */
#share-menu {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: rgba(8,6,4,0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 600;
}
#share-menu.show { display: flex; animation: container-in 220ms both; }
.share-card { width: min(380px, 100%); }
.share-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
}
.share-act {
    height: 48px;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background 120ms, border-color 120ms;
}
.share-act:hover { background: var(--surface-4); border-color: var(--border); }
#sa-whatsapp { color: #25d366; border-color: rgba(37,211,102,0.35); }
#sa-whatsapp:hover { background: rgba(37,211,102,0.12); }
.share-hint {
    margin-top: 14px;
    min-height: 16px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    line-height: 1.5;
    color: var(--gold);
    text-align: center;
}

/* ── Touch-Steuerung (Drehen / Spiegeln) ─ */
#touch-controls {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: none;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    z-index: 800;
    pointer-events: none;   /* nur die Buttons sind aktiv */
}
#touch-controls.show { display: flex; }
#touch-controls button {
    pointer-events: auto;
    flex: 1;
    max-width: 220px;
    height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: rgba(40,35,28,0.96);
    color: var(--gold-bright);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.55);
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
}
#touch-controls button:active { background: rgba(210,150,30,0.30); }
#touch-controls button span {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text);
}
