/* ==========================================================================
   pacman-lamp :: style.css
   Dark arcade theme, German UI copy.
   Mobile-first: full-width board, bottom status bar, virtual joystick.
   The original desktop layout is restored from 901px upward.
   ========================================================================== */

:root {
    --bg:            #05060a;
    --bg-panel:      #0d1020;
    --bg-card:       #111527;
    --line:          #232a4d;
    --text:          #e8ecff;
    --muted:         #8f97c4;
    --accent:        #ffd90a;
    --accent-2:      #2121de;
    --danger:        #ff2e4d;
    --blinky:        #ff2121;
    --pinky:         #ffb8de;
    --inky:          #21b7ff;
    --clyde:         #ffb852;
    --radius:        14px;
    --shadow:        0 18px 50px rgba(0, 0, 0, .55);
    --statusbar-h:   48px;
    --joystick-size: 120px;
    --knob-size:     56px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background:
        radial-gradient(1200px 600px at 50% -10%, #141a3a 0%, transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100%;
    overscroll-behavior: none;
}

kbd {
    display: inline-block;
    padding: 1px 7px;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: #171c33;
    font-family: inherit;
    font-size: .8em;
    color: var(--text);
}

.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 10px calc(var(--statusbar-h) + env(safe-area-inset-bottom) + 16px);
}

/* ---------- Top bar ---------- */

.topbar { text-align: center; margin-bottom: 10px; }

.logo {
    margin: 0;
    font-size: clamp(20px, 6vw, 26px);
    letter-spacing: .22em;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 18px rgba(255, 217, 10, .45);
}

.logo-dash { color: var(--text); }

.tagline {
    display: none;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: .95rem;
    letter-spacing: .08em;
}

/* ---------- Layout ---------- */

.stage {
    display: grid;
    grid-template-columns: minmax(0, 560px);
    gap: 16px;
    align-items: start;
    justify-content: center;
}

/* ---------- Board ---------- */

.board {
    --board-chrome: calc(var(--statusbar-h) + env(safe-area-inset-bottom) + 64px);
    position: relative;
    width: min(100%, 560px, calc((100vh - var(--board-chrome)) * 0.8));
    width: min(100%, 560px, calc((100dvh - var(--board-chrome)) * 0.8));
    aspect-ratio: 560 / 700;
    margin: 0 auto;
    background: #000;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    touch-action: none;
}

#game {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

/* ---------- Overlays ---------- */

.overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    align-items: safe center;
    justify-content: center;
    padding: clamp(10px, 4vw, 18px);
    overflow-y: auto;
    background: rgba(3, 4, 10, .86);
    backdrop-filter: blur(3px);
    z-index: 5;
    text-align: center;
}

.overlay--visible { display: flex; }

.panel {
    background: linear-gradient(180deg, #131834 0%, #0b0e1e 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(16px, 5vw, 26px) clamp(14px, 5vw, 26px) clamp(14px, 4vw, 22px);
    max-width: 420px;
    width: 100%;
    flex: 0 0 auto;
    box-shadow: var(--shadow);
}

.panel--slim { max-width: 320px; }

.panel h2 {
    margin: 0 0 8px;
    font-size: clamp(1.3rem, 6vw, 1.7rem);
    letter-spacing: .18em;
    color: var(--accent);
}

.panel-sub {
    margin: 0 0 18px;
    color: var(--muted);
    line-height: 1.55;
    font-size: clamp(.88rem, 3.4vw, .95rem);
}

.big-text {
    margin: 0;
    font-size: clamp(1.45rem, 7vw, 2rem);
    font-weight: 800;
    letter-spacing: .16em;
    color: var(--accent);
    text-shadow: 0 0 16px rgba(255, 217, 10, .4);
}

.pac-logo {
    width: 74px;
    height: 74px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: conic-gradient(from -35deg, var(--accent) 0 76%, transparent 76% 100%);
    animation: chomp 1.1s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 14px rgba(255, 217, 10, .55));
}

@keyframes chomp {
    from { clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0); }
    to   { clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0); }
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #171c33;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .04em;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform .08s ease, background .15s ease, border-color .15s ease;
}

.btn:hover { background: #1e2446; border-color: #39418a; }
.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #161300;
}

