/* ============================================================
   Catppuccin Mocha — Mia's Birthday Experience
   ============================================================ */

/* === CSS-Variablen === */
:root {
    --rosewater:  #f5e0dc;
    --flamingo:   #f2cdcd;
    --pink:       #f5c2e7;
    --mauve:      #cba6f7;
    --red:        #f38ba8;
    --maroon:     #eba0ac;
    --peach:      #fab387;
    --yellow:     #f9e2af;
    --green:      #a6e3a1;
    --teal:       #94e2d5;
    --sky:        #89dceb;
    --sapphire:   #74c7ec;
    --blue:       #89b4fa;
    --lavender:   #b4befe;
    --text:       #cdd6f4;
    --subtext1:   #bac2de;
    --subtext0:   #a6adc8;
    --overlay2:   #9399b2;
    --overlay1:   #7f849c;
    --overlay0:   #6c7086;
    --surface2:   #585b70;
    --surface1:   #45475a;
    --surface0:   #313244;
    --base:       #1e1e2e;
    --mantle:     #181825;
    --crust:      #11111b;
    --dark:       #090910;

    --font:       'Segoe UI', system-ui, -apple-system, sans-serif;
    --mono:       'Consolas', 'Courier New', monospace;
    --ease:       cubic-bezier(0.4, 0, 0.2, 1);
    --dur:        0.6s;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--base);
    color: var(--text);
    min-height: 100dvh;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
    z-index: 10;
}
.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* ============================================================
   FADE OVERLAY
   ============================================================ */
#fade-overlay {
    position: fixed;
    inset: 0;
    background: var(--dark);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}
#fade-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ============================================================
   HILFSFUNKTIONEN
   ============================================================ */
.hidden { display: none !important; }

.shake { animation: shake 0.45s ease; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-5px); }
    80%       { transform: translateX(5px); }
}

/* ============================================================
   CORNER BUTTONS (Regeln / Hinweis)
   ============================================================ */
.corner-btn {
    position: fixed;
    z-index: 50;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    border: 1px solid var(--surface2);
    background: color-mix(in srgb, var(--surface0) 80%, transparent);
    color: var(--overlay2);
    font-size: 0.78rem;
    font-family: var(--font);
    letter-spacing: 0.06em;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: all 0.25s ease;
}
.corner-btn:hover {
    border-color: var(--mauve);
    color: var(--mauve);
    background: color-mix(in srgb, var(--surface0) 90%, transparent);
    box-shadow: 0 0 12px color-mix(in srgb, var(--mauve) 20%, transparent);
}

.rules-btn { top: 1rem; right: 1rem; }
.hint-btn  { bottom: 1rem; right: 1rem; }

/* ============================================================
   OVERLAY MODAL (Regeln & Hinweis)
   ============================================================ */
.overlay-modal {
    position: fixed;
    inset: 0;
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 9, 16, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.overlay-box {
    position: relative;
    z-index: 1;
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 18px;
    padding: 2rem 2rem 1.75rem;
    width: min(480px, 90vw);
    max-height: 80vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surface2) transparent;
    box-shadow: 0 32px 80px rgba(0,0,0,0.7);
    animation: overlay-in 0.3s var(--ease);
}
@keyframes overlay-in {
    from { opacity: 0; transform: scale(0.93) translateY(10px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.overlay-close {
    position: absolute;
    top: 0.9rem; right: 1rem;
    background: none; border: none;
    color: var(--overlay1);
    font-size: 1rem; cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.2s;
    line-height: 1;
}
.overlay-close:hover { color: var(--red); }

.overlay-title {
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--mauve);
    margin-bottom: 1.25rem;
    padding-right: 2rem;
}

.overlay-content { color: var(--subtext1); font-size: 0.92rem; line-height: 1.8; }

.overlay-rules-list {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.overlay-rules-list li {
    padding: 0.55rem 0.9rem;
    background: var(--surface1);
    border-radius: 8px;
    border-left: 3px solid var(--mauve);
}

.overlay-hint-text {
    font-size: 1.05rem;
    color: var(--yellow);
    text-align: center;
    padding: 1rem;
    font-style: italic;
    background: color-mix(in srgb, var(--yellow) 6%, var(--surface1));
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--yellow) 20%, transparent);
}
.overlay-hint-img {
    width: 100%;
    border-radius: 8px;
    display: block;
}

/* ============================================================
   TYPEWRITER CURSOR
   ============================================================ */
.tw-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--mauve);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: tw-blink 0.75s step-end infinite;
}
@keyframes tw-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ============================================================
   BUTTONS (allgemein)
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-family: var(--font);
    letter-spacing: 0.04em;
    transition: all 0.2s ease;
}
.btn-primary {
    background: var(--mauve);
    color: var(--crust);
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--lavender);
    box-shadow: 0 0 22px color-mix(in srgb, var(--mauve) 45%, transparent);
    transform: translateY(-2px);
}
.btn-primary:active  { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-keypad-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.6rem;
    background: var(--surface0);
    border: 1px solid var(--surface2);
    color: var(--text);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.25s ease;
}
.btn-keypad-trigger:hover {
    border-color: var(--mauve);
    color: var(--mauve);
    box-shadow: 0 0 14px color-mix(in srgb, var(--mauve) 25%, transparent);
}

