/* Page defaults */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 32px 0;
    background-color: #f4f5f7;
    color: #283341;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}


/* Main container and original orange header */

.main {
    max-width: 85%;
    margin: 0 auto;
    overflow: hidden;
    border: 5px solid #ef790f;
    border-radius: 14px;
    background-color: #fffaf5;
    box-shadow: 0 12px 32px rgba(41, 48, 57, 0.1);
}

header {
    padding: 18px 12px;
    background-color: #ef790f;
    color: #ffffff;
    text-align: center;
}

header h1 {
    margin: 0;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 32px;
    letter-spacing: 1px;
}

header p {
    margin: 4px 0 0;
    font-size: 14px;
}


/* Original three-column grid: left, center, right */

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    gap: 18px;
    margin: 0;
    padding: 20px;
}

.col1,
.col2,
.col3 {
    min-width: 0;
    padding: 22px 16px;
    border: 1px solid #dce0e5;
    border-radius: 12px;
    background-color: #ffffff;
    text-align: center;
    box-shadow: 0 4px 12px rgba(41, 48, 57, 0.04);
}

h2 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.25;
}

.instructions {
    margin: 0 0 18px;
    color: #626c78;
    font-size: 14px;
}


/* Grade inputs: one field per row, just like the original */

.grade-inputs {
    display: grid;
    gap: 12px;
}

.grade-field,
.passing-field {
    width: 100%;
    max-width: 140px;
    margin: 0 auto;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #505b68;
    font-size: 13px;
    font-weight: bold;
}

input {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid #cdd3da;
    border-radius: 7px;
    background-color: #f8fafc;
    color: #283341;
    font: inherit;
    text-align: center;
}

input::placeholder {
    color: #8b94a0;
}

input:hover {
    border-color: #9da9b6;
}

input:focus-visible {
    outline: 3px solid #ffdbba;
    outline-offset: 2px;
    border-color: #d46200;
    background-color: #ffffff;
}


/* Results and buttons */

.average {
    margin: 22px auto 0;
    color: #1b7ec3;
    font-size: 64px;
    font-weight: bold;
    line-height: 1.1;
}

.score-caption {
    margin: 6px 0 24px;
    color: #75808c;
    font-size: 13px;
}

.buttons {
    display: grid;
    gap: 10px;
    max-width: 200px;
    margin: 0 auto;
}

button {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#calc {
    background-color: #1479be;
    color: #ffffff;
}

#calc:hover {
    background-color: #0c609a;
}

.reset-button {
    border-color: #dce0e5;
    background-color: #f5f7fa;
    color: #505b68;
    font-size: 13px;
}

.reset-button:hover {
    background-color: #e9edf2;
}

button:focus-visible {
    outline: 3px solid #ffc58e;
    outline-offset: 3px;
}

.result-box {
    margin-top: 24px;
    padding: 18px 8px;
    border-top: 1px solid #e6e9ed;
}

.result-box h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

#passfail {
    font-size: 24px;
    font-weight: bold;
    overflow-wrap: anywhere;
    line-height: 1.35;
}

#passfail.result-pass {
    padding: 20px 10px;
    border: 2px solid #8bdd9f;
    border-radius: 16px;
    background: linear-gradient(135deg, #effff1, #cef7d9);
    color: #137333;
    font-family: "Comic Sans MS", "Trebuchet MS", cursive;
    font-size: clamp(20px, 2.5vw, 34px);
    font-weight: 900;
    text-shadow: 1px 2px 0 #ffffff, 0 4px 10px #a8e7b6;
    box-shadow: 0 6px 18px rgba(19, 115, 51, 0.12);
    animation: pass-celebration 550ms ease-out;
}

#passfail.result-fail {
    padding: 20px 10px;
    border: 1px solid #d8bcbc;
    border-radius: 4px;
    background-color: #f1e8e8;
    color: #701f26;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(18px, 2vw, 26px);
    font-weight: normal;
}

@keyframes pass-celebration {
    0% { transform: translateY(8px) scale(0.95); opacity: 0; }
    65% { transform: translateY(-3px) scale(1.02); opacity: 1; }
    100% { transform: translateY(0) scale(1); }
}

.result-placeholder {
    margin: 0;
    color: #75808c;
    font-size: 13px;
}

#passfail:not(:empty) + .result-placeholder {
    display: none;
}


/* Passing-score helper text */

.score-presets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-width: 240px;
    margin: 18px auto 0;
}

.score-preset {
    min-width: 0;
    border-color: #edc6a4;
    background-color: #fff3e7;
    color: #83532b;
}

.score-preset:hover {
    background-color: #ffe1c4;
    border-color: #d46200;
}

.score-preset[aria-pressed="true"] {
    border-color: #a94800;
    background-color: #b95000;
    color: #ffffff;
}

.score-custom {
    grid-column: 1 / -1;
}

.score-custom span {
    display: block;
    font-size: 11px;
    font-weight: normal;
}

.help-text {
    margin: 20px 0 0;
    padding: 12px;
    border-radius: 8px;
    background-color: #fff3e7;
    color: #83532b;
    font-size: 13px;
}


/* Keep the same three columns on smaller screens */

@media (max-width: 700px) {
    body {
        padding: 16px 0;
    }

    .main {
        max-width: 96%;
    }

    .grid {
        gap: 8px;
        padding: 10px;
    }

    .col1,
    .col2,
    .col3 {
        padding: 16px 8px;
    }

    h2 {
        font-size: 18px;
    }

    .instructions,
    .help-text,
    .result-placeholder {
        font-size: 12px;
        overflow-wrap: anywhere;
    }

    button {
        padding: 10px 4px;
        font-size: 12px;
    }

    label {
        font-size: 11px;
    }

    input {
        padding: 8px 2px;
        font-size: 16px;
    }

    .average {
        font-size: 48px;
    }

    .help-text {
        padding: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #passfail.result-pass {
        animation: none;
    }

    button {
        transition: none;
    }
}
