@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    --page: #f7f9fc;
    --surface: #ffffff;
    --surface-soft: #edf7f3;
    --surface-warm: #fff5e8;
    --line: #d8e3ea;
    --text: #13202b;
    --muted: #647481;
    --blue: #2563eb;
    --teal: #0f9f8f;
    --green: #16a34a;
    --orange: #f59e0b;
    --red: #e11d48;
    --ink: #1f2937;
    --shadow: 0 18px 45px rgba(32, 52, 71, 0.12);
    --font-sans: 'Noto Sans KR', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: linear-gradient(180deg, #f8fbff 0%, #edf7f3 52%, #fff8ed 100%);
    color: var(--text);
    font-family: var(--font-sans);
    min-height: 100vh;
    padding: 24px;
    overflow-x: hidden;
}

button, select, input {
    font: inherit;
}

.dashboard-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.hero {
    min-height: 250px;
    background: linear-gradient(135deg, #123047 0%, #0f766e 54%, #f59e0b 140%);
    color: #ffffff;
    border-radius: 8px;
    padding: 32px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
    align-items: end;
    box-shadow: var(--shadow);
}

.eyebrow {
    display: inline-flex;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0;
    color: #baf7ee;
    margin-bottom: 12px;
}

.hero h1 {
    font-size: 2.8rem;
    line-height: 1.08;
    letter-spacing: 0;
    margin-bottom: 16px;
}

.hero-lead {
    max-width: 760px;
    font-size: 1.12rem;
    line-height: 1.72;
    color: rgba(255, 255, 255, 0.92);
}

.hero-note {
    margin-top: 16px;
    font-weight: 700;
    color: #fff5c7;
}

.hero-side {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    backdrop-filter: blur(10px);
}

.side-label {
    font-size: 0.8rem;
    color: #c8fff6;
}

.hero-side strong {
    font-size: 1.25rem;
}

.hero-side span {
    color: rgba(255, 255, 255, 0.86);
    line-height: 1.55;
}

.learning-band {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.learning-card,
.panel,
.control-surface,
.bottom-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(32, 52, 71, 0.08);
}

.learning-card {
    padding: 18px;
}

.learning-card span {
    font-family: var(--font-mono);
    color: var(--teal);
    font-size: 0.78rem;
}

.learning-card h2 {
    margin: 8px 0;
    font-size: 1.1rem;
}

.learning-card p {
    color: var(--muted);
    line-height: 1.55;
}

.guide-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.guide-strip span {
    background: var(--ink);
    color: #ffffff;
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
    font-weight: 700;
}

.principle-panel,
.algorithm-principles {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
}

.principle-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 1.1fr);
    gap: 18px;
    align-items: stretch;
}

.section-kicker {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 8px;
    color: var(--teal);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.principle-copy h2,
.algorithm-principles h2 {
    margin-bottom: 10px;
    font-size: 1.35rem;
}

.principle-copy p,
.principle-grid p {
    color: var(--muted);
    line-height: 1.6;
}

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

.principle-steps article,
.principle-grid article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.principle-steps strong,
.principle-grid strong {
    display: block;
    margin-bottom: 8px;
    color: var(--ink);
}

.principle-steps span {
    color: var(--muted);
    line-height: 1.55;
}

.algorithm-principles {
    display: grid;
    gap: 14px;
}

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

.control-surface {
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}

.control-group,
.speed-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

select,
.btn {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 9px 12px;
}

select {
    min-width: 230px;
    max-width: 100%;
}

.btn {
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: var(--teal);
    box-shadow: 0 8px 18px rgba(15, 159, 143, 0.18);
}

.btn-primary {
    background: var(--blue);
    color: #ffffff;
    border-color: var(--blue);
}

.btn-primary:hover {
    border-color: var(--blue);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.24);
}

.speed-control {
    min-width: 160px;
}

.speed-control input[type="range"] {
    width: 150px;
    accent-color: var(--teal);
}

#speed-display {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.panels-grid {
    display: grid;
    grid-template-columns: minmax(760px, 1fr) 340px;
    gap: 18px;
    align-items: stretch;
}

.panel {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    overflow: hidden;
}

.panel-header {
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.panel-title {
    font-size: 1.15rem;
    line-height: 1.35;
}

.panel-subtitle {
    margin-top: 5px;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.9rem;
}

.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 470px;
    overflow: auto;
    background: #f3f8fb;
    border: 1px solid #dbe7ee;
    border-radius: 8px;
    padding: 16px;
}

