/* ═══════════════════════════════════════
   GLOBALE VARIABLEN & RESET
   ═══════════════════════════════════════ */
:root {
    /* Taschenrechner-Farben */
    --calc-bg: #1a1a2e;
    --calc-body: #16213e;
    --calc-display-bg: #0d1117;
    --calc-display-text: #00ff9d;
    --calc-btn-num: #1e2d4a;
    --calc-btn-op: #16407a;
    --calc-btn-func: #0d2137;
    --calc-btn-equals: #0066cc;
    --calc-btn-clear: #8b0000;
    --calc-shadow: rgba(0,0,0,0.6);

    /* Gaming-Plattform-Farben */
    --p-bg: #050510;
    --p-bg2: #0a0a1a;
    --p-primary: #00f5ff;
    --p-secondary: #ff006e;
    --p-accent: #7b2fff;
    --p-gold: #ffd700;
    --p-text: #e0e0ff;
    --p-text-dim: #8080aa;
    --p-card-bg: rgba(10,10,30,0.8);
    --p-card-border: rgba(0,245,255,0.2);
    --p-glow-cyan: 0 0 20px rgba(0,245,255,0.5);
    --p-glow-pink: 0 0 20px rgba(255,0,110,0.5);
    --p-glow-purple: 0 0 20px rgba(123,47,255,0.5);

    --font-mono: 'Share Tech Mono', monospace;
    --font-display: 'Orbitron', sans-serif;
    --font-ui: 'Rajdhani', sans-serif;
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    background: #0d0d0d;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════
   TASCHENRECHNER
   ═══════════════════════════════════════ */
#calculator-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #0d0d1a 100%);
    padding: 20px;
}

