:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #232735;
    --text: #e8eaf2;
    --muted: #8a90a3;
    --accent: #e63946;
    --accent-soft: #ff6b76;
    --green: #4caf7d;
    --orange: #e0a44c;
    --red: #d9534f;
    --border: #2c303d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
                 "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
    min-height: 100vh;
}

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px 80px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}

h1 {
    font-size: 28px;
    margin: 0;
    font-weight: 600;
}
h1 .sub {
    color: var(--muted);
    font-size: 16px;
    font-weight: 400;
}

h2 {
    font-size: 22px;
    margin: 0 0 16px;
}

#stats-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--muted);
}
.badge.new { border-color: var(--accent); color: var(--accent-soft); }
.badge.learned { border-color: var(--green); color: var(--green); }

main { flex: 1; }

.screen { animation: fade .2s ease; }
.hidden { display: none !important; }

@keyframes fade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

button {
    font: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 12px 20px;
    font-weight: 500;
    transition: transform .05s, background .15s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary {
    background: var(--accent);
    color: white;
}
button.primary:hover { background: var(--accent-soft); }

button.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
button.secondary:hover { background: var(--surface-2); }

button.danger {
    background: transparent;
    color: var(--red);
    border-color: var(--red);
}
button.danger:hover { background: rgba(217, 83, 79, 0.1); }

button.link {
    background: transparent;
    color: var(--muted);
    border: none;
    margin-top: 24px;
    text-decoration: underline;
    padding: 8px;
}

button.big {
    width: 100%;
    padding: 18px;
    font-size: 16px;
}

/* Card */
.progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 14px;
}

#card-status-tag {
    background: var(--surface);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
}
#card-status-tag.new { background: rgba(230, 57, 70, 0.2); color: var(--accent-soft); }
#card-status-tag.review { background: rgba(76, 175, 125, 0.15); color: var(--green); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 24px;
    text-align: center;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.cat {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.jp {
    font-size: 44px;
    font-weight: 500;
    line-height: 1.2;
    word-break: keep-all;
}
@media (max-width: 480px) {
    .jp { font-size: 34px; }
}

.reading {
    color: var(--muted);
    font-size: 18px;
    margin-top: 8px;
}

.icon-btn {
    align-self: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 999px;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}
.icon-btn:hover { background: var(--accent); border-color: var(--accent); }
.icon-btn.speaking { background: var(--accent); border-color: var(--accent); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.answer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.fr {
    font-size: 22px;
    color: var(--accent-soft);
    font-weight: 500;
}

.card-buttons { display: flex; flex-direction: column; gap: 12px; }

.answer-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

button.ans {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px;
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
button.ans .lbl { font-weight: 600; font-size: 16px; }
button.ans .hint {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}
button.ans.again { border-color: var(--red); }
button.ans.again:hover { background: rgba(217, 83, 79, 0.15); }
button.ans.good { border-color: var(--green); }
button.ans.good:hover { background: rgba(76, 175, 125, 0.15); }
button.ans.easy { border-color: var(--orange); }
button.ans.easy:hover { background: rgba(224, 164, 76, 0.15); }

/* Stats screen */
#stats-content { display: flex; flex-direction: column; gap: 16px; }

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}
.stat-row + .stat-row { border-top: 1px solid var(--border); }

.bar {
    background: var(--surface-2);
    border-radius: 999px;
    height: 6px;
    flex: 1;
    margin: 0 12px;
    overflow: hidden;
}
.bar > div {
    background: var(--green);
    height: 100%;
    transition: width .3s;
}

footer {
    margin-top: 32px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}
kbd {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
}
