.ddd-intro {
    max-width: 680px;
    margin: 0 auto;
    padding: 32px 20px 8px;
    font-size: 1rem;
    text-align: center;
}

.ddd-eyebrow {
    display: block;
    margin-bottom: 14px;
    font-family: var(--g-font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--g-gold);
}

.ddd-intro h1 {
    margin: 0 0 14px;
}

.ddd-intro p {
    max-width: 62ch;
    margin: 0 auto;
    padding: 0;
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.65;
    color: var(--g-ink-2);
}

.ddd-intro::after {
    content: "";
    display: block;
    width: 200px;
    height: 12px;
    margin: 24px auto 0;
    background: var(--g-gold);
    -webkit-mask: var(--g-mask-rule) center / contain no-repeat;
    mask: var(--g-mask-rule) center / contain no-repeat;
}

#mainContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 20px 40px;
    box-sizing: border-box;
}

.top-toggle {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.toggle-group {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.toggle-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--g-ink-3);
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 38px;
    height: 20px;
    cursor: pointer;
}

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

.slider {
    position: absolute;
    inset: 0;
    border: 1px solid var(--g-rule-strong);
    transition: border-color 140ms ease, background-color 140ms ease;
}

.slider::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 10px;
    height: 10px;
    background: var(--g-ink-3);
    transition: transform 140ms ease, background-color 140ms ease;
}

.switch input:checked+.slider {
    border-color: var(--g-gold);
    background: var(--g-gold-soft);
}

.switch input:checked+.slider::before {
    background: var(--g-gold);
    transform: translateX(18px);
}

.switch input:focus-visible+.slider {
    outline: 1px solid var(--g-gold);
    outline-offset: 2px;
}

.ddd-stats {
    display: grid;
    grid-template-columns: 2fr 3fr;
    width: 100%;
    background: var(--g-panel);
    border-top: 1px solid var(--g-rule-strong);
    border-bottom: 1px solid var(--g-rule-strong);
}

#scoreboard,
#statsContainer {
    display: grid;
    margin: 0;
    padding: 0;
}

#scoreboard {
    grid-template-columns: repeat(2, 1fr);
}

#statsContainer {
    grid-template-columns: repeat(3, 1fr);
}

.stat-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 14px 8px 12px;
    border-left: 1px solid var(--g-rule);
    transition: background-color 140ms ease;
}

#scoreboard .stat-badge:first-child {
    border-left: 0;
}

.ddd-stats .stat-value {
    font-size: 1.6rem;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

body.tool-page #score {
    color: var(--g-gold) !important;
}

body.tool-page #lives {
    color: var(--g-rose) !important;
}

.stat-badge.streak.active {
    background: var(--g-gold-soft);
}

#gameAndControls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

#gameContainer {
    position: relative;
    display: block;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 3 / 4;
    min-height: 500px;
    max-height: min(800px, calc(100vh - 96px));
    margin: 0 auto;
    overflow: hidden;
    background: var(--g-canvas);
    border: 1px solid var(--g-rule);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

#multiArticlePopup {
    position: absolute;
    left: 50%;
    bottom: 120px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    max-width: 90%;
    padding: 14px 18px;
    text-align: center;
    color: var(--g-ink);
    background: var(--g-clasp), var(--g-panel);
    border: 1px solid var(--g-rule-strong);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%);
    transition: opacity 160ms ease;
}

#multiArticlePopup.show {
    opacity: 1;
}

.multi-article-title {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--g-ink-3);
}

.multi-article-word {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--g-ink);
}

.multi-article-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.article-chip {
    padding: 4px 12px;
    font-family: var(--g-font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--g-ink-3);
    border: 1px solid currentColor;
}

.article-chip--der {
    color: var(--g-moon);
}

.article-chip--die {
    color: var(--g-rose);
}

.article-chip--das {
    color: var(--g-verdigris);
}

#startScreen {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 36px 36px 48px;
    box-sizing: border-box;
    overflow-y: auto;
    text-align: center;
    background: var(--g-clasp), var(--g-panel);
}

#startScreen h2 {
    margin: 0;
    font-family: var(--g-font-display);
    font-size: 2.6rem;
    font-weight: 600;
    line-height: 1.05;
    color: var(--g-ink);
}

#startScreen>p {
    max-width: 420px;
    margin: 0;
    padding: 0;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--g-ink-2);
}

