* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f1117; color: #e2e8f0; min-height: 100vh; font-size: 14px; line-height: 1.6; }
.header { background: linear-gradient(135deg, #1a1f2e, #16213e); padding: 22px 20px; text-align: center; border-bottom: 1px solid #2d3748; }
.header h1 { font-size: 1.5rem; font-weight: 700; color: #f6ad55; letter-spacing: 0.5px; }
.header .subtitle { font-size: 0.85rem; color: #718096; margin-top: 4px; }
.container { max-width: 760px; margin: 0 auto; padding: 18px 14px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 10px; font-size: 0.9rem; font-weight: 600; cursor: pointer; text-decoration: none; border: 1px solid #2d3748; background: #1a202c; color: #e2e8f0; transition: all 0.2s; }
.btn:hover:not(:disabled) { background: #2d3748; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #6b4423; border-color: #f6ad55; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #835530; }
.btn-secondary { background: #2c4a7c; border-color: #63b3ed; color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.card { background: #1a202c; border: 1px solid #2d3748; border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.card-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: #4a5568; margin-bottom: 12px; }
.muted { color: #718096; font-size: 0.9rem; }
.small { font-size: 0.78rem; }
.error { color: #fc8181; }
.stat-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; }

/* Take header */
.take-header { position: sticky; top: 0; background: #16213e; border-bottom: 1px solid #2d3748; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; z-index: 10; }
.take-meta .period { font-weight: 700; font-size: 0.95rem; }
.take-meta .sub { font-size: 0.78rem; color: #a0aec0; }
.timer { font-family: 'SF Mono', Monaco, monospace; font-size: 1.2rem; font-weight: 700; color: #f6ad55; padding: 4px 12px; background: #1a202c; border-radius: 8px; }
.timer.warn { color: #fc8181; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; padding: 6px; background: #1a202c; border: 1px solid #2d3748; border-radius: 12px; }
.tab { flex: 1; min-width: 140px; padding: 11px 12px; border-radius: 8px; background: transparent; border: none; color: #a0aec0; font-size: 0.85rem; font-weight: 600; cursor: pointer; text-align: center; transition: all 0.15s; font-family: inherit; }
.tab:hover { background: #2d3748; color: #e2e8f0; }
.tab.active { background: #6b4423; color: #fff; }
.tab .tab-score { display: block; font-size: 0.72rem; opacity: 0.85; margin-top: 2px; }

.score-bar { background: #2d1f4a; border-left: 3px solid #b794f4; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 0.9rem; color: #cbd5e0; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.score-bar b { color: #b794f4; }

/* Question cards */
.q-card { background: #1a202c; border: 1px solid #2d3748; border-radius: 12px; padding: 16px 18px; margin-bottom: 12px; }
.q-num { font-size: 0.72rem; color: #4a5568; text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 8px; font-weight: 700; }
.q-jp { font-size: 1.05rem; line-height: 1.7; margin-bottom: 6px; color: #e2e8f0; }
.q-jp .blank { display: inline-block; min-width: 80px; border-bottom: 2px dashed #f6ad55; color: #f6ad55; padding: 0 6px; text-align: center; font-weight: 600; }
.q-hint { font-size: 0.85rem; color: #a0aec0; font-style: italic; margin-bottom: 12px; }

.choices { display: flex; flex-direction: column; gap: 8px; }
.choice-btn { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 2px solid #2d3748; border-radius: 9px; cursor: pointer; background: #0f1117; color: #e2e8f0; font-size: 0.92rem; text-align: left; font-family: inherit; transition: all 0.12s; line-height: 1.5; }
.choice-btn:hover:not(:disabled) { border-color: #4a5568; background: #1a202c; }
.choice-btn:disabled { cursor: default; }
.choice-btn .letter { width: 26px; height: 26px; border-radius: 50%; background: #2d3748; color: #a0aec0; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.8rem; }
.choice-btn.is-correct { background: #1f3a26; border-color: #68d391; color: #9ae6b4; }
.choice-btn.is-correct .letter { background: #68d391; color: #0f1117; }
.choice-btn.is-wrong { background: #3a1f1f; border-color: #fc8181; color: #feb2b2; }
.choice-btn.is-wrong .letter { background: #fc8181; color: #0f1117; }

.fill-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fill-input { flex: 1; min-width: 160px; padding: 9px 12px; background: #0f1117; border: 2px solid #2d3748; border-radius: 8px; color: #e2e8f0; font-size: 0.95rem; font-family: inherit; }
.fill-input:focus { outline: none; border-color: #f6ad55; }
.fill-input:disabled { opacity: 0.7; }
.fill-input.is-correct { border-color: #68d391; background: #1f3a26; color: #9ae6b4; }
.fill-input.is-wrong { border-color: #fc8181; background: #3a1f1f; color: #feb2b2; }

.feedback { margin-top: 10px; padding: 10px 12px; border-radius: 7px; font-size: 0.85rem; line-height: 1.5; }
.feedback.ok { background: #1f3a26; color: #9ae6b4; border-left: 3px solid #68d391; }
.feedback.bad { background: #3a1f1f; color: #feb2b2; border-left: 3px solid #fc8181; }
.feedback b { color: inherit; }

/* Matching */
.match-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid #252d3a; }
.match-row:last-child { border-bottom: none; }
.match-sentence { font-size: 0.95rem; line-height: 1.55; color: #e2e8f0; }
.match-select { padding: 9px 11px; background: #0f1117; border: 2px solid #2d3748; border-radius: 8px; color: #e2e8f0; font-size: 0.88rem; font-family: inherit; }
.match-select:disabled { opacity: 0.85; }
.match-select.is-correct { border-color: #68d391; background: #1f3a26; color: #9ae6b4; }
.match-select.is-wrong { border-color: #fc8181; background: #3a1f1f; color: #feb2b2; }
.match-correct-note { grid-column: 1 / -1; font-size: 0.82rem; color: #9ae6b4; padding: 4px 0 6px; }

@media (max-width: 560px) {
  .match-row { grid-template-columns: 1fr; }
  .tab { min-width: calc(50% - 4px); }
}

/* Result page */
.summary { background: linear-gradient(135deg, #1a2535, #16213e); border-radius: 14px; padding: 22px; text-align: center; margin-bottom: 18px; border: 1px solid #2d3748; }
.summary .score-big { font-size: 2.6rem; font-weight: 800; color: #f6ad55; margin-bottom: 4px; }
.summary .pct { color: #a0aec0; font-size: 1rem; margin-bottom: 14px; }
.tab-scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.tab-score-card { background: rgba(255,255,255,0.04); border-radius: 8px; padding: 10px; text-align: center; font-size: 0.8rem; color: #a0aec0; }
.tab-score-card b { display: block; font-size: 1.15rem; color: #e2e8f0; margin-bottom: 2px; }

.attempt-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #252d3a; gap: 10px; }
.attempt-row:last-child { border-bottom: none; }
.attempt-date { font-weight: 600; color: #e2e8f0; }
.attempt-meta { font-size: 0.78rem; color: #718096; }
.attempt-score { font-weight: 700; }
.streak-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: #3d2a0a; color: #f6ad55; border-radius: 20px; font-size: 0.78rem; font-weight: 700; }
