/* Dark only, in Matrix greens. Panels are near-opaque rather than blurred:
   a backdrop blur over an animated canvas is recomputed every frame. */
:root {
    --bg: #000a03;
    --panel: rgba(1, 12, 5, 0.86);
    --panel-strong: rgba(1, 14, 6, 0.94);
    --text: #d4ffdf;
    --muted: #7fc493;
    --border: rgba(0, 255, 65, 0.2);
    --accent: #00ff41;
    --accent-dim: #00b32d;
    --accent-text: #001a07;
    --danger: #ff6b6b;
    --map-line: rgba(0, 255, 65, 0.22);
    --map-hover: rgba(0, 255, 65, 0.14);
    --radius: 10px;
    --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Shown when WebGL is missing, and while the shader starts. */
    background:
        radial-gradient(ellipse at 30% 20%, rgba(0, 120, 35, 0.35), transparent 60%),
        radial-gradient(ellipse at 75% 80%, rgba(0, 90, 30, 0.3), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
::selection { background: var(--accent); color: var(--accent-text); }

.wrap {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---- Background layers: shader, then the map's lines, then the page ---- */

.fx-bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
    opacity: 0;
    transition: opacity 0.8s;
    pointer-events: none;
}
.has-fx .fx-bg { opacity: 1; }

.map-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 72px 4vw 48px;
    pointer-events: none;
}
.map-bg svg { height: 100%; width: auto; max-width: 60vw; }
.map-bg path {
    fill: transparent;
    stroke: var(--map-line);
    stroke-width: 0.8;
    stroke-linejoin: round;
    /* "all" so the transparent inside of a state still reacts. */
    pointer-events: all;
    cursor: pointer;
    transition: fill 0.15s, stroke 0.15s;
}
.map-bg path:hover, .map-bg path.active { fill: var(--map-hover); stroke: var(--accent); }

.map-tip {
    position: fixed;
    z-index: 3;
    pointer-events: none;
    background: var(--panel-strong);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font: 600 14px var(--mono);
    white-space: nowrap;
    transform: translate(12px, 12px);
}

.site-header, .site-footer, main { position: relative; z-index: 1; }
/* main lets the pointer through to the map except over what a visitor uses. */
main { pointer-events: none; }
main :is(a, button, input, textarea, select, label, form, h1, h2, p, .card, .alert, table, .entry, .score) { pointer-events: auto; }

@media (max-width: 720px) {
    .map-bg { justify-content: center; padding: 64px 16px 32px; }
    .map-bg svg { max-width: 100%; }
}

.fps-meter {
    position: fixed;
    right: 8px;
    bottom: 8px;
    z-index: 4;
    background: var(--panel-strong);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font: 12px var(--mono);
}

/* ---- Header, footer ---- */

.site-header, .site-footer { background: var(--panel-strong); }
.site-header { border-bottom: 1px solid var(--border); }

.site-header .wrap, .site-footer .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 14px;
    padding-bottom: 14px;
}

.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
}

.brand {
    font: 700 20px var(--mono);
    letter-spacing: 0.04em;
    color: var(--accent);
    text-decoration: none;
    text-shadow: 0 0 12px rgba(0, 255, 65, 0.45);
}