/* ============================================================
   NACHRICHTEN
   ============================================================ */
.msg-error {
    color: var(--red);
    font-size: 0.875rem;
    min-height: 1.4em;
    margin-top: 0.75rem;
    text-align: center;
}
.success-panel {
    margin-top: 1.5rem;
    padding: 1.2rem 1.5rem;
    background: color-mix(in srgb, var(--green) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--green) 28%, transparent);
    border-radius: 12px;
    text-align: center;
    animation: panel-in 0.4s var(--ease);
}
/* Outro-Panel (Phase 1 & 2 Abschluss) – neutral, kein Grün */
.outro-panel {
    margin-top: 1.5rem;
    padding: 1.2rem 1.5rem;
    background: color-mix(in srgb, var(--text) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
    border-radius: 12px;
    text-align: center;
    animation: panel-in 0.4s var(--ease);
}
.outro-panel .s-check { color: var(--subtext1); }
.outro-panel .s-hint  { color: var(--subtext0); }
@keyframes panel-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.s-check { color: var(--green); font-weight: 600; font-size: 1.1rem; margin-bottom: 0.4rem; }
.s-sub   { color: var(--subtext1); font-size: 0.9rem; margin-bottom: 0.3rem; }
.s-hint  { color: var(--peach); font-size: 0.95rem; margin-bottom: 0.3rem; }

/* ============================================================
   STORY TEXT (Typewriter-Ziel)
   ============================================================ */
.story-text {
    color: var(--subtext1);
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    line-height: 2;
    text-align: center;
    max-width: 580px;
}
.story-text--finale {
    color: var(--subtext0);
    line-height: 2.2;
}

/* Zustand-Wrapper */
.state-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.25rem;
    padding: 2rem;
    width: min(640px, 90vw);
}

/* ============================================================
   SCREEN LOGIN
   ============================================================ */
#screen-login { background: var(--crust); }

.login-wrap {
    text-align: center;
    padding: 2rem;
    width: min(420px, 90vw);
}
.login-omega {
    display: block;
    font-size: clamp(3rem, 8vw, 5rem);
    color: var(--mauve);
    text-shadow:
        0 0 28px color-mix(in srgb, var(--mauve) 50%, transparent),
        0 0 70px color-mix(in srgb, var(--mauve) 20%, transparent);
    margin-bottom: 0.75rem;
    animation: omega-pulse 4s ease-in-out infinite;
}
@keyframes omega-pulse {
    0%,100% { text-shadow: 0 0 28px color-mix(in srgb, var(--mauve) 50%, transparent); }
    50%      { text-shadow: 0 0 50px color-mix(in srgb, var(--mauve) 70%, transparent),
                            0 0 100px color-mix(in srgb, var(--lavender) 30%, transparent); }
}
.login-title {
    font-size: 1.4rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--subtext1);
    margin-bottom: 0.4rem;
    font-weight: 400;
}
.login-sub {
    color: var(--overlay1);
    font-size: 0.9rem;
    margin-bottom: 2.2rem;
}
.login-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.login-input {
    background: var(--surface0);
    border: 1px solid var(--surface2);
    color: var(--text);
    padding: 0.8rem 1.25rem;
    border-radius: 8px;
    font-size: 1.15rem;
    text-align: center;
    letter-spacing: 0.35em;
    width: 100%;
    max-width: 260px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: var(--mono);
}
.login-input:focus {
    border-color: var(--mauve);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--mauve) 22%, transparent);
}