#startScreen .instructions {
    width: 100%;
    max-width: 400px;
    padding: 16px 0;
    border-top: 1px solid var(--g-rule);
    border-bottom: 1px solid var(--g-rule);
}

#startScreen .instructions ul {
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

#startScreen .instructions li {
    position: relative;
    margin: 0;
    padding: 6px 0 6px 22px;
    font-size: 1rem;
    line-height: 1.45;
    color: var(--g-ink);
}

#startScreen .instructions li::before {
    content: "";
    position: absolute;
    top: 14px;
    left: 4px;
    width: 5px;
    height: 5px;
    background: var(--g-gold);
    transform: rotate(45deg);
}

#startScreen kbd {
    min-width: 1.6em;
    text-align: center;
}

.difficulty-selector {
    display: flex;
    justify-content: center;
}

body.tool-page .difficulty-btn {
    min-width: 96px;
    min-height: 42px;
    padding: 10px 18px;
    font-size: 0.95rem !important;
}

.difficulty-btn+.difficulty-btn {
    margin-left: -1px;
}

body.tool-page .difficulty-btn.active {
    position: relative;
    z-index: 1;
}

#startScreen .difficulty-hint {
    margin: 0;
    padding: 0;
    font-family: var(--g-font-mono);
    font-size: 0.78rem;
    color: var(--g-ink-3);
}

body.tool-page #startBtn {
    min-width: 200px;
    min-height: 48px;
    padding: 12px 32px;
    font-size: 1rem !important;
    letter-spacing: 0.04em !important;
}

#soundToggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 12px;
    background: var(--g-panel) !important;
    cursor: pointer;
}

#soundToggle .sound-icon {
    width: 7px;
    height: 7px;
    background: var(--g-gold);
    border: 1px solid var(--g-gold);
    transform: rotate(45deg);
}

#soundToggle.muted .sound-icon {
    background: transparent;
    border-color: var(--g-ink-3);
}

#soundToggle .sound-label {
    font-family: var(--g-font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#soundToggle.muted .sound-label {
    color: var(--g-ink-3);
}

#controls {
    display: none;
    flex-flow: row nowrap;
    gap: 12px;
    width: 100%;
    max-width: 600px;
    margin: 0;
    padding: 0;
}

body.tool-page .control-btn {
    flex: 1;
    min-height: 56px;
    font-size: 1.05rem !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#leftButton::before {
    content: "←";
    margin-right: 8px;
}

#rightButton::after {
    content: "→";
    margin-left: 8px;
}

#recapPanel {
    width: 100%;
    background: var(--g-clasp), var(--g-panel);
    border: 1px solid var(--g-rule);
}

#recapPanel summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    font-family: var(--g-font-display);
    font-size: 1.3rem;
    font-weight: 600;
    font-variant: small-caps;
    letter-spacing: 0.06em;
    text-transform: lowercase;
    color: var(--g-ink);
    list-style: none;
    cursor: pointer;
    transition: color 140ms ease;
}

#recapPanel summary:hover {
    color: var(--g-gold);
}

#recapPanel summary::-webkit-details-marker {
    display: none;
}

#recapPanel summary::after {
    content: "+";
    font-family: var(--g-font-mono);
    font-size: 1.1rem;
    font-variant: normal;
    color: var(--g-gold);
}

#recapPanel[open] summary {
    border-bottom: 1px solid var(--g-rule);
}

#recapPanel[open] summary::after {
    content: "−";
}

#tablesContainer {
    width: 100%;
    padding: 20px 22px 24px;
    box-sizing: border-box;
}

#wordsTableContainer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    width: 100%;
}

.column {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
}

.column h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--g-ink-2);
}

.column h3::before {
    content: "";
    width: 7px;
    height: 7px;
    transform: rotate(45deg);
}

.column:first-child h3::before {
    background: var(--g-rose);
}

.column:last-child h3::before {
    background: var(--g-verdigris);
}

#incorrectWordsTable,
#correctWordsTable {
    width: 100%;
    border-collapse: collapse;
}

#incorrectWordsTable th,
#correctWordsTable th,
#incorrectWordsTable td,
#correctWordsTable td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--g-rule);
}

#incorrectWordsTable th,
#correctWordsTable th {
    border-top: 1px solid var(--g-rule-strong);
}

#incorrectWordsTable td,
#correctWordsTable td {
    font-size: 0.95rem;
    color: var(--g-ink);
}

#incorrectWordsTable td:not(:first-child),
#correctWordsTable td:not(:first-child) {
    font-family: var(--g-font-mono);
    font-size: 0.85rem;
    color: var(--g-ink-2);
}

