:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #64748b;
    --line: #d9e0ea;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #0f766e;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, sans-serif;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 260px),
        var(--bg);
}

.app-shell {
    width: min(960px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0;
}

.play-shell {
    width: min(820px, calc(100% - 32px));
}

.landing-shell {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    justify-content: center;
    padding-top: 24px;
    padding-bottom: 24px;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.app-header.compact {
    align-items: center;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 40px;
    line-height: 1.1;
}

h2 {
    margin-bottom: 0;
    font-size: 20px;
}

.home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    gap: 20px;
    align-items: start;
}

.home-grid-single {
    display: block;
    width: min(720px, 100%);
    margin: 0 auto;
}

.landing-header {
    align-items: center;
    margin-bottom: 28px;
}

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(340px, 1.15fr);
    gap: 36px;
    align-items: center;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 24px;
    padding: clamp(28px, 5vw, 56px);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.13), transparent 48%),
        var(--surface);
    box-shadow: var(--shadow);
}

.landing-copy h2 {
    margin-bottom: 14px;
    font-size: clamp(32px, 5vw, 54px);
    line-height: 1.05;
}

.landing-copy p:last-child {
    max-width: 360px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.7;
}

.landing-kicker {
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 14px;
    font-weight: 800;
}

.landing-actions {
    display: grid;
    gap: 14px;
}

.landing-action {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    min-height: 104px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px 20px;
    color: var(--text);
    background: var(--surface);
    text-decoration: none;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.landing-action:hover {
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, 0.45);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
}

.landing-action-primary {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
}

.landing-action-primary:hover {
    border-color: transparent;
}

.landing-action-icon {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    border-radius: 14px;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    font-size: 22px;
    font-weight: 800;
}

.landing-action-primary .landing-action-icon {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.landing-action strong,
.landing-action small {
    display: block;
}

.landing-action strong {
    margin-bottom: 5px;
    font-size: 20px;
}

.landing-action small {
    color: var(--muted);
    font-size: 13px;
}

.landing-action-primary small {
    color: rgba(255, 255, 255, 0.78);
}

.landing-action-arrow {
    font-size: 22px;
    transition: transform 0.18s ease;
}

.landing-action:hover .landing-action-arrow {
    transform: translateX(4px);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.panel-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-heading p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 13px;
}

form {
    display: grid;
    gap: 12px;
}

label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-align: left;
}

