* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #10b981;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 16px;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

#app {
    height: 100vh;
    width: 100vw;
}

.screen {
    display: none;
    height: 100vh;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* ── ヘッダー ─────────────────────── */
.app-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 40px 24px 32px;
    text-align: center;
}

.app-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.85;
    margin-top: 6px;
}

/* ── グループ選択 ──────────────────── */
.group-select-main {
    flex: 1;
    padding: 24px 20px;
    overflow-y: auto;
}

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

.group-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.group-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    padding: 16px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
    text-align: left;
}

.group-btn:hover,
.group-btn:active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    box-shadow: var(--shadow-lg);
}

.group-number {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.group-count {
    font-size: 12px;
    color: var(--text-muted);
}

.score-btn {
    width: 76px;
    flex-shrink: 0;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.score-btn:hover,
.score-btn:active {
    border-color: var(--secondary);
    color: var(--secondary);
    background: rgba(16, 185, 129, 0.05);
}

/* ── モーダル ─────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 24px;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
}

.modal-stats {
    display: flex;
    gap: 12px;
}

.modal-stat {
    flex: 1;
    background: var(--bg);
    border-radius: 12px;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

/* ── カード画面 ───────────────────── */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.btn-back {
    background: none;
    border: none;
    font-size: 15px;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    font-weight: 600;
}

.card-progress {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.header-spacer {
    width: 60px;
}

.card-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
}

/* ── フリップカード ────────────────── */
.flash-card {
    perspective: 1200px;
    cursor: pointer;
    width: 100%;
    max-width: 480px;
    height: 280px;
    -webkit-tap-highlight-color: transparent;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.45s ease;
}

.flash-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    padding: 32px 28px;
    text-align: center;
}

.card-front {
    background: var(--surface);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.card-back {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: var(--shadow-lg);
    transform: rotateY(180deg);
}

.card-idiom {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 20px;
}

.card-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.card-meaning {
    font-size: 22px;
    font-weight: 700;
    color: white;
    line-height: 1.6;
}

/* ── フッター ─────────────────────── */
.card-footer {
    padding: 16px 20px 28px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

/* ── 完了画面 ─────────────────────── */
.done-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    gap: 20px;
}

.done-icon {
    font-size: 72px;
}

.done-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.done-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
    margin-top: 8px;
}

/* ── 汎用ボタン ───────────────────── */
.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #059669;
}

.answer-buttons {
    display: flex;
    gap: 12px;
}

.answer-buttons .btn {
    flex: 1;
}

.btn-correct {
    background: #16a34a;
    color: white;
}

.btn-correct:hover {
    background: #15803d;
}

.btn-incorrect {
    background: #dc2626;
    color: white;
}

.btn-incorrect:hover {
    background: #b91c1c;
}

.done-score {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}