#incorrectWordsTable td:nth-child(2) {
    color: var(--g-rose);
}

#correctWordsTable td:nth-child(2) {
    color: var(--g-verdigris);
}

.spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 24px 32px;
    font-size: 0;
    background: var(--g-clasp), var(--g-panel);
    border: 1px solid var(--g-rule);
    transform: translate(-50%, -50%);
}

.spinner::before {
    content: "";
    width: 10px;
    height: 10px;
    background: var(--g-gold);
    transform: rotate(45deg);
    animation: ddd-pulse 1.2s ease-in-out infinite;
}

.spinner::after {
    content: "Loading German words";
    font-family: var(--g-font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--g-ink-2);
}

@keyframes ddd-pulse {
    50% {
        opacity: 0.25;
    }
}

#pluralOverlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: color-mix(in srgb, var(--g-bg) 88%, transparent);
}

.plural-card {
    width: min(440px, 100%);
    padding: 32px;
    box-sizing: border-box;
    text-align: center;
    color: var(--g-ink);
    background: var(--g-clasp), var(--g-panel);
    border: 1px solid var(--g-rule-strong);
    transition: border-color 140ms ease;
}

.plural-card h3 {
    margin: 0 0 10px;
    font-family: var(--g-font-display);
    font-size: 1.6rem;
    font-weight: 600;
    font-variant: small-caps;
    letter-spacing: 0.06em;
    text-transform: lowercase;
    color: var(--g-ink);
}

.plural-card p {
    margin: 0;
    padding: 0;
    font-size: 1.05rem;
    color: var(--g-ink-2);
}

#pluralWord {
    font-weight: 600;
    color: var(--g-ink);
}

body.tool-page .plural-card input {
    width: 100%;
    margin-top: 18px;
    padding: 12px 14px;
    font-size: 1.1rem;
    box-sizing: border-box;
}

.plural-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
}

body.tool-page .plural-actions button {
    min-width: 110px;
    min-height: 42px;
    font-size: 0.95rem !important;
}

#pluralFeedback {
    min-height: 24px;
    margin-top: 16px;
    font-weight: 500;
    color: var(--g-ink-2);
}

#pluralOverlay.plural-correct .plural-card {
    border-color: var(--g-verdigris);
}

#pluralOverlay.plural-correct #pluralFeedback {
    color: var(--g-verdigris);
}

#pluralOverlay.plural-wrong .plural-card {
    border-color: var(--g-rose);
}

#pluralOverlay.plural-wrong #pluralFeedback {
    color: var(--g-rose);
}

@media only screen and (max-width: 767px) {
    #mainContainer {
        gap: 14px;
        padding: 16px 16px 32px;
    }

    .ddd-stats {
        grid-template-columns: 1fr;
    }

    #statsContainer {
        border-top: 1px solid var(--g-rule);
    }

    #statsContainer .stat-badge:first-child {
        border-left: 0;
    }

    .ddd-stats .stat-value {
        font-size: 1.3rem;
    }

    .stat-badge {
        padding: 10px 6px;
    }

    #gameContainer {
        min-height: 60vh;
        max-height: none;
    }

    #controls {
        display: flex;
    }

    #wordsTableContainer {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    #tablesContainer {
        padding: 16px;
    }

    #startScreen {
        gap: 16px;
        padding: 24px 22px 40px;
    }

    #startScreen h2 {
        font-size: 2.1rem;
    }
}

@media (max-width: 480px) {
    .ddd-intro {
        padding: 24px 16px 0;
    }

    .ddd-intro p {
        font-size: 1rem;
    }

    #gameContainer {
        min-height: 95vh;
        aspect-ratio: 1 / 2;
    }

    #startScreen {
        padding: 20px 16px 36px;
    }

    #startScreen>p {
        font-size: 0.98rem;
    }

    #startScreen .instructions li {
        font-size: 0.95rem;
        padding: 5px 0 5px 22px;
    }

    #startScreen .instructions li::before {
        top: 13px;
    }

    .difficulty-selector {
        width: 100%;
    }

    body.tool-page .difficulty-btn {
        flex: 1;
        min-width: 0;
    }

    .toggle-group {
        width: 100%;
        justify-content: space-between;
    }

    .toggle-label {
        margin-right: auto;
    }
}

@media (max-height: 720px) {
    #startScreen {
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner::before {
        animation: none;
    }
}