* {
    box-sizing: border-box;
}

:root {
    --cream: #fff4dc;
    --cream-deep: #f3dfb8;
    --chalk: #315f44;
    --chalk-line: rgba(255, 255, 255, 0.34);
    --wood: #b77a45;
    --wood-dark: #7c4a2b;
    --wood-light: #d9a269;
    --paper: #fff9ed;
    --ink: #3b2a1d;
    --muted: #846f5a;
    --green: #6c9b60;
    --warning: #9c4d2f;
    --shadow: 0 22px 55px rgba(86, 57, 24, 0.18);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.85), transparent 22rem),
        linear-gradient(180deg, #fff8e9, var(--cream));
    font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.site-header,
.classroom-app {
    width: min(1440px, calc(100% - 40px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 14px 0;
    backdrop-filter: blur(18px);
}

.site-header::before {
    position: fixed;
    inset: 0 0 auto;
    z-index: -1;
    height: 68px;
    content: "";
    background: rgba(255, 248, 233, 0.86);
    border-bottom: 1px solid rgba(126, 88, 47, 0.14);
}

.brand,
.site-nav {
    display: inline-flex;
    align-items: center;
}

.brand {
    gap: 0.75rem;
    font-weight: 900;
    white-space: nowrap;
}

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: #fffdf7;
    background: var(--chalk);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(49, 95, 68, 0.18);
}

.brand-name {
    font-size: 1.02rem;
}

.site-nav {
    gap: 0.2rem;
    padding: 5px;
    color: var(--muted);
    background: rgba(255, 249, 237, 0.82);
    border: 1px solid rgba(126, 88, 47, 0.18);
    border-radius: 999px;
}

.site-nav a {
    padding: 0.62rem 0.78rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a[aria-current="page"] {
    color: #fffdf7;
    background: var(--chalk);
    outline: 0;
}

.classroom-app {
    display: grid;
    grid-template-columns: minmax(780px, 1fr) 340px;
    gap: 24px;
    min-height: 100vh;
    padding: 24px 0;
}

/* Classroom header */

.classroom-stage {
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 18px;
    min-height: 900px;
    padding: 24px 28px 30px;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(238, 210, 158, 0.25) 1px, transparent 1px),
        linear-gradient(rgba(238, 210, 158, 0.25) 1px, transparent 1px),
        #fff5df;
    background-size: 34px 34px;
    border: 2px solid rgba(126, 88, 47, 0.16);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.classroom-board {
    display: grid;
    min-height: 126px;
    place-items: center;
    padding: 18px 32px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 35%),
        var(--chalk);
    border: 10px solid #926440;
    border-radius: 8px;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.06), 0 12px 0 rgba(124, 74, 43, 0.22);
}

.classroom-title-input {
    width: min(920px, 100%);
    color: #fbfff4;
    background: transparent;
    border: 0;
    outline: 0;
    text-align: center;
    font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
    font-size: clamp(34px, 4vw, 58px);
    font-weight: 900;
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

/* Teacher desk and character */

.teacher-zone {
    display: grid;
    justify-items: center;
    gap: 0;
    min-height: 136px;
}

.classroom-character {
    position: relative;
    width: 96px;
    height: 78px;
    margin-bottom: -18px;
    z-index: 2;
}

.character-ear {
    position: absolute;
    top: 3px;
    width: 34px;
    height: 34px;
    background: #d99b66;
    border: 4px solid #74442d;
    border-radius: 50%;
}

.character-ear.left {
    left: 8px;
}

.character-ear.right {
    right: 8px;
}

.character-face {
    position: absolute;
    left: 11px;
    bottom: 0;
    width: 74px;
    height: 66px;
    background: #e9b47a;
    border: 4px solid #74442d;
    border-radius: 42% 42% 48% 48%;
}

.character-eye,
.character-nose,
.character-mouth {
    position: absolute;
    display: block;
}

.character-eye {
    top: 25px;
    width: 8px;
    height: 10px;
    background: #3b2a1d;
    border-radius: 50%;
}

.character-eye.left {
    left: 20px;
}

.character-eye.right {
    right: 20px;
}

.character-nose {
    top: 34px;
    left: 30px;
    width: 14px;
    height: 10px;
    background: #6c3d28;
    border-radius: 50%;
}

.character-mouth {
    top: 46px;
    left: 28px;
    width: 18px;
    height: 8px;
    border-bottom: 3px solid #6c3d28;
    border-radius: 0 0 18px 18px;
}

.teacher-desk {
    display: grid;
    width: 270px;
    height: 84px;
    place-items: center;
    color: #3f2210;
    background: linear-gradient(180deg, #d9a269, #b9753d);
    border: 4px solid var(--wood-dark);
    border-radius: 8px;
    box-shadow: 0 10px 0 rgba(124, 74, 43, 0.32);
    font-size: 24px;
    font-weight: 900;
}

/* Seat cards */

.seat-area {
    display: grid;
    align-items: start;
    gap: clamp(22px, 3vw, 48px);
    width: 100%;
    padding: 16px 6px 24px;
}

.seat-group {
    display: grid;
    align-content: start;
    gap: 12px;
}

.seat-group-title {
    margin: 0;
    color: var(--muted);
    text-align: center;
    font-size: 16px;
    font-weight: 900;
}

.seat-grid {
    display: grid;
    gap: 14px;
}

.desk-card {
    position: relative;
    display: grid;
    min-width: 96px;
    min-height: 68px;
    place-items: center;
    padding: 10px;
    color: #3a2415;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 45%),
        linear-gradient(180deg, var(--wood-light), var(--wood));
    border: 3px solid var(--wood-dark);
    border-radius: 8px;
    box-shadow: 0 7px 0 rgba(124, 74, 43, 0.36), 0 14px 22px rgba(124, 74, 43, 0.16);
    font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
    font-size: clamp(16px, 1.4vw, 22px);
    font-weight: 900;
    text-align: center;
    cursor: grab;
    will-change: transform;
    transform-style: preserve-3d;
    transition: filter 0.25s ease, box-shadow 0.25s ease, opacity 0.2s ease, transform 0.2s ease;
}

.desk-card::before {
    position: absolute;
    top: 8px;
    left: 12px;
    width: 26px;
    height: 5px;
    content: "";
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
}

.desk-card.empty {
    color: rgba(58, 36, 21, 0.5);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 45%),
        #d4b08b;
    border-style: dashed;
}

.desk-card.dragging {
    cursor: grabbing;
    opacity: 0.58;
    transform: scale(0.98);
}

.desk-card.drop-target {
    filter: brightness(1.06);
    outline: 3px solid rgba(67, 111, 69, 0.65);
    outline-offset: 4px;
    transform: translateY(-3px);
}

/* Shuffle and reveal states */

.desk-card.shuffling {
    pointer-events: none;
    animation: cardShuffleMove var(--shuffle-duration, 700ms) cubic-bezier(0.22, 1, 0.36, 1) both;
    filter: brightness(1.06);
    box-shadow: 0 12px 0 rgba(124, 74, 43, 0.3), 0 26px 38px rgba(124, 74, 43, 0.25);
}

.desk-card.hidden {
    color: #fffdf7;
    background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0 7px, transparent 7px 14px),
        linear-gradient(180deg, #6c9b60, #436f45);
    border-color: #2f5636;
    box-shadow: 0 7px 0 #2f5636, 0 14px 22px rgba(67, 111, 69, 0.18);
    cursor: pointer;
    font-size: 30px;
}

.desk-card.hidden:hover {
    filter: brightness(1.07);
}

.desk-card.hidden.shuffling {
    cursor: wait;
    filter: brightness(1.12);
    box-shadow: 0 18px 0 rgba(47, 86, 54, 0.22), 0 30px 46px rgba(47, 86, 54, 0.28);
}

.desk-card.revealing {
    animation: cardRevealFlip 0.52s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.desk-card.revealed {
    filter: brightness(1.03);
}

@keyframes cardShuffleMove {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    18% {
        transform: translate(var(--shuffle-x), var(--shuffle-y)) rotate(var(--shuffle-rotate));
    }

    38% {
        transform: translate(var(--shuffle-x2), var(--shuffle-y2)) rotate(calc(var(--shuffle-rotate) * -0.75));
    }

    58% {
        transform: translate(calc(var(--shuffle-x) * -0.55), calc(var(--shuffle-y) * -0.55)) rotate(calc(var(--shuffle-rotate) * 0.55));
    }

    78% {
        transform: translate(calc(var(--shuffle-x2) * 0.35), calc(var(--shuffle-y2) * 0.35)) rotate(calc(var(--shuffle-rotate) * -0.25));
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

@keyframes cardRevealFlip {
    0% {
        transform: rotateY(0deg);
    }

    50% {
        transform: rotateY(90deg) scale(1.04);
    }

    100% {
        transform: rotateY(0deg);
    }
}

/* Desk name input */

.desk-name-input {
    width: 100%;
    min-width: 0;
    color: inherit;
    background: rgba(255, 249, 237, 0.5);
    border: 0;
    border-radius: 6px;
    outline: 0;
    padding: 6px 4px;
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    text-align: center;
    cursor: text;
}

.desk-name-input::placeholder {
    color: rgba(58, 36, 21, 0.48);
}

.desk-name-input:focus {
    background: #fff9ed;
    box-shadow: 0 0 0 3px rgba(255, 249, 237, 0.72);
}

/* Settings panel */

.classroom-panel {
    position: sticky;
    top: 20px;
    align-self: start;
    display: grid;
    gap: 16px;
    padding: 20px;
    background: rgba(255, 249, 237, 0.92);
    border: 2px solid rgba(126, 88, 47, 0.18);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel-heading p {
    margin: 0 0 6px;
    color: var(--green);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.panel-heading h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
}

.setting-field {
    display: grid;
    gap: 8px;
}

.hidden-setting {
    display: none;
}

.setting-field span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 900;
}

.setting-field input,
.setting-field textarea {
    width: 100%;
    color: var(--ink);
    background: #fffdf7;
    border: 2px solid rgba(126, 88, 47, 0.2);
    border-radius: 8px;
    outline: 0;
}

.setting-field input {
    height: 46px;
    padding: 0 12px;
}

.setting-field textarea {
    min-height: 220px;
    resize: vertical;
    padding: 12px;
    line-height: 1.55;
}

.setting-field input:focus,
.setting-field textarea:focus {
    border-color: rgba(108, 155, 96, 0.68);
    box-shadow: 0 0 0 4px rgba(108, 155, 96, 0.12);
}

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

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

.primary-button,
.secondary-button {
    min-height: 50px;
    border-radius: 8px;
    font-weight: 900;
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.primary-button {
    color: #fffdf7;
    background: var(--green);
    border: 0;
    box-shadow: 0 6px 0 #4f7748;
}

.secondary-button {
    color: var(--ink);
    background: #fffdf7;
    border: 2px solid rgba(126, 88, 47, 0.22);
}

.status-message {
    min-height: 56px;
    margin: 0;
    padding: 12px;
    color: var(--muted);
    background: rgba(108, 155, 96, 0.1);
    border: 1px solid rgba(108, 155, 96, 0.22);
    border-radius: 8px;
    line-height: 1.45;
}

.status-message.warning {
    color: var(--warning);
    background: rgba(156, 77, 47, 0.1);
    border-color: rgba(156, 77, 47, 0.26);
}

.seo-copy {
    display: grid;
    gap: 8px;
    padding-top: 4px;
}

.seo-copy h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.3;
}

.seo-copy p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

@media (max-width: 1180px) {
    .classroom-app {
        grid-template-columns: 1fr;
    }

    .classroom-panel {
        position: static;
    }
}

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

    .site-header::before {
        height: 120px;
    }

    .site-nav {
        width: 100%;
        overflow-x: auto;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    body {
        min-height: auto;
        background: #fff;
    }

    .classroom-app {
        display: block;
        width: 100%;
        min-height: auto;
        padding: 0;
    }

    .site-header,
    .classroom-panel {
        display: none;
    }

    .classroom-stage {
        min-height: auto;
        padding: 12mm;
        overflow: visible;
        border-color: rgba(126, 88, 47, 0.32);
        box-shadow: none;
        break-inside: avoid;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .classroom-title-input,
    .desk-name-input {
        background: transparent;
        border: 0;
        box-shadow: none;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .desk-card {
        min-width: 74px;
        min-height: 52px;
        box-shadow: none;
        break-inside: avoid;
    }

    .seat-area {
        gap: 18px;
        padding: 8px 0 0;
    }

    .seat-grid {
        gap: 8px;
    }

}