/* ============================================================
   SCREEN PHASE 1 – WACHE
   ============================================================ */
#screen-phase1 {
    background: var(--dark);
    overflow: hidden;
    transition: background 1.5s ease;
    align-items: center;
}

/* Regen */
.rain-wrap {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}
.raindrop {
    position: absolute;
    top: -20px;
    width: 1.5px;
    height: 20px;
    background: linear-gradient(
        to bottom,
        transparent,
        color-mix(in srgb, var(--sapphire) 55%, white)
    );
    border-radius: 0 0 2px 2px;
    animation: rain-fall linear infinite;
}
@keyframes rain-fall {
    from { transform: translateY(-20px); }
    to   { transform: translateY(115vh); }
}

/* Blitz */
#lightning {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    pointer-events: none;
    z-index: 2;
}
#lightning.flash {
    animation: lightning-anim 0.35s ease-out forwards;
}
@keyframes lightning-anim {
    0%   { background: rgba(255,255,255, 0);    }
    8%   { background: rgba(255,255,255, 0.13); }
    18%  { background: rgba(255,255,255, 0);    }
    28%  { background: rgba(255,255,255, 0.08); }
    100% { background: rgba(255,255,255, 0);    }
}

/* Phase 1 Inhalts-States */
.p1-intro-wrap,
.p1-puzzle-wrap,
.p1-success-wrap {
    position: relative;
    z-index: 5;
}

.p1-lock { font-size: 3.2rem; filter: drop-shadow(0 0 18px var(--mauve)); }

.p1-flavor {
    color: var(--subtext0);
    font-size: 0.95rem;
    line-height: 1.75;
}

/* Metallplatte am Tor */
.p1-plate {
    position: relative;
    padding: 6px;
    background: linear-gradient(145deg, #4a4a52, #2a2a32, #3a3a44, #1e1e26);
    border-radius: 6px;
    box-shadow:
        0 0 0 1px #111,
        0 4px 18px rgba(0,0,0,0.7),
        inset 0 1px 0 rgba(255,255,255,0.06),
        0 0 40px color-mix(in srgb, var(--mauve) 18%, transparent);
}
.p1-plate::before {
    /* Schrauben-Effekt oben links & rechts */
    content: '· · · ·';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 4px 6px;
    font-size: 0.5rem;
    color: rgba(255,255,255,0.12);
    pointer-events: none;
    letter-spacing: 4px;
}
.p1-plate-inner {
    background: linear-gradient(160deg, #1a1a24, #141420, #1c1c28);
    border-radius: 3px;
    padding: 1.1rem 2rem;
    border: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
}
.p1-cipher-text {
    font-family: var(--mono);
    font-size: clamp(2.4rem, 8vw, 4.8rem);
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--mauve);
    text-shadow:
        0 0 18px color-mix(in srgb, var(--mauve) 70%, transparent),
        0 0 50px color-mix(in srgb, var(--mauve) 35%, transparent),
        0 0 100px color-mix(in srgb, var(--lavender) 15%, transparent);
    display: block;
}

/* ============================================================
   SCREEN PHASE 2 – LABOR / DUNKEL
   ============================================================ */
#screen-phase2 {
    background: var(--dark);
    transition: background 1s ease;
}

/* Cursor-Licht */
#cursor-light {
    position: fixed;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.2s ease;
    background: transparent;
}
#cursor-light.active { opacity: 1; }

.p2-intro-wrap {
    position: relative;
    z-index: 5;
}

.p2-explore-wrap {
    position: fixed;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem;
}

.p2-img-wrap {
    width: min(900px, 90vw);
    position: relative;
}

/* Bild ist standardmäßig verborgen – JS steuert mask-image per Cursor */
.p2-img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    /* Mask: alles ausgeblendet, wird per JS am Cursor-Punkt geöffnet */
    mask-image: radial-gradient(circle 0px at -9999px -9999px, black 0%, transparent 0%);
    -webkit-mask-image: radial-gradient(circle 0px at -9999px -9999px, black 0%, transparent 0%);
    transition: mask-image 0.05s, -webkit-mask-image 0.05s;
}

