:root {
    --dark-bg: #202126;
    --panel-bg: #2b2d33;
    --option-bg: #383a41;
    --text: #d7d8dc;
    --text-strong: #f3f4f6;
    --muted: #9699a2;
    --blue: #0969e8;
    --blue-soft: #145bc7;
    --green: #8be38a;
    --green-text: #15321a;
    --red: #ff9ca5;
    --red-text: #3d1116;
    --divider: #3b3d44;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: Arial, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    background: var(--dark-bg);
    color: var(--text);
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
    width: 100%;
    max-width: 680px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 12px 14px 10px;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
}

h1 {
    margin: 0;
    color: var(--text-strong);
    font-size: 18px;
    line-height: 1.25;
    letter-spacing: .02em;
    font-weight: 700;
}

.mode-label {
    flex: 0 0 auto;
    white-space: nowrap;
}

.timer-label {
    display: inline-block;
    font-size: 26px;
    line-height: 1;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

#timer {
    color: #4caf50;
}

#timer.warning { color: #ffc107; }
#timer.critical { color: #ff9800; }
#timer.expired { color: #e65252; }

.progress-area {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 13px 0 19px;
}

.progress-track {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
}

.progress-segment {
    height: 4px;
    border-radius: 3px;
    background: #393b42;
    transition: background .18s ease;
}

.progress-segment.current { background: var(--blue); }
.progress-segment.correct { background: var(--green); }
.progress-segment.wrong { background: #f06d78; }

.progress-label {
    min-width: 29px;
    color: var(--text-strong);
    font-size: 13px;
    text-align: right;
    white-space: nowrap;
}

.question-panel {
    display: block;
    margin-bottom: 20px;
}

.question-text {
    color: var(--text-strong);
    font-size: 18px;
    line-height: 1.5;
    font-weight: 700;
}

/* E/V/M iPhone alarm-style wheel picker */
.answer-options {
    display: block;
}

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

.roller-card {
    min-width: 0;
    text-align: center;
}

.roller-title {
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.roller {
    height: 126px;
    position: relative;
    overflow: hidden;
    border-radius: 13px;
    background: #303238;
    cursor: ns-resize;
    touch-action: none;
    outline: none;
}

.roller::before, .roller::after {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    height: 1px;
    background: #565962;
    z-index: 3;
}
.roller::before { top: 42px; }
.roller::after { top: 84px; }

.roller-window {
    position: absolute;
    inset: 0;
}

.roller-track {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    transition: transform .13s cubic-bezier(.2,.8,.2,1);
}

.roller-item {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #777a83;
    font-size: 21px;
    font-weight: 500;
    transition: color .12s ease, font-size .12s ease, opacity .12s ease;
    user-select: none;
}
.roller-item.selected {
    color: var(--text-strong);
    font-size: 27px;
    font-weight: 700;
}
.roller.locked {
    cursor: default;
    opacity: .72;
}
.roller.locked .roller-item {
    pointer-events: none;
}
.answer-locked .nt-btn,
.answer-locked #totalInput {
    opacity: .62;
    cursor: default;
}
.nt-reminder {
    margin-top: 5px;
    color: #d6d7dc;
    font-size: 12px;
    line-height: 1.35;
}

.nt-btn {
    margin-top: 5px;
    border: 1px solid #555861;
    border-radius: 12px;
    background: transparent;
    color: #aeb0b7;
    min-width: 52px;
    height: 28px;
    cursor: pointer;
}
.nt-btn.active {
    background: #555861;
    color: var(--text-strong);
}

.total-entry {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.total-entry label {
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}
#totalInput {
    width: 96px;
    height: 42px;
    border: 1px solid #555861;
    border-radius: 10px;
    background: #303238;
    color: var(--text-strong);
    font-size: 20px;
    text-align: center;
    outline: none;
}
#totalInput:focus { border-color: var(--blue); }
#totalInput::placeholder { color: #777a83; font-size: 11px; }
.total-note { color: #85878e; font-size: 11px; }

.submit-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--blue);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}
.submit-btn:disabled { opacity: .42; cursor: default; }

.result-panel {
    min-height: 0;
    margin-top: 4px;
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
    overflow: visible;
    padding-right: 0;
}

.result-title {
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 700;
}

.result-detail { margin-top: 6px; }

.answer-detail {
    font-size: 18px;
    line-height: 1.7;
    color: var(--text-strong);
}

.answer-detail strong { font-size: 21px; }

.retry-message {
    font-size: 16px;
    line-height: 1.4;
}

.analysis-block {
    margin-top: 5px;
    color: #c8cad0;
    overflow: visible;
    padding-right: 0;
    font-size: 12px;
    line-height: 1.35;
}

.wrong-answer {
    color: #ff6f7b;
    font-weight: 700;
}

.wrong-feedback {
    margin-top: 6px;
    line-height: 1.55;
}

.total-error {
    display: block;
    margin-top: 4px;
}

.analysis-line {
    display: block;
    white-space: normal;
    line-height: 1.45;
}

.next-btn {
    align-self: flex-end;
    margin-top: auto;
    min-width: 92px;
    height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 23px;
    background: var(--blue);
    color: white;
    font-size: 15px;
    cursor: pointer;
}

.next-btn:hover:not(:disabled) { background: var(--blue-soft); }
.next-btn:disabled { opacity: .42; cursor: default; }

.footer {
    margin-top: 7px;
    text-align: center;
    color: #70737b;
    font-size: 10px;
    line-height: 1.35;
}

.programby { margin-bottom: 2px; }
.programby a { color: #85878e; text-decoration: none; }
.programby a:hover { color: var(--text); text-decoration: underline; }

@media (max-width: 520px) {
    .app-shell { padding: 10px 12px 8px; }
    h1 { font-size: 16px; }
    .question-text { font-size: 16px; line-height: 1.48; }
    .question-panel { margin-bottom: 15px; }
    .roller-grid { gap: 6px; }
    .roller { height: 126px; }
    .roller-item { font-size: 20px; }
    .roller-item.selected { font-size: 26px; }
    .total-entry { gap: 6px; }
    .total-note { font-size: 10px; }
    .answer-detail { font-size: 17px; }
    .answer-detail strong { font-size: 20px; }
    .retry-message { font-size: 15px; }
    .timer-label { font-size: 26px; }
    .next-btn { height: 42px; min-width: 88px; }
}

@media (max-height: 620px) {
    .app-shell { padding-top: 8px; padding-bottom: 6px; }
    .progress-area { margin-top: 8px; margin-bottom: 12px; }
    .question-panel { margin-bottom: 12px; }
    .question-text { font-size: 16px; line-height: 1.4; }
    .roller { height: 112px; }
    .roller::before { top: 37px; }
    .roller::after { top: 74px; }
    .roller-item { height: 37px; }
    .total-entry { margin-top: 7px; }
    .submit-btn { margin-top: 6px; height: 40px; }
    .footer { display: none; }
}
