:root {
    --page-bg: #f3f4f6;
    --card-bg: #ffffff;
    --card-muted: #f8f8f9;
    --border: #e5e7eb;
    --text-main: #1f2937;
    --text-soft: #6b7280;
    --header-bg: #161c27;
    --header-bg-2: #202938;
    --accent: #2b3444;
    --accent-2: #3b4658;
    --success-soft: #eef7f0;
    --warning-soft: #fdf7ea;
}
html, body { min-height: 100%; }
body {
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--text-main);
}
main { flex: 1 0 auto; }
.site-header {
    background: linear-gradient(135deg, var(--header-bg), var(--header-bg-2));
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.navbar-brand { letter-spacing: .02em; }
.teacher-header-nav { align-items: center; }
.teacher-link {
    color: rgba(255,255,255,.78);
    text-decoration: none;
    padding: .55rem .85rem;
    border-radius: 999px;
    font-size: .95rem;
    font-weight: 600;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.teacher-link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
    transform: translateY(-1px);
}
.teacher-link.active {
    color: #111827;
    background: #f3f4f6;
}
.header-role-label {
    color: rgba(255,255,255,.82);
    font-size: .95rem;
    font-weight: 600;
    padding: .55rem .85rem;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 999px;
}
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-2);
    --bs-btn-hover-border-color: var(--accent-2);
    --bs-btn-active-bg: var(--accent-2);
    --bs-btn-active-border-color: var(--accent-2);
}
.btn-register {
    color: #111827;
    font-weight: 600;
}
.hero,
.admin-card,
.module-box,
.task-box,
.achievement-chip,
.attempt-card,
.option-row,
.feature-card,
.metric-card,
.story-card,
.price-card,
.task-shell,
.task-stage,
.task-side,
.student-summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}
.hero,
.admin-card,
.module-box,
.task-box,
.achievement-chip,
.attempt-card,
.option-row,
.feature-card,
.metric-card,
.story-card,
.price-card,
.task-shell,
.task-stage,
.task-side,
.student-summary-card { padding: 1rem; }
.hero {
    padding: 1.7rem;
    background: linear-gradient(180deg, #ffffff 0%, #fbfbfc 100%);
}
.hero-glow::after,
.landing-pill,
.feature-icon { display: none !important; }
.metric-card,
.student-summary-card,
.module-box,
.task-box,
.option-row,
.attempt-card {
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.metric-card:hover,
.student-summary-card:hover,
.module-box:hover,
.task-box:hover,
.option-row:hover,
.attempt-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, .08);
    border-color: #d7dbe2;
}
.metric-card {
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}
.metric-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}
.metric-label,
.soft-label,
.table-meta,
.task-meta,
.text-soft {
    color: var(--text-soft);
}
.achievement-chip { background: #fbf7eb; }
.progress {
    height: 10px;
    background: #ebecef;
}
.progress-bar {
    background: linear-gradient(90deg, #2b3444, #4b5563);
}
.token-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: .42rem .78rem;
    background: var(--card-muted);
    border: 1px solid var(--border);
    font-weight: 600;
    margin: .15rem;
}
.footer {
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,.97);
    color: var(--text-soft);
}
.sticky-actions { position: sticky; top: 1rem; }
.alerts-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    width: min(360px, calc(100vw - 2rem));
}
.alerts-stack .alert { margin-bottom: .75rem; }
.table-clean {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #fafafa;
    --bs-table-hover-bg: #f6f7f8;
}
.table-clean thead th {
    background: #f7f7f8;
    color: #374151;
    font-size: .88rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom-width: 1px;
}
.table-clean td, .table-clean th { vertical-align: middle; }
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .38rem .72rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: .88rem;
    font-weight: 600;
}
.status-chip.active-state { background: var(--success-soft); }
.status-chip.blocked-state { background: #fdeeee; }
.student-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.task-shell {
    padding: 1.25rem;
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}
.task-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.task-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}
.task-badges .badge {
    background: #f5f5f6 !important;
    color: #374151 !important;
    border: 1px solid var(--border);
    font-weight: 600;
}
.task-stage {
    padding: 1.2rem;
    background: #fff;
}
.task-side {
    padding: 1rem;
    background: #fcfcfc;
}
.answer-card {
    position: relative;
    display: block;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: .9rem 1rem;
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.answer-card:hover {
    transform: translateY(-1px);
    border-color: #cfd5dd;
    box-shadow: 0 10px 20px rgba(15,23,42,.05);
    background: #fcfcfd;
}
.answer-card input { margin-right: .75rem; }
.task-form-panel textarea,
.task-form-panel select,
.task-form-panel .form-control,
.task-form-panel .form-select {
    border-radius: 14px;
    border-color: #d7dbe2;
}
.task-history-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: .9rem;
}
.module-card-link,
.task-card-link { text-decoration: none; color: inherit; }
.module-box .action-row,
.task-box .action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: auto;
}
.dashboard-panel {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 1rem;
}
@media (max-width: 1199px) {
    .dashboard-panel { grid-template-columns: 1fr; }
}
@media (max-width: 991px) {
    .navbar .btn { width: 100%; }
    .navbar .auth-actions { width: 100%; }
    .teacher-header-nav { width: 100%; }
    .teacher-link { width: 100%; border-radius: 14px; }
    .hero { padding: 1.25rem; }
}
@media (max-width: 767px) {
    .table-responsive { border-radius: 14px; overflow: hidden; }
    .btn { min-height: 44px; }
    .alerts-stack { left: 1rem; width: auto; }
    .task-shell,
    .task-stage,
    .task-side { padding: 1rem; }
}


