/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --red:     #e63946;
    --red-bg:  #fde8ea;
    --blue:    #1d6fa4;
    --blue-bg: #dceefb;
    --green:   #2a9d5c;
    --orange:  #d97706;
    --gray:    #6b7280;
    --bg:      #eef2f7;
    --card:    #ffffff;
    --text:    #1a202c;
    --radius:  16px;
    --shadow:  0 4px 24px rgba(0,0,0,.11);
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

/* ===== SCREENS ===== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ===== START SCREEN ===== */
.start-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.4rem 2rem;
    max-width: 520px;
    width: 94vw;
    text-align: center;
}
.start-icon { font-size: 3.5rem; margin-bottom: .4rem; }
h1 { font-size: 2rem; font-weight: 800; color: var(--text); margin-bottom: .2rem; }
.subtitle { color: var(--gray); font-size: 1.05rem; margin-bottom: 1.4rem; }

.rules-box {
    background: #f4f7ff;
    border-radius: 12px;
    padding: 1.1rem 1.3rem;
    text-align: left;
    margin-bottom: 1.5rem;
    border: 1px solid #dde4f5;
}
.rules-box h3 { font-size: .97rem; margin-bottom: .65rem; color: var(--text); }
.rules-box ul { padding-left: 1.2rem; }
.rules-box li { margin-bottom: .55rem; font-size: .93rem; line-height: 1.55; }
.rule-example { color: var(--gray); font-size: .86rem; }

.green-frame-preview {
    display: inline-block;
    border: 2px solid var(--green);
    border-radius: 4px;
    padding: 0 5px;
    color: var(--green);
    font-weight: 700;
    font-size: .86rem;
}

.keyboard-hint {
    margin-top: .85rem;
    font-size: .83rem;
    color: var(--gray);
    border-top: 1px solid #dde4f5;
    padding-top: .65rem;
}
kbd {
    background: #e2e8f0;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: monospace;
    font-size: .84em;
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: .9rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .14s, box-shadow .14s;
    box-shadow: 0 4px 16px rgba(102,126,234,.35);
    width: 100%;
    max-width: 280px;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102,126,234,.45); }

.btn-secondary {
    background: #fff;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 50px;
    padding: .75rem 1.8rem;
    font-size: .98rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
}
.btn-secondary:hover { background: #f0f2ff; }

/* ===== QUIZ HEADER ===== */
.quiz-header {
    width: 100%;
    background: var(--card);
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    padding: .55rem 1.2rem .45rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
.progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: .35rem;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 99px;
    transition: width .4s ease;
    width: 0%;
}
.quiz-meta { text-align: right; font-size: .83rem; color: var(--gray); font-weight: 700; }

/* ===== QUIZ MAIN ===== */
#screen-quiz.active {
    justify-content: flex-start;
    padding-bottom: 1rem;
}
.quiz-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.8rem 0.6rem;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

/* ===== SHAPE CONTAINER (BIGGER) ===== */
.shape-container {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 660px;
    /* Fixed height – big! */
    height: clamp(280px, 44vh, 400px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.1rem;
    overflow: hidden;
    padding: .5rem;
}
.shape-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== ANSWER BUTTONS ===== */
.answer-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .9rem;
    width: 100%;
    max-width: 660px;
    margin-bottom: .65rem;
}

.btn-answer {
    border: 3px solid transparent;
    border-radius: 14px;
    padding: 1rem .8rem;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s;
    min-height: 68px;
    line-height: 1.3;
    letter-spacing: .01em;
}
.btn-answer:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.16); }
.btn-answer:active { transform: translateY(0); }

.btn-answer.red  { background: var(--red-bg);  color: var(--red);  border-color: var(--red); }
.btn-answer.blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }

.btn-answer.selected-red  { background: var(--red);  color: #fff; border-color: var(--red);  box-shadow: 0 4px 16px rgba(230,57,70,.4); }
.btn-answer.selected-blue { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 0 4px 16px rgba(29,111,164,.4); }
.btn-answer.dimmed { opacity: .35; }

/* ===== SKIP BUTTON ===== */
.quiz-footer { width: 100%; max-width: 660px; display: flex; justify-content: flex-end; }
.btn-skip {
    background: none;
    border: 2px solid #c8d4e0;
    border-radius: 50px;
    padding: .45rem 1.3rem;
    font-size: .9rem;
    color: var(--gray);
    cursor: pointer;
    font-weight: 700;
    transition: border-color .15s, color .15s;
}
.btn-skip:hover { border-color: #667eea; color: #667eea; }

/* ===== RESULTS SCREEN ===== */
#screen-results {
    padding: 1.5rem 1rem;
    justify-content: flex-start;
    padding-top: 2rem;
}
.results-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.8rem 1.6rem;
    max-width: 600px;
    width: 94vw;
    text-align: center;
}
.results-card h2 { font-size: 1.5rem; margin-bottom: .4rem; font-weight: 800; }

.score-display {
    font-size: 4.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}
.score-label { color: var(--gray); font-size: .95rem; margin-bottom: 1.5rem; font-weight: 600; }

.solution-sequence { text-align: left; margin-bottom: 1.1rem; }
.solution-sequence h3 { font-size: .9rem; color: var(--text); margin-bottom: .45rem; font-weight: 700; }

