.foxwell-page {
    padding-bottom: 4rem;
}

.foxwell-hero {
    padding: 1.5rem 0 0;
}

.foxwell-hero-inner {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
    gap: 1.5rem;
    align-items: center;
}

.foxwell-copy p {
    max-width: 60ch;
    color: var(--muted);
}

.foxwell-hero-card,
.foxwell-card {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(214, 227, 239, 0.95);
    border-radius: 28px;
    box-shadow: 0 18px 36px rgba(23, 38, 60, 0.08);
}

.foxwell-hero-card {
    padding: 1rem;
}

.foxwell-hero-image {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
}

.foxwell-lab {
    margin-top: 1.75rem;
}

.foxwell-card {
    padding: 1.5rem;
}

.problem-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.problem-buttons,
.tool-buttons,
.foxwell-hero-actions,
.answer-row,
.foxwell-bubble-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tool-button {
    min-height: 44px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--primary-dark);
    font-weight: 800;
    cursor: pointer;
}

.tool-button.is-active {
    background: linear-gradient(135deg, #4d95cd, #377ab5);
    border-color: transparent;
    color: #fff;
}

.problem-status {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.problem-status p {
    margin: 0;
    color: var(--muted);
}

.problem-pill {
    display: inline-flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.85rem 1rem;
    border-radius: 18px;
    background: #f5f9fe;
    border: 1px solid var(--border);
}

.problem-pill-label,
.answer-help {
    color: var(--muted);
}

.problem-pill-label {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.workspace-shell {
    display: flex;
    justify-content: center;
}

.workspace-board {
    position: relative;
    width: min(100%, 960px);
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border-radius: 24px;
    border: 2px solid #cfe0f0;
    background-color: #fff;
    background-image:
        linear-gradient(to right, rgba(61, 116, 176, 0.15) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(61, 116, 176, 0.15) 1px, transparent 1px);
    background-size: 32px 32px;
    touch-action: none;
}

.workspace-grid,
.shape-layer,
.text-layer,
.draw-layer {
    position: absolute;
    inset: 0;
}

.shape-layer {
    pointer-events: none;
}

.triangle-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.triangle-line {
    fill: rgba(85, 155, 231, 0.12);
    stroke: #2d6cab;
    stroke-width: 4;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.triangle-right-angle {
    fill: rgba(255, 255, 255, 0.95);
    stroke: #2d6cab;
    stroke-width: 3;
}

.triangle-side-label {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 32px;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(45, 108, 171, 0.25);
    color: #204e7f;
    font-weight: 800;
    font-size: 0.98rem;
    box-shadow: 0 10px 18px rgba(23, 38, 60, 0.08);
}

.draw-layer {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.text-layer {
    pointer-events: none;
}

.board-text {
    position: absolute;
    min-width: 56px;
    min-height: 28px;
    padding: 0.2rem 0.35rem;
    border: 2px dashed transparent;
    color: #111;
    font: 700 1rem/1.25 Arial, Helvetica, sans-serif;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 8px;
    pointer-events: auto;
    outline: none;
    white-space: pre-wrap;
}

.board-text:focus {
    border-color: rgba(53, 121, 184, 0.45);
    background: rgba(255, 255, 255, 0.92);
}

.answer-panel {
    max-width: 560px;
    margin: 1.5rem auto 0;
    text-align: center;
}

.answer-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    color: var(--primary-dark);
    font-weight: 800;
}

.answer-row {
    justify-content: center;
}

.answer-input {
    min-width: min(100%, 320px);
    min-height: 52px;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    font: inherit;
    color: var(--text);
}

.foxwell-modal {
    position: fixed;
    inset: 0;
    z-index: 600;
}

.foxwell-overlay {
    position: absolute;
    inset: 0;
    background: rgba(14, 26, 41, 0.58);
}

.foxwell-dialog {
    position: relative;
    z-index: 1;
    width: min(92vw, 940px);
    margin: min(8vh, 3rem) auto 0;
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 1rem;
    align-items: end;
}

.foxwell-character,
.foxwell-bubble {
    position: relative;
}

.foxwell-character {
    display: flex;
    align-items: end;
    justify-content: center;
    min-height: 360px;
}

.foxwell-character-image {
    width: 100%;
    max-width: 300px;
    transform-origin: center bottom;
}

.foxwell-character[data-state="happy"] .foxwell-character-image {
    animation: foxwell-bounce 1.3s ease-in-out infinite;
}

.foxwell-character[data-state="sad"] .foxwell-character-image {
    filter: saturate(0.72) brightness(0.92);
    animation: foxwell-sad 2.4s ease-in-out infinite;
}

.foxwell-character[data-state="sad"] .foxwell-rock {
    position: absolute;
    bottom: 26px;
    width: 46px;
    height: 18px;
    border-radius: 999px;
    background: #8c95a2;
    transform: translateX(84px);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.foxwell-bubble {
    padding: 1.75rem;
    background: #fff;
    border-radius: 28px;
    box-shadow: 0 24px 42px rgba(14, 26, 41, 0.14);
}

.foxwell-bubble::before {
    content: "";
    position: absolute;
    left: -18px;
    bottom: 44px;
    border-width: 18px 18px 18px 0;
    border-style: solid;
    border-color: transparent #fff transparent transparent;
}

.foxwell-bubble h2,
.foxwell-bubble p {
    margin-top: 0;
}

@keyframes foxwell-bounce {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    35% {
        transform: translateY(-18px) rotate(-2deg);
    }
    65% {
        transform: translateY(0) rotate(1.5deg);
    }
}

@keyframes foxwell-sad {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translate(-4px, 2px) rotate(-3deg);
    }
    50% {
        transform: translate(5px, 0) rotate(2deg);
    }
    75% {
        transform: translate(-3px, 2px) rotate(-2deg);
    }
}

@media (max-width: 960px) {
    .foxwell-hero-inner,
    .foxwell-dialog {
        grid-template-columns: 1fr;
    }

    .foxwell-hero-card,
    .foxwell-character {
        max-width: 340px;
        margin: 0 auto;
    }

    .foxwell-bubble::before {
        left: 50%;
        top: -18px;
        bottom: auto;
        transform: translateX(-50%) rotate(90deg);
    }
}

@media (max-width: 640px) {
    .foxwell-card {
        padding: 1rem;
    }

    .problem-toolbar {
        flex-direction: column;
    }

    .problem-buttons,
    .tool-buttons,
    .answer-row {
        flex-direction: column;
    }

    .button,
    .tool-button,
    .answer-input {
        width: 100%;
    }

    .triangle-side-label {
        min-width: 48px;
        font-size: 0.88rem;
    }
}
