* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--page-background);
    color: var(--page-text);
    font-family: "Candy", "Trebuchet MS", sans-serif;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.student-workspace {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 20px;
}

.student-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
    padding: 18px 22px;
    border-bottom: 4px solid #f08cb4;
    background: var(--surface);
    box-shadow: 0 3px 10px rgba(23, 50, 95, 0.14);
}

.student-header p,
.student-header h1 {
    margin: 0;
}

.student-header p {
    font-size: 1.1rem;
}

.student-header h1 {
    margin-top: 3px;
    font-family: "Cheese", "Trebuchet MS", sans-serif;
    font-size: 2.5rem;
    font-weight: 400;
}

.topic-container {
    margin-bottom: 24px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(23, 50, 95, 0.12);
}

.topic-directions {
    margin-bottom: 16px;
    font-size: 1.4rem;
    font-weight: 700;
}

.problem-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    justify-content: start;
    column-gap: 24px;
    row-gap: 18px;
}

.problem-card {
    position: relative;
    min-height: 115px;
    margin-inline: 8px;
    perspective: 1000px;
}

.problem-card.is-flippable {
    cursor: pointer;
    transition: transform 0.25s ease;
}

.problem-card.is-flippable:hover {
    transform: translateY(-3px);
}

.problem-card.is-flippable:hover .problem-face {
    box-shadow: 0 4px 12px rgba(23, 50, 95, 0.18);
}

.problem-card.is-flippable:focus-visible {
    outline: 3px solid #f08cb4;
    outline-offset: 3px;
}

.flip-star-badge {
    position: absolute;
    top: 8px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--star-badge, #0077ff);
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.problem-card.is-flippable:hover .flip-star-badge {
    opacity: 1;
    transform: scale(1.2) rotate(12deg);
    color: var(--star-badge-hover, #0056b3);
}

.problem-face {
    position: relative;
    min-height: 115px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-soft);
    backface-visibility: hidden;
    transition: transform 0.5s ease, box-shadow 0.25s ease;
    transform-style: preserve-3d;
}

.problem-card.is-flippable .problem-face-front {
    transform: rotateX(0deg);
}

.problem-face-back {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotateX(-180deg);
}

.problem-card.is-flipped .problem-face-front {
    transform: rotateX(180deg);
}

.problem-card.is-flipped .problem-face-back {
    transform: rotateX(0deg);
}

.problem-number {
    /* Layout */
    display: block;

    /* Box Model */
    /* margin-bottom: 10px; */
    margin-top: 5px;
    
    /* Fonts */
    font-family: "Apple", "Cheese", "Trebuchet MS", sans-serif;
    font-size: 1.25rem;
    font-weight: 400;

    /* Appearance */
    color: #49627f;
}

.problem-text,
.answer-text {
    text-align: center;
}

.problem-text {
    overflow-x: auto;
    font-size: calc(1.7rem * var(--problem-scale));
    margin-bottom: 20px;
}

.problem-text mjx-container[display="true"] {
    display: inline-block;
}

.answer-text {
    color: var(--answer-text);
    font-size: calc(1.7rem * var(--problem-scale));
}

.problem-face-back .answer-text {
    padding: 0 10px;
}

.error-message {
    padding: 30px;
    background: #ffffff;
    color: #8b2740;
    text-align: center;
}

@media print {
    body {
        background: #ffffff;
    }

    .student-workspace {
        max-width: none;
        padding: 0;
    }

    .student-header,
    .topic-container {
        box-shadow: none;
    }

}

@media (max-width: 760px) {
    .student-header { align-items: stretch; flex-direction: column; }
}