.seq-row { display: flex; flex-wrap: wrap; gap: .38rem; }
.seq-cell {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .8rem;
    border: 3px solid transparent;
    position: relative;
    cursor: default;
}
.seq-cell .seq-num { font-size: .6rem; font-weight: 500; opacity: .75; margin-bottom: 1px; }
.seq-cell.red-cell  { background: var(--red);  color: #fff; }
.seq-cell.blue-cell { background: var(--blue); color: #fff; }
.seq-cell.skip-cell { background: #e2e8f0; color: var(--gray); }

/* Outcome borders on player cells */
.seq-cell.outcome-correct { border-color: var(--green); box-shadow: 0 0 0 2px var(--green); }
.seq-cell.outcome-also    { border-color: var(--orange); box-shadow: 0 0 0 2px var(--orange); }
.seq-cell.outcome-wrong   { border-color: #b91c1c; box-shadow: 0 0 0 2px #b91c1c; opacity: .65; }
.seq-cell.outcome-skip    { border-color: #9ca3af; }

.result-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem .9rem;
    justify-content: center;
    margin-bottom: 1.3rem;
    font-size: .8rem;
}
.legend-item { padding: .22rem .6rem; border-radius: 20px; font-weight: 700; }
.legend-item.correct { background: #d1fae5; color: #065f46; }
.legend-item.also-ok { background: #fef3c7; color: #92400e; }
.legend-item.wrong   { background: #fee2e2; color: #991b1b; }
.legend-item.skipped { background: #f1f5f9; color: var(--gray); }

.results-actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; margin-top: .4rem; }

/* ===== REVIEW SCREEN ===== */
#screen-review {
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
}
.review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    padding: .75rem 1.2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    position: sticky;
    top: 0;
    z-index: 10;
}
.review-header h2 { font-size: 1.05rem; font-weight: 800; }
.review-header span { color: var(--gray); font-size: .88rem; font-weight: 700; }
.btn-back {
    background: none;
    border: none;
    color: #667eea;
    font-weight: 700;
    font-size: .92rem;
    cursor: pointer;
    padding: .25rem .4rem;
}

.review-nav-dots {
    display: flex;
    justify-content: center;
    gap: .32rem;
    padding: .6rem 1rem;
    background: #f4f7ff;
    border-bottom: 1px solid #dde4f5;
    flex-wrap: wrap;
}
.nav-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: .66rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border: 2.5px solid transparent;
    transition: transform .1s;
}
.nav-dot:hover { transform: scale(1.25); }
.nav-dot.active-dot { border-color: #1a202c; transform: scale(1.2); }
.nav-dot.red-dot  { background: var(--red); }
.nav-dot.blue-dot { background: var(--blue); }
.nav-dot.skip-dot { background: var(--gray); }

.review-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem .8rem .8rem;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

/* Review shape – also big */
.review-shape {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 620px;
    height: clamp(240px, 40vh, 360px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: .5rem;
    margin-bottom: 1rem;
}
.review-shape svg { width: 100%; height: 100%; display: block; }

.review-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    width: 100%;
    max-width: 620px;
    margin-bottom: .85rem;
}

.review-option-btn {
    border-radius: 14px;
    padding: .85rem .8rem;
    font-size: 1.02rem;
    font-weight: 800;
    text-align: center;
    border: 3px solid transparent;
    min-height: 62px;
    line-height: 1.3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .22rem;
}
/* Default colour matching the button colour */
.review-option-btn.red  { background: var(--red-bg);  color: var(--red);  border-color: var(--red); }
.review-option-btn.blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }

/* ✓ THE correct (narrowest) answer */
.review-option-btn.is-correct {
    background: #d1fae5;
    border-color: var(--green);
    color: #065f46;
}
.review-option-btn.is-correct .badge-correct { display: inline; }

/* ≈ also acceptable (superset) */
.review-option-btn.is-also-correct {
    border-color: var(--orange);
    background: #fef3c7;
    color: #92400e;
}
.review-option-btn.is-also-correct .badge-also { display: inline; }

/* Suffix badges */
.badge-correct, .badge-also { display: none; font-size: .8rem; margin-left: 3px; }

.player-badge {
    font-size: .7rem;
    font-weight: 700;
    background: rgba(0,0,0,.12);
    border-radius: 20px;
    padding: 1px 8px;
    margin-top: 3px;
    white-space: nowrap;
}

.review-verdict {
    font-size: .93rem;
    font-weight: 700;
    padding: .6rem 1.1rem;
    border-radius: 10px;
    text-align: center;
    max-width: 620px;
    width: 100%;
    line-height: 1.5;
}
.verdict-correct { background: #d1fae5; color: #065f46; }
.verdict-also    { background: #fef3c7; color: #92400e; }
.verdict-wrong   { background: #fee2e2; color: #991b1b; }
.verdict-skip    { background: #f1f5f9; color: var(--gray); }

.review-footer {
    display: flex;
    justify-content: space-between;
    padding: .75rem 1rem;
    background: var(--card);
    border-top: 1px solid #e2e8f0;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    position: sticky;
    bottom: 0;
}
.btn-nav {
    background: #fff;
    border: 2px solid #c8d4e0;
    border-radius: 50px;
    padding: .55rem 1.4rem;
    font-size: .93rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text);
    transition: border-color .15s, color .15s;
}
.btn-nav:hover { border-color: #667eea; color: #667eea; }
.btn-nav:disabled { opacity: .3; cursor: default; pointer-events: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    h1 { font-size: 1.6rem; }
    .btn-answer { font-size: .95rem; padding: .85rem .5rem; min-height: 60px; }
    .shape-container { height: clamp(220px, 38vw, 280px); }
    .review-shape    { height: clamp(200px, 36vw, 260px); }
    .score-display   { font-size: 3.2rem; }
    .seq-cell        { width: 38px; height: 38px; font-size: .72rem; }
    .review-option-btn { font-size: .9rem; }
}