.table-responsive {
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    display: block;
}
.table-responsive > .table {
    min-width: 860px;
}
.table-clean td,
.table-clean th {
    white-space: nowrap;
}
.table-clean td:last-child,
.table-clean th:last-child {
    white-space: nowrap;
}
.matching-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.matching-column {
    display: grid;
    gap: .75rem;
}
.matching-card {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 14px;
    padding: .95rem 1rem;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.matching-card:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(15,23,42,.06); }
.matching-card.active { border-color: #4b5563; box-shadow: 0 0 0 3px rgba(75,85,99,.12); }
.matching-card.paired { border-color: #10b981; background: #f0fdf4; }
.matching-summary { display: grid; gap: .5rem; }
.matching-line { padding: .75rem .9rem; border-radius: 12px; background: #f7f8fa; border: 1px solid var(--border); }
.fill-blank-input { max-width: 280px; }
.sentence-slots, .sentence-bank {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}
.sentence-slot, .sentence-word {
    border-radius: 14px;
    border: 1px dashed #cfd6de;
    background: #fff;
    min-width: 110px;
    padding: .85rem 1rem;
    transition: all .18s ease;
}
.sentence-slot.filled {
    border-style: solid;
    border-color: #9ca3af;
    background: #f9fafb;
}
.sentence-word {
    border-style: solid;
    border-color: var(--border);
    cursor: grab;
    font-weight: 600;
}
.sentence-word:hover, .sentence-slot:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(15,23,42,.05); }
.dialog-box { background: #fafafa; }
.dialog-thread { display: grid; gap: .75rem; }
.dialog-bubble {
    max-width: 90%;
    padding: .85rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
}
.teacher-bubble { background: #fff; }
.student-bubble { background: #f3f4f6; margin-left: auto; }
.dialog-speaker { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); margin-bottom: .25rem; }
.dialog-choices { display: grid; gap: .75rem; }
.dialog-choice-btn {
    text-align: left;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 14px;
    padding: .9rem 1rem;
}
.image-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.image-choice-card {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 1rem;
    display: grid;
    gap: .75rem;
    cursor: pointer;
}
.image-choice-card input { margin: 0; }
.image-choice-visual {
    min-height: 110px;
    border-radius: 14px;
    background: #f7f8fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    overflow: hidden;
}
.image-choice-visual img { width: 100%; height: 100%; object-fit: cover; }
.memory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: .85rem;
}
.memory-card {
    aspect-ratio: 1 / 1;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .75rem;
    font-weight: 700;
    font-size: 1rem;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.memory-card:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(15,23,42,.06); }
.memory-card.matched { background: #ecfdf5; border-color: #10b981; }
.memory-back { font-size: 1.8rem; color: #6b7280; }
.memory-face-visual { font-size: 2rem; }
.memory-face-visual img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.answer-card-check { display: flex; align-items: center; gap: .75rem; }
.order-list { display: grid; gap: .75rem; }
.order-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
}
.order-row-text { font-weight: 600; }
.order-row-actions { display: flex; gap: .5rem; }
@media (max-width: 767px) {
    .table-responsive > .table { min-width: 980px; }
    .matching-board { grid-template-columns: 1fr; }
    .sentence-slot, .sentence-word { width: 100%; min-width: 0; }
    .memory-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .order-row { align-items: flex-start; flex-direction: column; }
    .dialog-bubble { max-width: 100%; }
}


/* enhanced mini-dialog */
.dialog-layout { display:grid; grid-template-columns:minmax(0, 1.5fr) minmax(280px, .9fr); gap:1rem; align-items:start; }
.dialog-topline { display:flex; justify-content:space-between; gap:1rem; align-items:flex-start; margin-bottom:1rem; }
.dialog-scene { font-weight:700; color:var(--text-main); }
.dialog-state-badge { padding:.45rem .8rem; border-radius:999px; font-size:.82rem; font-weight:700; border:1px solid var(--border); background:#fff; color:var(--text-soft); }
.dialog-state-badge[data-tone='progress'] { background:#f8fafc; }
.dialog-state-badge[data-tone='success'] { background:#eef7f0; color:#166534; border-color:#d5ead9; }
.dialog-state-badge[data-tone='warning'] { background:#fff7ed; color:#9a3412; border-color:#fed7aa; }
.dialog-sidecard { background:linear-gradient(180deg, #ffffff, #fbfbfc); border:1px solid var(--border); border-radius:20px; padding:1rem; box-shadow:0 10px 24px rgba(15,23,42,.06); }
.dialog-path-pills { display:flex; flex-direction:column; gap:.55rem; min-height:64px; }
.dialog-path-pill { display:flex; gap:.65rem; align-items:flex-start; padding:.75rem .85rem; border-radius:16px; background:#f8f8f9; border:1px solid #eceef1; }
.dialog-path-index { width:1.6rem; height:1.6rem; border-radius:999px; background:#fff; border:1px solid var(--border); display:inline-flex; align-items:center; justify-content:center; font-size:.8rem; font-weight:700; flex:0 0 auto; }
.dialog-empty-note { color:var(--text-soft); font-size:.92rem; }
.dialog-progress-wrap { margin-top:1rem; }
.dialog-note { margin-top:1rem; color:var(--text-soft); font-size:.92rem; line-height:1.45; }
.dialog-thread { display:flex; flex-direction:column; gap:.8rem; max-height:560px; overflow:auto; padding-right:.25rem; }
.dialog-bubble { max-width:min(92%, 520px); padding:.9rem 1rem; border-radius:18px; border:1px solid var(--border); box-shadow:0 12px 20px rgba(15,23,42,.05); opacity:0; transform:translateY(8px) scale(.985); transition:opacity .24s ease, transform .24s ease; }
.dialog-bubble.visible { opacity:1; transform:translateY(0) scale(1); }
.dialog-bubble-enter { will-change:transform, opacity; }
.dialog-speaker-row { display:flex; justify-content:space-between; gap:.75rem; margin-bottom:.4rem; }
.dialog-speaker { font-size:.82rem; font-weight:700; text-transform:uppercase; letter-spacing:.03em; }
.dialog-bubble-meta { font-size:.78rem; color:var(--text-soft); }
.dialog-bubble.teacher-bubble { align-self:flex-start; background:#ffffff; }
.dialog-bubble.student-bubble { align-self:flex-end; background:#f6f7f9; }
.dialog-bubble.system-bubble { align-self:center; background:#fff7ed; border-color:#fed7aa; }
.dialog-choice-btn { width:100%; text-align:left; padding:1rem 1rem; border-radius:18px; border:1px solid var(--border); background:#ffffff; display:flex; flex-direction:column; gap:.35rem; transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease, background-color .18s ease; }
.dialog-choice-btn:hover { transform:translateY(-2px); box-shadow:0 14px 24px rgba(15,23,42,.08); border-color:#d1d5db; background:#fcfcfd; }
.dialog-choice-index { display:inline-flex; width:1.8rem; height:1.8rem; align-items:center; justify-content:center; border-radius:999px; border:1px solid var(--border); font-size:.82rem; font-weight:700; margin-bottom:.2rem; }
.dialog-choice-text { font-weight:700; color:var(--text-main); }
.dialog-choice-preview { font-size:.87rem; color:var(--text-soft); }

/* enhanced memory game */
.memory-toolbar { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:.75rem; }
.memory-stat { border:1px solid var(--border); border-radius:18px; padding:.85rem 1rem; background:linear-gradient(180deg,#fff,#fbfbfc); }
.memory-stat-label { display:block; font-size:.8rem; text-transform:uppercase; letter-spacing:.04em; color:var(--text-soft); margin-bottom:.25rem; }
.memory-stat-value { display:block; font-size:1.15rem; font-weight:800; color:var(--text-main); }
.memory-status-line { color:var(--text-soft); line-height:1.5; }
.memory-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(110px, 1fr)); gap:.85rem; }
.memory-card-shell { position:relative; height:140px; border:none; background:transparent; perspective:1200px; padding:0; }
.memory-card-inner { position:relative; width:100%; height:100%; transform-style:preserve-3d; transition:transform .55s cubic-bezier(.2,.8,.2,1); }
.memory-card-shell.is-open .memory-card-inner,
.memory-card-shell.is-matched .memory-card-inner { transform:rotateY(180deg); }
.memory-card-face { position:absolute; inset:0; border-radius:20px; backface-visibility:hidden; border:1px solid var(--border); box-shadow:0 14px 28px rgba(15,23,42,.07); overflow:hidden; }
.memory-card-front { transform:rotateY(180deg); background:linear-gradient(180deg,#ffffff,#fbfbfc); display:flex; flex-direction:column; justify-content:center; align-items:center; padding:.9rem; gap:.55rem; }
.memory-card-front.is-left { background:linear-gradient(180deg,#ffffff,#f8fafc); }
.memory-card-front.is-right { background:linear-gradient(180deg,#ffffff,#faf7ff); }
.memory-card-back { background:linear-gradient(135deg,#212938,#394355); color:#fff; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.2rem; }
.memory-back-mark { font-size:1.9rem; font-weight:800; line-height:1; }
.memory-back-text { font-size:.78rem; opacity:.78; letter-spacing:.08em; text-transform:uppercase; }
.memory-card-content { font-size:1.75rem; font-weight:700; text-align:center; display:flex; align-items:center; justify-content:center; flex:1 1 auto; width:100%; }
.memory-card-content img { max-width:100%; max-height:64px; object-fit:contain; }
.memory-card-caption { font-size:.86rem; font-weight:700; color:var(--text-main); text-align:center; line-height:1.3; }
.memory-card-shell.is-matched .memory-card-face { box-shadow:0 0 0 2px #d6ead9, 0 16px 28px rgba(34,197,94,.12); }

@media (max-width: 991px) {
  .dialog-layout { grid-template-columns:1fr; }
}
@media (max-width: 767px) {
  .memory-toolbar { grid-template-columns:1fr; }
  .memory-grid { grid-template-columns:repeat(2, minmax(0, 1fr)); gap:.7rem; }
  .memory-card-shell { height:122px; }
  .dialog-bubble { max-width:100%; }
  .dialog-choice-btn { padding:.9rem; }
}


.view-toggle .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.compact-row-item { display:flex; justify-content:space-between; gap:.75rem; padding:.3rem 0; border-bottom:1px dashed #eceef1; }
.compact-row-item:last-child { border-bottom:none; }
.compact-task-card { display:flex; flex-direction:column; }
.compact-topic-box { background:#fbfbfc; }
.constructor-card { border:1px solid var(--border); border-radius:16px; background:#fbfbfc; padding:1rem; }
.task-result-banner { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:1rem 1.15rem; border:1px solid var(--border); border-radius:16px; background:#fff; }
.task-result-banner.is-correct { background:#eef8f0; }
.task-result-banner.is-wrong { background:#fff8ea; }
.readonly-review { display:grid; gap:.75rem; }
.readonly-row { border:1px solid var(--border); border-radius:14px; padding:.85rem 1rem; background:#fff; }
.readonly-row.is-correct { background:#eef8f0; }
.readonly-row.is-wrong { background:#fff8ea; }
.answer-card.is-correct, .image-choice-card.is-correct { border-color:#4b9b67; background:#eef8f0; }
.answer-card.is-wrong, .image-choice-card.is-wrong { border-color:#d9a441; background:#fff8ea; }
.answer-state-label { margin-left:auto; font-size:.78rem; font-weight:700; color:#25603b; }
.answer-state-label.wrong { color:#9a6700; }
.matching-board { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1rem; }
.matching-column { display:grid; gap:.75rem; }
.matching-card { width:100%; text-align:left; border:1px solid var(--border); border-radius:14px; background:#fff; padding:.9rem 1rem; transition:.18s ease; }
.matching-card.selected { border-color:#7a8493; box-shadow:0 10px 20px rgba(15,23,42,.06); }
.fill-blank-input { max-width:280px; }
.sentence-slots, .sentence-bank { display:flex; flex-wrap:wrap; gap:.75rem; }
.sentence-slot, .sentence-word { border:1px dashed #ccd1d9; border-radius:14px; background:#fff; padding:.8rem 1rem; min-height:48px; }
.sentence-slot.filled { border-style:solid; }
.dialog-layout { display:grid; grid-template-columns:minmax(0,2fr) minmax(280px,1fr); gap:1rem; }
.dialog-box { border:1px solid var(--border); border-radius:16px; background:#fff; padding:1rem; }
.dialog-thread { display:grid; gap:.75rem; max-height:420px; overflow:auto; }
.dialog-bubble { max-width:92%; border-radius:16px; padding:.8rem 1rem; border:1px solid var(--border); background:#f7f8fa; }
.dialog-bubble.teacher-bubble { background:#fff; }
.dialog-bubble.student-bubble { background:#eef2f7; margin-left:auto; }
.dialog-bubble.system-bubble { background:#fff8ea; }
.dialog-speaker-row { display:flex; justify-content:space-between; gap:.75rem; font-size:.78rem; margin-bottom:.25rem; color:#6b7280; }
.dialog-state-badge { display:inline-flex; align-items:center; padding:.35rem .7rem; border-radius:999px; background:#eef2f7; font-size:.82rem; font-weight:700; }
.dialog-state-badge[data-tone='success'] { background:#eef8f0; color:#25603b; }
.dialog-state-badge[data-tone='warning'] { background:#fff4e0; color:#9a6700; }
.dialog-progress { height:10px; background:#eceef1; border-radius:999px; overflow:hidden; }
.dialog-progress-bar { height:100%; width:0; background:linear-gradient(90deg,#2b3444,#596477); transition:width .25s ease; }
.dialog-choice-btn { width:100%; display:flex; align-items:flex-start; gap:.85rem; text-align:left; border:1px solid var(--border); border-radius:14px; background:#fff; padding:.9rem 1rem; margin-bottom:.75rem; transition:.18s ease; }
.dialog-choice-btn:hover { transform:translateY(-1px); box-shadow:0 10px 20px rgba(15,23,42,.05); }
.dialog-choice-btn.is-disabled { opacity:.5; cursor:not-allowed; background:#f7f7f8; }
.dialog-choice-index, .dialog-path-index { flex:0 0 auto; width:26px; height:26px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; background:#eef2f7; font-size:.8rem; font-weight:700; }
.dialog-path-pills { display:grid; gap:.55rem; }
.dialog-path-pill { display:flex; gap:.65rem; align-items:flex-start; border:1px solid var(--border); border-radius:12px; background:#fff; padding:.7rem .8rem; }
.dialog-empty-note { color:var(--text-soft); font-size:.9rem; }
.memory-toolbar { display:flex; gap:.8rem; align-items:center; flex-wrap:wrap; }
.memory-stat { border:1px solid var(--border); border-radius:999px; padding:.35rem .8rem; background:#fff; font-weight:600; }
.memory-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(110px, 1fr)); gap:.85rem; }
.memory-card { perspective:1000px; border:none; background:transparent; padding:0; }
.memory-card-inner { position:relative; width:100%; min-height:132px; transform-style:preserve-3d; transition:transform .45s ease; }
.memory-card.is-open .memory-card-inner, .memory-card.is-matched .memory-card-inner { transform:rotateY(180deg); }
.memory-card-face { position:absolute; inset:0; border-radius:18px; border:1px solid var(--border); backface-visibility:hidden; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:1rem; box-shadow:0 10px 20px rgba(15,23,42,.05); }
.memory-card-back { background:linear-gradient(180deg,#2b3444,#414b5c); color:#fff; }
.memory-card-front { transform:rotateY(180deg); background:#fff; }
.memory-card-front.is-left { background:#fbfbfc; }
.memory-card-front.is-right { background:#fffef8; }
.memory-card-content { font-size:1.8rem; }
.memory-card-caption { margin-top:.55rem; font-weight:600; text-align:center; }
.memory-back-mark { font-size:2rem; font-weight:700; }
.memory-back-text { font-size:.75rem; text-transform:uppercase; letter-spacing:.08em; }
.image-choice-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:1rem; }
.image-choice-card { position:relative; display:flex; flex-direction:column; gap:.75rem; align-items:center; border:1px solid var(--border); border-radius:16px; background:#fff; padding:1rem; }
.image-choice-card input { position:absolute; top:.75rem; right:.75rem; }
.image-choice-visual { min-height:96px; width:100%; display:flex; align-items:center; justify-content:center; border-radius:14px; background:#f8f9fb; font-size:2rem; }
.order-builder { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1rem; }
.order-target, .order-source { display:flex; flex-wrap:wrap; gap:.75rem; min-height:72px; }
.order-chip { border:1px solid var(--border); border-radius:14px; background:#fff; padding:.75rem .95rem; }
.order-chip.is-filled { background:#eef2f7; }
@media (max-width: 991px) {
  .dialog-layout, .order-builder, .matching-board { grid-template-columns:1fr; }
}


.markdown-body { line-height: 1.65; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin-top: 1.2rem; margin-bottom: 0.75rem; }
.markdown-body p, .markdown-body ul { margin-bottom: 0.9rem; }
.markdown-body ul { padding-left: 1.25rem; }
.md-image { max-width: 100%; height: auto; display: block; margin: 0.75rem 0; border-radius: 0.75rem; }

.world-map-card,
.maze-card {
    background: linear-gradient(180deg, #fffdf7 0%, #ffffff 100%);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 12px 28px rgba(15,23,42,.06);
    padding: 1rem;
}
.world-map-board,
.teacher-map-board,
.maze-board {
    position: relative;
    min-height: 430px;
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,.8), transparent 28%),
        linear-gradient(180deg, #f8f5e8 0%, #eef1f7 100%);
    border: 1px dashed #d7dbe2;
}
.world-map-path {
    position: absolute;
    inset: 10% 8%;
    border: 3px dashed rgba(43, 52, 68, .22);
    border-radius: 28px;
    pointer-events: none;
}
.map-node-card,
.teacher-map-node,
.maze-room-node {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: .35rem;
    min-width: 150px;
    max-width: 180px;
    padding: .8rem .9rem;
    border-radius: 18px;
    text-decoration: none;
    color: var(--text-main);
    background: rgba(255,255,255,.94);
    border: 1px solid #d6dbe3;
    box-shadow: 0 12px 24px rgba(15,23,42,.08);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.map-node-card:hover,
.teacher-map-node:hover,
.maze-room-node:hover {
    transform: translate(-50%, calc(-50% - 3px));
    box-shadow: 0 16px 28px rgba(15,23,42,.12);
    border-color: #bfc7d4;
}
.map-node-card.is-locked,
.maze-room-node.is-locked,
.map-node-summary.is-locked {
    opacity: .6;
    filter: grayscale(.2);
    pointer-events: none;
}
.map-node-order {
    display: inline-flex;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    background: #1f2937;
    color: white;
    font-size: .82rem;
    font-weight: 700;
}
.map-node-title,
.maze-room-title {
    font-weight: 700;
    line-height: 1.2;
}
.map-node-summary,
.maze-room-list-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: .95rem;
    box-shadow: 0 8px 18px rgba(15,23,42,.05);
}
.maze-board {
    min-height: 520px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.88) 0%, rgba(250,251,253,.98) 100%),
        linear-gradient(90deg, rgba(43,52,68,.04) 1px, transparent 1px),
        linear-gradient(rgba(43,52,68,.04) 1px, transparent 1px);
    background-size: auto, 42px 42px, 42px 42px;
}
.maze-room-node {
    min-width: 130px;
    max-width: 170px;
}
.maze-room-node.type-bonus { background: #fff6df; }
.maze-room-node.type-checkpoint { background: #eef7ff; }
.maze-room-node.type-boss { background: #fef0f1; }
.maze-room-node.type-final,
.maze-room-node.is-final { background: #f4edff; }
.maze-room-node.is-completed { border-color: #6aa87b; }
.maze-room-node.is-entry { border-color: #5b8def; }
.maze-room-kind {
    font-size: .78rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.teacher-maze-board,
.teacher-map-board { min-height: 460px; }
.dungeon-stage-card { background: linear-gradient(180deg, #fff 0%, #fbfbfd 100%); }
@media (max-width: 991px) {
    .world-map-board,
    .teacher-map-board,
    .maze-board { min-height: 680px; }
    .map-node-card,
    .teacher-map-node,
    .maze-room-node { min-width: 130px; max-width: 150px; }
}

.stat-inline {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem 1.25rem;
    align-items: center;
}
.stat-inline > div {
    display: inline-flex;
    align-items: baseline;
    gap: .42rem;
    min-width: fit-content;
}
.stat-inline strong {
    font-size: 1.05rem;
    line-height: 1;
}
.stat-inline span {
    line-height: 1.25;
}
.demo-clickable-card {
    cursor: pointer;
    min-height: 100%;
}
.module-card-link:hover .module-box,
.task-card-link:hover .task-box {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .1);
    border-color: #cfd5df;
}
.demo-link-hint {
    color: var(--accent);
}
@media (max-width: 575px) {
    .stat-inline {
        align-items: flex-start;
    }
    .stat-inline > div {
        width: 100%;
    }
}

.matching-table {
    display: grid;
    grid-template-columns: minmax(160px, 0.9fr) minmax(220px, 1.4fr);
    gap: .75rem;
    align-items: stretch;
}
.matching-table-head {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.matching-left-static {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: .85rem 1rem;
    font-weight: 700;
}
.matching-select-wrap {
    min-width: 0;
}
.matching-select {
    min-height: 48px;
    border-radius: 14px;
}
@media (max-width: 575px) {
    .matching-table {
        grid-template-columns: 1fr;
        gap: .55rem;
    }
    .matching-table-head {
        display: none;
    }
    .matching-left-static {
        margin-top: .35rem;
        border-bottom-left-radius: 8px;
        border-bottom-right-radius: 8px;
    }
    .matching-select {
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
    }
}