.calc-container {
    background: linear-gradient(160deg, #1e2d4a 0%, #0d1b2e 100%);
    border-radius: 20px;
    padding: 24px 20px 20px;
    width: 100%;
    max-width: 340px;
    box-shadow:
        0 30px 80px rgba(0,0,0,0.8),
        0 0 0 1px rgba(255,255,255,0.05),
        inset 0 1px 0 rgba(255,255,255,0.08);
    position: relative;
}

.calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

.calc-brand {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: bold;
    color: #c0c8d8;
    letter-spacing: 3px;
}

.calc-model {
    font-family: var(--font-mono);
    font-size: 11px;
    color: #6070a0;
    letter-spacing: 1px;
}

.calc-display-wrapper {
    background: #0d1117;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(0,255,157,0.15);
    box-shadow: inset 0 4px 20px rgba(0,0,0,0.6), 0 0 10px rgba(0,255,157,0.05);
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.calc-expression {
    font-family: var(--font-mono);
    font-size: 13px;
    color: rgba(0,255,157,0.45);
    text-align: right;
    min-height: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calc-result {
    font-family: var(--font-mono);
    font-size: 34px;
    color: var(--calc-display-text);
    text-align: right;
    text-shadow: 0 0 10px rgba(0,255,157,0.5);
    transition: font-size 0.1s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.btn {
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 15px;
    padding: 14px 0;
    transition: all 0.1s ease;
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.1s;
    border-radius: 10px;
}

.btn:active::after { background: rgba(255,255,255,0.15); }

.btn-num {
    background: linear-gradient(180deg, #243048 0%, #1a2538 100%);
    color: #d0ddf0;
    box-shadow: 0 4px 0 #0d1520, 0 0 0 1px rgba(255,255,255,0.04);
}

.btn-num:hover { background: linear-gradient(180deg, #2d3a5a 0%, #223044 100%); }
.btn-num:active { transform: translateY(2px); box-shadow: 0 2px 0 #0d1520; }

.btn-op {
    background: linear-gradient(180deg, #1a4a8a 0%, #103070 100%);
    color: #80c0ff;
    box-shadow: 0 4px 0 #0a1f50, 0 0 0 1px rgba(128,192,255,0.1);
}

.btn-op:hover { background: linear-gradient(180deg, #1f5aa0 0%, #133880 100%); }
.btn-op:active { transform: translateY(2px); box-shadow: 0 2px 0 #0a1f50; }

.btn-func {
    background: linear-gradient(180deg, #112233 0%, #0a1826 100%);
    color: #6090b0;
    font-size: 12px;
    box-shadow: 0 4px 0 #060e18, 0 0 0 1px rgba(255,255,255,0.03);
}

.btn-func:hover { color: #80b8d8; background: linear-gradient(180deg, #162a40 0%, #0e2030 100%); }
.btn-func:active { transform: translateY(2px); box-shadow: 0 2px 0 #060e18; }

.btn-clear {
    background: linear-gradient(180deg, #6b0000 0%, #4a0000 100%);
    color: #ff8080;
    box-shadow: 0 4px 0 #2a0000, 0 0 0 1px rgba(255,0,0,0.1);
}

.btn-clear:hover { background: linear-gradient(180deg, #800000 0%, #600000 100%); }
.btn-clear:active { transform: translateY(2px); box-shadow: 0 2px 0 #2a0000; }

.btn-equals {
    background: linear-gradient(180deg, #0077ee 0%, #0055cc 100%);
    color: #ffffff;
    font-size: 20px;
    box-shadow: 0 4px 0 #002880, 0 0 12px rgba(0,100,255,0.3);
}

.btn-equals:hover { background: linear-gradient(180deg, #0088ff 0%, #0066dd 100%); }
.btn-equals:active { transform: translateY(2px); box-shadow: 0 2px 0 #002880; }

.btn-zero { grid-column: span 2; }

.calc-footer {
    text-align: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.calc-model-tag {
    font-family: var(--font-mono);
    font-size: 9px;
    color: #3a4a6a;
    letter-spacing: 3px;
}

/* ═══════════════════════════════════════
   SPIELEPLATTFORM – GRUNDLAYOUT
   ═══════════════════════════════════════ */
#platform-view {
    position: relative;
    min-height: 100vh;
    background: var(--p-bg);
    color: var(--p-text);
    font-family: var(--font-ui);
    overflow-x: hidden;
}

#particles-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ═══════════════════════════════════════
   EMERGENCY BUTTON
   ═══════════════════════════════════════ */
#emergency-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    background: rgba(200,0,0,0.85);
    border: 2px solid #ff4444;
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 0 20px rgba(255,0,0,0.5);
    transition: all 0.2s;
    animation: emergency-pulse 2s infinite;
}

#emergency-btn:hover {
    background: rgba(255,0,0,0.95);
    box-shadow: 0 0 30px rgba(255,0,0,0.8);
    transform: scale(1.05);
}

@keyframes emergency-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255,0,0,0.4); }
    50% { box-shadow: 0 0 25px rgba(255,0,0,0.8); }
}

/* ═══════════════════════════════════════
   PLATTFORM HEADER
   ═══════════════════════════════════════ */
.platform-header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
    background: rgba(5,5,20,0.9);
    border-bottom: 1px solid rgba(0,245,255,0.15);
    backdrop-filter: blur(10px);
    flex-wrap: wrap;
    gap: 12px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 900;
}

.logo-icon {
    color: var(--p-primary);
    font-size: 28px;
    animation: logo-spin 8s linear infinite;
    display: inline-block;
}

@keyframes logo-spin {
    0% { transform: rotate(0deg); filter: drop-shadow(0 0 8px var(--p-primary)); }
    50% { filter: drop-shadow(0 0 16px var(--p-secondary)); }
    100% { transform: rotate(360deg); filter: drop-shadow(0 0 8px var(--p-primary)); }
}

.logo-text { color: var(--p-text); letter-spacing: 2px; }
.logo-accent { color: var(--p-primary); }

.header-nav { display: flex; gap: 8px; flex-wrap: wrap; }

.nav-btn {
    background: transparent;
    border: 1px solid rgba(0,245,255,0.25);
    color: var(--p-text-dim);
    padding: 8px 18px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 2px;
    transition: all 0.2s;
}

.nav-btn:hover, .nav-btn.active {
    border-color: var(--p-primary);
    color: var(--p-primary);
    background: rgba(0,245,255,0.08);
    box-shadow: var(--p-glow-cyan);
}

/* ═══════════════════════════════════════
   SEKTIONEN
   ═══════════════════════════════════════ */
.platform-section {
    display: none;
    position: relative;
    z-index: 5;
    padding: 40px;
    max-width: 1300px;
    margin: 0 auto;
    animation: section-in 0.3s ease;
}

.platform-section.active { display: block; }

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

.section-title {
    text-align: center;
    margin-bottom: 40px;
}

.section-title h2 {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 900;
    color: var(--p-primary);
    text-shadow: var(--p-glow-cyan);
    letter-spacing: 4px;
    margin-bottom: 8px;
}

.section-title p {
    color: var(--p-text-dim);
    font-size: 16px;
    letter-spacing: 1px;
}

/* ═══════════════════════════════════════
   SPIELE-GRID
   ═══════════════════════════════════════ */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}

.game-card {
    position: relative;
    background: var(--p-card-bg);
    border: 1px solid var(--p-card-border);
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--p-primary), var(--p-accent), var(--p-secondary));
    opacity: 0;
    transition: opacity 0.3s;
}

.game-card:hover {
    transform: translateY(-6px);
    border-color: rgba(0,245,255,0.5);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), var(--p-glow-cyan);
}

.game-card:hover::before { opacity: 1; }

.game-card-glow {
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(0,245,255,0.04) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.game-card:hover .game-card-glow { opacity: 1; }

.game-icon {
    font-size: 48px;
    margin-bottom: 14px;
    display: block;
    filter: drop-shadow(0 0 10px rgba(0,245,255,0.3));
    transition: transform 0.3s;
}

.game-card:hover .game-icon { transform: scale(1.15); }

.game-card h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--p-text);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.game-card p {
    color: var(--p-text-dim);
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.4;
}

.game-tag {
    display: inline-block;
    background: rgba(0,245,255,0.1);
    border: 1px solid rgba(0,245,255,0.2);
    color: var(--p-primary);
    font-size: 10px;
    font-family: var(--font-display);
    letter-spacing: 2px;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.play-btn {
    width: 100%;
    padding: 11px;
    background: transparent;
    border: 2px solid var(--p-primary);
    color: var(--p-primary);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 3px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.play-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--p-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s;
    z-index: -1;
}

.play-btn:hover {
    color: #000;
    box-shadow: var(--p-glow-cyan);
}

.play-btn:hover::before { transform: scaleX(1); }

/* ═══════════════════════════════════════
   MULTIPLAYER
   ═══════════════════════════════════════ */
.multiplayer-container {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
}

.mp-card {
    background: var(--p-card-bg);
    border: 1px solid var(--p-card-border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mp-card h3 {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--p-primary);
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 8px;
}

.mp-card input, .mp-card select {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(0,245,255,0.2);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--p-text);
    font-family: var(--font-ui);
    font-size: 15px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

.mp-card input:focus, .mp-card select:focus {
    border-color: var(--p-primary);
    box-shadow: 0 0 8px rgba(0,245,255,0.2);
}

.mp-card select option { background: #0a0a1a; }

.mp-btn {
    padding: 13px;
    background: linear-gradient(135deg, var(--p-accent), var(--p-primary));
    border: none;
    border-radius: 8px;
    color: #000;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.25s;
}

.mp-btn:hover {
    opacity: 0.9;
    box-shadow: 0 0 20px rgba(0,245,255,0.4);
    transform: translateY(-2px);
}

.mp-divider {
    display: flex;
    align-items: center;
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--p-text-dim);
    letter-spacing: 3px;
    padding: 20px 0;
}

.lobby-info {
    background: rgba(0,245,255,0.08);
    border: 1px solid rgba(0,245,255,0.3);
    border-radius: 8px;
    padding: 14px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--p-primary);
    text-align: center;
    line-height: 1.6;
}

/* ═══════════════════════════════════════
   HIGHSCORES
   ═══════════════════════════════════════ */
.scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.score-card {
    background: var(--p-card-bg);
    border: 1px solid var(--p-card-border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.score-card-icon { font-size: 32px; margin-bottom: 8px; }
.score-card-name {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--p-text);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.score-card-value {
    font-family: var(--font-mono);
    font-size: 28px;
    color: var(--p-gold);
    text-shadow: 0 0 10px rgba(255,215,0,0.5);
}

/* ═══════════════════════════════════════
   SPIELFENSTER OVERLAY
   ═══════════════════════════════════════ */
.game-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlay-in 0.2s ease;
    padding: 16px;
    backdrop-filter: blur(6px);
}

@keyframes overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.game-window {
    background: #05050f;
    border: 1px solid rgba(0,245,255,0.3);
    border-radius: 16px;
    overflow: hidden;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 60px rgba(0,245,255,0.15), 0 40px 80px rgba(0,0,0,0.8);
    animation: window-in 0.25s cubic-bezier(.34,1.56,.64,1);
}

@keyframes window-in {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.game-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(0,245,255,0.06);
    border-bottom: 1px solid rgba(0,245,255,0.15);
    font-family: var(--font-display);
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--p-primary);
    flex-shrink: 0;
}

.game-close-btn {
    background: rgba(255,0,0,0.2);
    border: 1px solid rgba(255,0,0,0.4);
    color: #ff6060;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.game-close-btn:hover {
    background: rgba(255,0,0,0.4);
    color: #fff;
}

.game-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.game-content canvas {
    display: block;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(0,245,255,0.2);
}

/* ═══════════════════════════════════════
   SPIEL-UI ELEMENTE
   ═══════════════════════════════════════ */
.game-info-bar {
    display: flex;
    gap: 20px;
    font-family: var(--font-mono);
    color: var(--p-primary);
    font-size: 15px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.game-btn {
    padding: 10px 24px;
    background: transparent;
    border: 2px solid var(--p-primary);
    color: var(--p-primary);
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 2px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-btn:hover {
    background: var(--p-primary);
    color: #000;
}

/* Memory-Karten */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 480px;
}

.memory-card {
    aspect-ratio: 1;
    cursor: pointer;
    perspective: 600px;
}

.memory-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-front,
.memory-card-back {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 28px;
    backface-visibility: hidden;
}

.memory-card-front {
    background: linear-gradient(135deg, var(--p-accent), #3d1a8a);
    border: 2px solid rgba(123,47,255,0.5);
    color: rgba(255,255,255,0.2);
    font-size: 16px;
    font-family: var(--font-display);
}

.memory-card-back {
    background: linear-gradient(135deg, #0a0a2a, #15153a);
    border: 2px solid rgba(0,245,255,0.4);
    transform: rotateY(180deg);
}

.memory-card.matched .memory-card-back {
    border-color: var(--p-gold);
    background: linear-gradient(135deg, #1a1500, #2a2200);
}

/* Tic Tac Toe */
.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 300px;
}

.ttt-cell {
    aspect-ratio: 1;
    background: rgba(0,245,255,0.06);
    border: 2px solid rgba(0,245,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-display);
}

.ttt-cell:hover:empty { background: rgba(0,245,255,0.12); }
.ttt-cell.x { color: var(--p-primary); }
.ttt-cell.o { color: var(--p-secondary); }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
    .platform-header { padding: 16px 20px; }
    .platform-section { padding: 24px 16px; }
    .games-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
    .game-card { padding: 20px 14px; }
    .game-icon { font-size: 36px; }
    .section-title h2 { font-size: 22px; }
    .mp-divider { padding: 10px 0; }
    .multiplayer-container { flex-direction: column; align-items: center; }
}

@media (max-width: 400px) {
    .calc-result { font-size: 26px; }
    .btn { font-size: 13px; padding: 12px 0; }
}