.btn--primary:hover { background: #ffe857; border-color: #ffe857; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 12px; }

/* ---------- Quote overlay ---------- */

.panel--quote { border-color: #4b2f6e; }

.quote-mark {
    margin: 0;
    font-size: clamp(2.4rem, 10vw, 3.4rem);
    line-height: .6;
    color: var(--accent);
    font-family: Georgia, serif;
}

.quote-text {
    margin: 10px 0 14px;
    font-size: clamp(1rem, 4vw, 1.15rem);
    line-height: 1.5;
    font-style: italic;
    color: var(--text);
    min-height: 3.2em;
    display: flex;
    align-items: center;
    justify-content: center;
}

#quote-lives { color: var(--danger); font-weight: 600; margin-bottom: 0; }

/* ---------- Game over form ---------- */

.gameover-title {
    color: var(--danger) !important;
    text-shadow: 0 0 16px rgba(255, 46, 77, .45);
}

.final-score {
    font-size: 1.15rem;
    margin: 4px 0 16px;
    color: var(--muted);
}

.final-score strong { color: var(--accent); font-size: 1.5rem; }

.field-label {
    display: block;
    text-align: left;
    font-size: .85rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.field {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #070a17;
    color: var(--text);
    font-size: 16px;
    letter-spacing: .06em;
    outline: none;
}

.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 217, 10, .18); }

.save-status {
    min-height: 1.3em;
    margin: 10px 0 0;
    font-size: .9rem;
    color: var(--accent);
}

.save-status.is-error { color: var(--danger); }

/* ---------- Highscore list ---------- */

.score-list {
    list-style: none;
    margin: 0 0 6px;
    padding: 0;
    text-align: left;
    max-height: 320px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.score-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
}

.score-list li:last-child { border-bottom: 0; }

.score-list .rank { color: var(--muted); width: 2.2em; }
.score-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-list .pts  { color: var(--accent); font-weight: 700; }
.score-list .lvl  { color: var(--muted); font-size: .85em; width: 3.4em; text-align: right; }

.score-empty { justify-content: center; color: var(--muted); }

/* ---------- Controls hint ---------- */

.controls-hint {
    list-style: none;
    display: none;
    margin: 18px 0 0;
    padding: 14px 0 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .88rem;
    gap: 6px;
}

.controls-hint kbd + kbd { margin-left: 3px; }

.touch-hint {
    display: block;
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .88rem;
}

.hint-keyboard { display: none; }
.hint-touch    { display: inline; }

/* ---------- Sidebar ---------- */

.sidebar { display: none; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.card--muted { background: transparent; }

.card-title {
    margin: 0 0 12px;
    font-size: .8rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--muted);
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }

.stat {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}

.stat dt { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat dd { margin: 4px 0 0; font-size: 1.35rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

#hud-lives { color: var(--accent); letter-spacing: .12em; }

.points, .ghost-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
    font-size: .92rem;
}

.points li, .ghost-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.points span { color: var(--muted); }
.points b { color: var(--text); font-variant-numeric: tabular-nums; }

.ghost-list li { justify-content: flex-start; color: var(--muted); }
.ghost-list b { color: var(--text); margin-right: 4px; }

.dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    flex: 0 0 auto;
    margin-right: 9px;
    display: inline-block;
    position: relative;
}

.dot::before, .dot::after {
    content: "";
    position: absolute;
    top: 3px;
    width: 3px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
}

.dot::before { left: 3px; }
.dot::after  { right: 3px; }

.dot--blinky { background: var(--blinky); }
.dot--pinky  { background: var(--pinky); }
.dot--inky   { background: var(--inky); }
.dot--clyde  { background: var(--clyde); }

.hint { margin: 0 0 8px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.hint:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */

.footer {
    display: none;
    margin-top: 26px;
    text-align: center;
    color: #565e8c;
    font-size: .82rem;
    letter-spacing: .04em;
}

/* ---------- Status bar (touch devices) ---------- */

.status-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--statusbar-h) + env(safe-area-inset-bottom));
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: var(--bg-panel);
    border-top: 1px solid var(--line);
    overflow: hidden;
    z-index: 40;
}

.status-item {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.status-item b {
    max-width: 100%;
    font-size: .95rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-item small {
    font-size: .6rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    line-height: 1.15;
    color: var(--muted);
    white-space: nowrap;
}

.status-item #status-lives { font-size: .8rem; letter-spacing: .1em; }

.status-pause {
    display: none;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #171c33;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    align-items: center;
    justify-content: center;
}

.status-pause:active { transform: translateY(1px); }

.status-bar.is-playing .status-pause { display: inline-flex; }

.pause-icon {
    display: inline-flex;
    gap: 4px;
}

.pause-icon i {
    display: block;
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--accent);
}

/* ---------- Virtual joystick (touch devices) ---------- */

.joystick {
    display: none;
    position: fixed;
    right: 16px;
    bottom: calc(var(--statusbar-h) + 16px + env(safe-area-inset-bottom));
    width: var(--joystick-size);
    height: var(--joystick-size);
    border-radius: 50%;
    border: 2px solid rgba(232, 236, 255, .28);
    background: rgba(13, 16, 32, .55);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 30;
}

body.touch .joystick { display: block; }

.joystick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--knob-size);
    height: var(--knob-size);
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, .35);
    background: radial-gradient(circle at 35% 30%, #ffe857, var(--accent) 60%, #c9a400);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    body.touch .joystick { display: none; }
}

/* ---------- Narrow landscape phones ---------- */

@media (max-width: 900px) and (orientation: landscape) {
    .app { padding-top: 6px; }
    .topbar { display: none; }
    .board {
        --board-chrome: calc(var(--statusbar-h) + env(safe-area-inset-bottom) + 8px);
    }
}

/* ==========================================================================
   Desktop layout (unchanged original design)
   ========================================================================== */

@media (min-width: 901px) {
    .app { padding: 22px 18px 40px; }

    .topbar { margin-bottom: 18px; }
    .logo   { font-size: clamp(28px, 5vw, 44px); }
    .tagline { display: block; }

    .stage {
        grid-template-columns: minmax(0, 560px) minmax(240px, 1fr);
        gap: 22px;
    }

    .board {
        width: 100%;
        max-width: 560px;
    }

    #game { image-rendering: pixelated; }

    .overlay { padding: 18px; }
    .panel   { padding: 26px 26px 22px; }
    .panel h2 { font-size: 1.7rem; }
    .panel-sub { font-size: .95rem; }
    .big-text  { font-size: 2rem; }
    .quote-mark { font-size: 3.4rem; }
    .quote-text { font-size: 1.15rem; }

    .field { font-size: 1.05rem; }

    .controls-hint { display: grid; }
    .touch-hint    { display: none; }

    .hint-keyboard { display: inline; }
    .hint-touch    { display: none; }

    .sidebar { display: grid; gap: 16px; }

    .footer { display: block; }

    .status-bar { display: none; }
}