/* Keypad: dezent, erscheint nur bei Hover */
.p2-keypad-area {
    opacity: 0.18;
    transition: opacity 0.5s ease;
    position: relative;
    z-index: 9;
}
.p2-keypad-area:hover,
.p2-keypad-area:focus-within { opacity: 1; }

.p2-trigger {
    color: var(--overlay0);
    font-family: var(--mono);
    font-size: 1.5rem;
    letter-spacing: 0.4em;
    border-color: var(--surface1);
    background: transparent;
}
.p2-trigger:hover {
    color: var(--mauve);
    border-color: var(--mauve);
}

.p2-success-wrap {
    position: relative;
    z-index: 5;
}

/* ============================================================
   SCREEN PHASE 3 – AUDIO-RÄTSEL (kein Text, nur Audio + Buttons)
   ============================================================ */
#screen-phase3 {
    background: var(--mantle);
}

/* Zentrierter Haupt-Container */
.p3-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    padding: 2rem;
    width: min(540px, 90vw);
}

/* Waveform-Visualizer Container */
.p3-audio-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(520px, 90vw);
    height: 100px;
    /* Explizite Pixel-Werte damit JS sie auch lesen kann wenn hidden */
    --wf-w: 520;
    --wf-h: 100;
}

/* Canvas füllt Container exakt */
.p3-waveform {
    width: 100%;
    height: 100%;
    display: block;
}

/* Strophe-Replay-Buttons */
.p3-strophe-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    justify-content: center;
}
.btn-strophe {
    padding: 0.6rem 1.5rem;
    background: var(--surface0);
    border: 1px solid var(--surface2);
    color: var(--subtext1);
    border-radius: 22px;
    font-size: 0.9rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-strophe:hover {
    border-color: var(--mauve);
    color: var(--mauve);
    background: color-mix(in srgb, var(--mauve) 8%, var(--surface0));
}
.btn-strophe.is-playing {
    border-color: var(--green);
    color: var(--green);
    background: color-mix(in srgb, var(--green) 8%, var(--surface0));
}
.btn-strophe-pause {
    border-color: color-mix(in srgb, var(--yellow) 40%, var(--surface2));
    color: var(--yellow);
}
.btn-strophe-pause:hover {
    border-color: var(--yellow);
    color: var(--yellow);
    background: color-mix(in srgb, var(--yellow) 8%, var(--surface0));
}
.btn-strophe-stop {
    border-color: color-mix(in srgb, var(--red) 35%, var(--surface2));
    color: var(--maroon);
}
.btn-strophe-stop:hover {
    border-color: var(--red);
    color: var(--red);
    background: color-mix(in srgb, var(--red) 8%, var(--surface0));
}

/* Keypad-Wrapper Phase 3 */
.p3-keypad-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--surface1);
    width: 100%;
    text-align: center;
}

/* ============================================================
   SCREEN FINALE
   ============================================================ */
#screen-finale {
    background: var(--dark);
    flex-direction: column;
    gap: 0;
}

/* Flucht-Geschichte */
.finale-escape-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    width: min(560px, 90vw);
}