.grid-pathfind {
    display: grid;
    min-width: max-content;
    background: #cbd7df;
    padding: 2px;
    border-radius: 8px;
    border: 1px solid #b9c8d2;
    user-select: none;
}

.node {
    width: 19px;
    height: 19px;
    background: #ffffff;
    border: 1px solid #e1ebf0;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.1s ease;
}

.node-start {
    background: radial-gradient(circle, #4ade80 22%, var(--green) 72%);
    border-radius: 50%;
    border-color: #15803d;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.16);
    transform: scale(0.88);
}

.node-end {
    background: radial-gradient(circle, #fb7185 22%, var(--red) 72%);
    border-radius: 50%;
    border-color: #be123c;
    box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.16);
    transform: scale(0.88);
}

.node-wall {
    background: linear-gradient(135deg, #34495e 0%, #1f2937 100%);
    border-color: #17202a;
    animation: wall-bounce 0.15s ease-out;
}

@keyframes wall-bounce {
    0% { transform: scale(0.5); }
    100% { transform: scale(1); }
}

.node-visited {
    animation: visitedAnimation 0.75s ease-out 0s 1 alternate forwards;
}

@keyframes visitedAnimation {
    0% { transform: scale(0.35); background-color: #dff8ff; border-radius: 100%; }
    60% { background-color: #65e1d2; }
    100% { transform: scale(1); background-color: #bdf2ec; border-color: #78d8cd; }
}

.node-shortest-path {
    animation: shortestPathAnimation 0.55s ease-in-out 0s 1 alternate forwards;
}

@keyframes shortestPathAnimation {
    0% { transform: scale(0.6); background-color: #fde68a; border-radius: 50%; }
    100% { transform: scale(1); background-color: var(--orange); border-color: #b45309; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18); }
}

.sub-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.parent-note {
    background: var(--surface-soft);
}

.student-note {
    background: var(--surface-warm);
}

.sub-card-title {
    font-size: 0.84rem;
    font-weight: 800;
    color: var(--ink);
}

.sub-card p {
    color: var(--muted);
    line-height: 1.58;
}

.legend-container,
.stats-grid {
    display: grid;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.92rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    flex: 0 0 auto;
}

.visited-swatch {
    background: #bdf2ec;
}

.path-swatch {
    background: var(--orange);
}

.stat-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 4px;
}

.stat-val {
    font-family: var(--font-mono);
    font-size: 1.12rem;
}

.stat-val.accent {
    color: var(--blue);
}

.bottom-panel {
    padding: 18px;
    display: grid;
    gap: 14px;
}

.channels-container {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 10px;
}

.channel-card {
    background: #f8fafc;
    border: 1px solid #e1e9ef;
    border-radius: 8px;
    padding: 9px;
    display: grid;
    gap: 7px;
}

.channel-title {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-preview-path {
    width: 100%;
    aspect-ratio: 1.5;
    background: #e6eef3;
    border-radius: 6px;
    display: grid;
    gap: 1px;
    padding: 2px;
    overflow: hidden;
    grid-auto-rows: minmax(0, 1fr);
}

.channel-pixel {
    aspect-ratio: 1;
    border-radius: 1px;
    min-width: 0;
    min-height: 0;
}

.pixel-active { background: #203447; }
.pixel-inactive { background: #d8e4eb; }
.pixel-glow-cyan { background: #20c7b4; }
.pixel-glow-yellow { background: #f59e0b; }
.pixel-glow-green { background: #16a34a; }
.pixel-glow-red { background: #e11d48; }

@media (max-width: 1100px) {
    .hero {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .learning-band,
    .guide-strip,
    .principle-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .principle-panel {
        grid-template-columns: 1fr;
    }

    .panels-grid {
        grid-template-columns: 1fr;
    }

    .channels-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 720px) {
    body {
        padding: 12px;
    }

    .hero {
        padding: 22px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .learning-band,
    .guide-strip,
    .principle-steps,
    .principle-grid {
        grid-template-columns: 1fr;
    }

    .control-surface {
        align-items: stretch;
    }

    .control-group,
    .speed-control,
    select,
    .btn {
        width: 100%;
    }

    .board-container {
        justify-content: center;
        min-height: 260px;
        padding: 10px;
    }

    .grid-pathfind {
        min-width: 0;
    }

    .node {
        width: 7px;
        height: 7px;
    }

    .channels-container {
        grid-template-columns: repeat(2, 1fr);
    }
}