.field-label {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-align: left;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px 14px;
    color: var(--text);
    background: var(--surface-soft);
    font: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

textarea {
    resize: vertical;
    line-height: 1.55;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.choice-section {
    display: grid;
    gap: 8px;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.category-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-card {
    display: block;
    min-width: 0;
    cursor: pointer;
}

.choice-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-content {
    display: grid;
    gap: 4px;
    min-height: 66px;
    align-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    color: var(--text);
    background: var(--surface-soft);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.choice-content strong,
.choice-content small {
    overflow-wrap: anywhere;
}

.choice-content small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.choice-card input:checked + .choice-content {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.choice-card.is-hidden {
    display: none;
}

button,
.secondary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button {
    color: #fff;
    background: var(--primary);
}

button:hover {
    background: var(--primary-dark);
}

.secondary-link {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.notice {
    border: 1px solid rgba(15, 118, 110, 0.28);
    border-radius: 8px;
    padding: 13px 16px;
    margin-bottom: 20px;
    color: var(--success);
    background: rgba(15, 118, 110, 0.08);
    font-weight: 700;
}

.seed-panel {
    display: block;
}

.seed-panel summary {
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

.seed-panel p {
    margin: 14px 0 12px;
    color: var(--muted);
    line-height: 1.55;
}

.ai-prompt-guide {
    display: grid;
    gap: 12px;
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 16px;
}

.ai-prompt-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.ai-prompt-header h3 {
    margin: 0 0 4px;
    font-size: 16px;
}

.ai-prompt-header p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.copy-prompt-button {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 9px 14px;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.copy-prompt-button:hover {
    background: rgba(37, 99, 235, 0.16);
}

.prompt-example {
    min-height: 260px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
}

.question-filter-form {
    gap: 14px;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-wrap {
    overflow-x: auto;
}

.question-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
    text-align: left;
}

.question-table th,
.question-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    vertical-align: top;
}

.question-table th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    background: var(--surface-soft);
}

.question-table td {
    overflow-wrap: anywhere;
}

.question-table code {
    color: var(--primary);
    font-family: Consolas, "Courier New", monospace;
    font-size: 14px;
    font-weight: 700;
}

.empty-state {
    margin-bottom: 0;
    color: var(--muted);
    font-weight: 700;
}

.bulk-details {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 16px;
}

.bulk-details summary {
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

.bulk-details form {
    margin-top: 14px;
}

.counter {
    min-width: 168px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--muted);
    background: var(--surface);
    font-weight: 700;
    text-align: center;
}

.question-stage {
    display: grid;
    place-items: center;
    min-height: 280px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 36px 24px;
    margin-bottom: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

#jp {
    margin-bottom: 18px;
    font-size: 48px;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
}

#romaji {
    color: var(--muted);
    font-size: 28px;
    line-height: 1.25;
    text-align: center;
}

#typingInput {
    display: block;
    width: min(620px, 100%);
    margin: 0 auto;
    padding: 18px 20px;
    font-size: 28px;
    text-align: center;
}

#typingInput.mistake {
    border-color: var(--danger);
    background: #fff1f0;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.metric {
    min-height: 96px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: var(--surface-soft);
    text-align: left;
}

.metric span {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    display: block;
    font-size: 28px;
    line-height: 1.1;
}

.metric.accent {
    border-color: rgba(37, 99, 235, 0.34);
    background: rgba(37, 99, 235, 0.08);
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 12px;
    color: var(--muted);
    font-weight: 700;
}

.legend-speed {
    color: var(--primary);
}

.legend-mistakes {
    color: var(--danger);
}

.result-chart {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.chart-grid {
    stroke: #dfe5ee;
    stroke-width: 1;
}

.chart-axis {
    stroke: #7b8798;
    stroke-width: 1.5;
}

.chart-speed,
.chart-mistakes {
    fill: none;
    stroke-width: 3;
}

.chart-speed {
    stroke: var(--primary);
}

.chart-mistakes {
    stroke: var(--danger);
}

.chart-speed-point {
    fill: var(--primary);
}

.chart-mistakes-point {
    fill: var(--danger);
}

.chart-label,
.chart-empty {
    fill: var(--muted);
    font-size: 13px;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 16px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--surface-soft);
    text-align: left;
}

.history span {
    min-width: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.history strong {
    white-space: nowrap;
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 24px, 960px);
        padding: 28px 0;
    }

    .app-header,
    .app-header.compact {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .landing-shell {
        min-height: 100svh;
        justify-content: center;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .landing-header {
        flex-direction: row;
        align-items: center;
        margin-bottom: 18px;
    }

    .landing-header h1 {
        font-size: 27px;
    }

    .landing-header .secondary-link {
        min-height: 40px;
        padding: 9px 12px;
        font-size: 12px;
    }

    .landing-hero {
        grid-template-columns: 1fr;
        gap: 22px;
        border-radius: 18px;
        padding: 24px 18px;
    }

    .landing-copy h2 {
        margin-bottom: 8px;
        font-size: 34px;
    }

    .landing-copy p:last-child {
        font-size: 14px;
        line-height: 1.55;
    }

    .landing-action {
        grid-template-columns: 46px minmax(0, 1fr) auto;
        min-height: 84px;
        padding: 14px;
    }

    .landing-action-icon {
        width: 46px;
        height: 46px;
    }

    .landing-action strong {
        font-size: 18px;
    }

    h1 {
        font-size: 32px;
    }

    .home-grid,
    .metrics-grid,
    .filter-grid,
    .choice-grid,
    .category-choice-grid {
        grid-template-columns: 1fr;
    }

    .panel,
    .question-stage {
        padding: 18px;
    }

    .ai-prompt-header {
        flex-direction: column;
    }

    #jp {
        font-size: 36px;
    }

    #romaji,
    #typingInput {
        font-size: 23px;
    }

    .history {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