/* Geburtstags-Nachricht */
.finale-wrap {
    text-align: center;
    padding: 2rem;
    width: min(560px, 90vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    animation: finale-rise 1.8s var(--ease) forwards;
}
@keyframes finale-rise {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.finale-star {
    font-size: 2.5rem;
    color: var(--yellow);
    animation: star-glow 3s ease-in-out infinite;
}
@keyframes star-glow {
    0%,100% { text-shadow: 0 0 20px color-mix(in srgb, var(--yellow) 45%, transparent); }
    50%     { text-shadow: 0 0 45px color-mix(in srgb, var(--yellow) 75%, transparent),
                           0 0 90px color-mix(in srgb, var(--peach)  30%, transparent); }
}
.finale-number {
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 700;
    color: var(--mauve);
    text-shadow: 0 0 24px color-mix(in srgb, var(--mauve) 55%, transparent);
    line-height: 1;
}
.finale-title {
    font-size: clamp(1.7rem, 5vw, 2.6rem);
    font-weight: 300;
    color: var(--text);
    letter-spacing: 0.04em;
    line-height: 1.35;
}
.finale-name {
    color: var(--pink);
    font-weight: 700;
    font-size: 1.15em;
    text-shadow: 0 0 24px color-mix(in srgb, var(--pink) 55%, transparent);
}
.finale-msg {
    color: var(--subtext1);
    font-size: 1rem;
    line-height: 1.95;
    font-style: italic;
    max-width: 460px;
}
.finale-from { color: var(--lavender); font-size: 1.1rem; }
.finale-from em { color: var(--rosewater); font-style: normal; font-weight: 600; }

.finale-stars { display: flex; gap: 1.5rem; font-size: 1.3rem; margin-top: 0.5rem; }
.finale-stars span:nth-child(odd)  { color: var(--yellow); animation: star-glow 2.2s ease-in-out infinite; }
.finale-stars span:nth-child(even) { color: var(--surface2); animation: star-glow 2.2s ease-in-out infinite 1.1s; }

/* Credits – unten links, dezent */
.finale-credits {
    position: fixed;
    bottom: 1rem;
    left: 1.2rem;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--overlay0);
    font-style: italic;
    opacity: 0;
    transition: opacity 1.5s ease;
    pointer-events: none;
    z-index: 20;
}
.finale-credits.visible { opacity: 1; }

/* Keypad-Button Phase 3: nur Icon */
.btn-keypad-icon {
    font-size: 1.6rem;
    padding: 0.7rem 1.1rem;
    line-height: 1;
    border-radius: 50%;
    width: 3.2rem;
    height: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   KEYPAD MODAL
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--crust) 82%, transparent);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.modal-box {
    position: relative;
    z-index: 1;
    background: var(--mantle);
    border: 1px solid var(--surface1);
    border-radius: 18px;
    padding: 2.2rem 2rem;
    width: min(360px, 90vw);
    text-align: center;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    animation: modal-in 0.3s var(--ease);
}
@keyframes modal-in {
    from { opacity: 0; transform: scale(0.9) translateY(12px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.modal-close {
    position: absolute;
    top: 0.8rem; right: 0.9rem;
    background: none; border: none;
    color: var(--overlay1);
    font-size: 1rem; cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.2s;
    line-height: 1;
}
.modal-close:hover { color: var(--red); }

.kp-label {
    color: var(--subtext0);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}
.kp-display {
    font-family: var(--mono);
    font-size: 2.1rem;
    letter-spacing: 0.55em;
    color: var(--mauve);
    background: var(--surface0);
    border-radius: 8px;
    padding: 0.5rem;
    margin-bottom: 1.5rem;
    min-height: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.kp-display.error-flash {
    color: var(--red);
    animation: shake 0.45s ease;
}
.kp-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.kp-key {
    background: var(--surface0);
    border: 1px solid var(--surface2);
    color: var(--text);
    border-radius: 10px;
    padding: 0.9rem 0.5rem;
    font-size: 1.25rem;
    font-family: var(--mono);
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.kp-key:hover {
    background: var(--surface1);
    border-color: var(--mauve);
    color: var(--mauve);
    box-shadow: 0 0 10px color-mix(in srgb, var(--mauve) 28%, transparent);
}
.kp-key:active,
.kp-key.pressed {
    transform: scale(0.93);
    background: color-mix(in srgb, var(--mauve) 18%, var(--surface0));
}
.kp-del   { color: var(--maroon); }
.kp-del:hover { border-color: var(--red); color: var(--red); box-shadow: 0 0 10px color-mix(in srgb, var(--red) 28%, transparent); }
.kp-enter { color: var(--green); }
.kp-enter:hover { border-color: var(--green); color: var(--green); box-shadow: 0 0 10px color-mix(in srgb, var(--green) 28%, transparent); }

.kp-error { color: var(--red); font-size: 0.85rem; min-height: 1.3em; margin-top: 0.25rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
    .p1-cipher-text { font-size: clamp(1.8rem, 11vw, 3.2rem); letter-spacing: 0.1em; }
    .p1-plate-inner { padding: 0.8rem 1.2rem; }
    .modal-box { padding: 1.75rem 1.25rem; }
    .kp-key    { padding: 0.75rem 0.4rem; font-size: 1.1rem; }
    .p3-block  { padding: 1rem 1.1rem; }
    .corner-btn { font-size: 0.72rem; padding: 0.35rem 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