nav { display: flex; gap: 16px; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover, nav a[aria-current="page"] { color: var(--accent); }

.session { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.session form { margin: 0; }
.session > a:not(.button) { color: var(--muted); text-decoration: none; }
.session > a:not(.button):hover { color: var(--accent); }

main.wrap { padding-top: 40px; padding-bottom: 56px; }

/* ---- Glitch: two offset copies of the text, cut by clip-path in short
   bursts. At most three jumps a second, and none with reduced motion. ---- */

.glitch { position: relative; display: inline-block; }
.glitch::before,
.glitch::after {
    content: attr(data-text);
    content: attr(data-text) / ""; /* hidden from screen readers where supported */
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    text-shadow: none;
}
.glitch::before { color: #a8ffbf; animation: glitch-a 5.5s infinite steps(1); }
.glitch::after { color: var(--accent-dim); animation: glitch-b 5.5s infinite steps(1); }

@keyframes glitch-a {
    0%, 88%, 100% { opacity: 0; transform: none; clip-path: inset(0); }
    89% { opacity: 0.9; transform: translate(-3px, 1px); clip-path: inset(10% 0 55% 0); }
    92% { opacity: 0.9; transform: translate(3px, -1px); clip-path: inset(60% 0 8% 0); }
    95% { opacity: 0.8; transform: translate(-2px, 0); clip-path: inset(35% 0 40% 0); }
    97% { opacity: 0; }
}
@keyframes glitch-b {
    0%, 88%, 100% { opacity: 0; transform: none; clip-path: inset(0); }
    89% { opacity: 0.8; transform: translate(3px, 0); clip-path: inset(65% 0 5% 0); }
    92% { opacity: 0.8; transform: translate(-3px, 2px); clip-path: inset(5% 0 70% 0); }
    95% { opacity: 0.7; transform: translate(2px, -1px); clip-path: inset(45% 0 30% 0); }
    97% { opacity: 0; }
}
.brand.glitch::before, .brand.glitch::after { animation-duration: 7.3s; }

@media (prefers-reduced-motion: reduce) {
    .glitch::before, .glitch::after { animation: none; display: none; }
    *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* ---- Home ---- */

.hero {
    text-align: center;
    padding: 9vh 0 6vh;
}
.hero h1 {
    font: 700 clamp(40px, 9vw, 88px) / 1.05 var(--mono);
    letter-spacing: 0.02em;
    color: var(--accent);
    margin: 0 0 16px;
    text-shadow: 0 0 24px rgba(0, 255, 65, 0.5), 0 0 2px rgba(0, 255, 65, 0.9);
}
.hero p {
    color: var(--text);
    font-size: clamp(16px, 2.2vw, 19px);
    margin: 0 auto;
    max-width: 560px;
    text-shadow: 0 1px 8px #000;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

/* ---- Panels ---- */

.card, .entry, .alert, table, .game-status {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.card { padding: 20px; }
.card h2 { margin: 0 0 6px; font-size: 18px; color: var(--text); }
.card p { margin: 0 0 12px; color: var(--muted); }

a.card-link { display: block; color: inherit; text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; }
a.card-link:hover { border-color: var(--accent); box-shadow: 0 0 18px rgba(0, 255, 65, 0.18); }

.badge {
    display: inline-block;
    font: 12px var(--mono);
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
}
.badge-live { border-color: var(--accent); color: var(--accent); }

/* Headings on the open background get a dark halo so they stay legible. */
main h1, main h2 { text-shadow: 0 1px 10px #000, 0 0 2px #000; }
main h1 { font-family: var(--mono); letter-spacing: 0.01em; }
.muted { color: var(--muted); }
main > section > p, .form-page > p { text-shadow: 0 1px 8px #000; }

.alert { padding: 10px 14px; }
.alert-ok { border-color: var(--accent); }
.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-info { border-color: var(--border); }

/* ---- Forms ---- */

button, .button {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
    border-radius: 8px;
    padding: 8px 16px;
    text-decoration: none;
    display: inline-block;
}
button:hover, .button:hover { box-shadow: 0 0 14px rgba(0, 255, 65, 0.4); }
.session .button { padding: 4px 12px; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font-weight: 400; box-shadow: none; }
button.link:hover { color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }

.form-page { max-width: 440px; }
.form { display: grid; gap: 16px; margin: 16px 0 24px; }
.form label { display: grid; gap: 6px; font-weight: 600; text-shadow: 0 1px 8px #000; }
.form small { font-weight: 400; color: var(--muted); }
input, textarea, select {
    font: inherit;
    color: var(--text);
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Tables ---- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font: 600 12px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.actions { display: flex; gap: 6px; margin: 0; }
.actions button { padding: 4px 10px; font-size: 14px; }

/* ---- Guestbook ---- */

.guestbook { max-width: 720px; }
.entry-form textarea { resize: vertical; min-height: 80px; }
.entry-form button { justify-self: start; }
.entries { display: grid; gap: 12px; margin-top: 8px; }
.entry { padding: 14px 18px; }
.entry header { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.entry strong { color: var(--accent); font-family: var(--mono); }
.entry time { color: var(--muted); font-size: 13px; }
/* white-space keeps the writer's line breaks; the text itself is escaped. */
.entry p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry form { margin: 6px 0 0; }
.entry button.link { font-size: 13px; }
.entry.is-new { animation: entry-in 0.8s ease-out; }
@keyframes entry-in { from { border-color: var(--accent); box-shadow: 0 0 20px rgba(0, 255, 65, 0.35); } }

/* ---- Rock, paper, scissors ---- */

.game { max-width: 720px; }
.game-status { margin: 16px 0; padding: 16px 20px; }
.game-status p { margin: 0; }
.game-status strong { color: var(--accent); font-family: var(--mono); }
.moves { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 24px; }
.move {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 18px 8px;
    font-size: 17px;
    font-weight: 600;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.move:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 0 18px rgba(0, 255, 65, 0.25); }
.move:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
/* Drawn shapes rather than emoji, so they look the same on every system. */
.move-icon { width: 46px; height: 46px; background: var(--accent); }
.move-stein .move-icon { border-radius: 46% 54% 50% 50% / 55% 48% 52% 45%; }
.move-papier .move-icon { border-radius: 4px; width: 36px; height: 46px; }
.move-schere .move-icon {
    background:
        linear-gradient(60deg, transparent 44%, var(--accent) 44% 56%, transparent 56%),
        linear-gradient(-60deg, transparent 44%, var(--accent) 44% 56%, transparent 56%);
}
.score { display: inline-flex; gap: 20px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 16px; }
.score strong { color: var(--accent); font-family: var(--mono); }
tr.result-win td:last-child { color: var(--accent); font-weight: 600; }
tr.result-loss td:last-child { color: var(--danger); font-weight: 600; }
