/* ════════════════════════════════════════════════════════════
   TEACHER PORTAL LAYOUT
   Three views:  #view-auth  |  #view-portal  |  #view-board
   ════════════════════════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); min-height: 100vh;
       display: flex; flex-direction: column;
       height: auto; overflow: visible; }

/* ── Shared nav ─────────────────────────────────────────── */
.t-nav {
  display: flex; align-items: center; height: 58px;
  padding: 0 32px; background: var(--surface);
  border-bottom: 1px solid var(--toolbar-border);
  position: sticky; top: 0; z-index: 200; flex-shrink: 0;
}
.t-nav .nav-logo { margin-right: auto; }
.t-nav .nav-logo img { height: 32px; display: block; }
.t-nav .nav-links { display: flex; align-items: center; gap: 6px; }
.t-nav .nav-link {
  font-size: 13px; color: var(--text-muted); text-decoration: none;
  padding: 6px 12px; border-radius: 7px; background: none; border: none;
  cursor: pointer; font-family: inherit; transition: background .12s, color .12s;
}
.t-nav .nav-link:hover { background: var(--btn-hover); color: var(--btn-text); }
.t-nav .nav-link.active { color: var(--purple); font-weight: 600; }
.t-nav .nav-user {
  font-size: 13px; font-weight: 600; color: var(--btn-text);
  padding: 6px 12px; border-radius: 7px;
}
.t-nav .nav-sep { width: 1px; height: 22px; background: var(--toolbar-border); margin: 0 4px; }

/* ── Auth view ──────────────────────────────────────────── */
#view-auth {
  flex: 1; display: flex; flex-direction: column; background: var(--bg); min-height: 0;
}


.auth-hero {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
.auth-card {
  background: var(--surface); border-radius: 18px; padding: 40px 44px; width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.10); max-width: 92vw;
  margin-top: auto; margin-bottom: auto;
}
.auth-card .card-brand {
  text-align: center; font-size: 26px; font-weight: 800;
  color: var(--purple); letter-spacing: -.5px; margin-bottom: 4px;
}
.auth-card .card-sub { text-align: center; font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }
.auth-card h2 { font-size: 19px; font-weight: 700; color: var(--btn-text); margin-bottom: 20px; }

/* ── Portal view ────────────────────────────────────────── */
#view-portal { display: none; flex-direction: column; flex: 1; }
#view-portal.active { display: flex; }

.portal-body {
  display: flex;
  min-height: calc(100vh - 60px);
  background: linear-gradient(to right, var(--surface) 220px, var(--bg) 220px);
}

/* Sidebar */
.portal-sidebar {
  width: 220px; flex-shrink: 0;
  border-right: 1px solid var(--toolbar-border);
  padding: 24px 0;
}
.sidebar-section { padding: 0 12px; margin-bottom: 6px; }
.sidebar-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 0 8px; margin-bottom: 4px;
}
.sidebar-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 8px; border: none; background: none;
  font-size: 13px; font-weight: 500; color: var(--btn-text);
  cursor: pointer; font-family: inherit; text-align: left; transition: background .12s;
}
.sidebar-btn:hover { background: var(--btn-hover); }
.sidebar-btn.active { background: var(--purple-light); color: var(--purple); }
.sidebar-btn svg { flex-shrink: 0; opacity: .6; }
.sidebar-btn.active svg { opacity: 1; }
.sidebar-divider { height: 1px; background: var(--toolbar-border); margin: 12px 12px; }

/* Main content area */
.portal-main { flex: 1; padding: 32px 40px; min-width: 0; }
.portal-panel { display: none; }
.portal-panel.active { display: block; }

.panel-title {
  font-size: 20px; font-weight: 700; color: var(--btn-text); margin-bottom: 6px;
}
.panel-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }

/* Room grid */
.rooms-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.room-tile {
  background: var(--surface); border-radius: 13px; border: 1.5px solid var(--btn-border);
  padding: 14px 16px 16px 16px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
  display: flex; flex-direction: column; gap: 4px;
}
.room-tile:hover { border-color: var(--purple); box-shadow: 0 4px 16px rgba(83,74,183,.12); }
.room-tile .rt-name { font-size: 14px; font-weight: 700; color: var(--btn-text); }
.room-tile .rt-code { font-size: 20px; font-weight: 800; color: var(--purple); letter-spacing: .12em; margin-top: 6px; }
.room-tile .rt-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.room-tile .rt-locked { font-size: 11px; color: #BA7517; font-weight: 600; }
.room-tile .rt-rename {
  position: static; width: 24px; height: 24px;
  border-radius: 50%; background: var(--surface); border: 1px solid var(--btn-border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.room-tile .rt-rename:hover { background: #EEF4FF; border-color: #7F77DD; color: #7F77DD; }
.room-tile .rt-view {
  position: static; width: 24px; height: 24px;
  border-radius: 50%; background: var(--surface); border: 1px solid var(--btn-border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.room-tile .rt-view:hover { background: #E8F5FE; border-color: #378ADD; color: #378ADD; }
.room-tile .rt-present {
  position: static; width: 24px; height: 24px;
  border-radius: 50%; background: var(--surface); border: 1px solid var(--btn-border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.room-tile .rt-present:hover { background: #E6F6F2; border-color: #1D9E75; color: #1D9E75; }
.room-tile .rt-del {
  position: static; width: 24px; height: 24px;
  border-radius: 50%; background: var(--surface); border: 1px solid var(--btn-border);
  color: #A32D2D; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.room-tile .rt-del:hover { background: #FCEBEB; border-color: #E24B4A; }

/* Create room form */
.create-form {
  display: flex; gap: 10px; align-items: flex-end; max-width: 480px;
}
.create-form .field { flex: 1; margin: 0; }
.create-form button {
  padding: 10px 20px; background: var(--purple); color: #fff; border: none;
  border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
}
.create-form button:hover { background: var(--purple-dark); }

/* Settings form */
.settings-card {
  background: var(--surface); border-radius: 13px; border: 1px solid var(--btn-border);
  padding: 28px 32px; max-width: 520px; margin-bottom: 24px;
}
.settings-card h3 { font-size: 15px; font-weight: 700; color: var(--btn-text); margin-bottom: 18px; }
.settings-row { display: flex; gap: 14px; }
.settings-row .field { flex: 1; }
.settings-save {
  padding: 9px 22px; background: var(--purple); color: #fff; border: none;
  border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; margin-top: 4px;
}
.settings-save:hover { background: var(--purple-dark); }
.settings-msg { font-size: 13px; margin-top: 10px; min-height: 18px; }
.settings-msg.ok    { color: #0F6E56; }
.settings-msg.error { color: #A32D2D; }

/* Setting row with toggle switch */
.setting-toggle-row {
  display: flex;
  align-items: center;
  padding: 8px 0;
}
.setting-toggle-info { flex: 1; }
.setting-toggle-title { font-size: 14px; font-weight: 600; color: var(--btn-text); }
.setting-toggle-desc  { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--btn-border);
  border-radius: 24px;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.toggle-switch input:checked + .toggle-slider { background: var(--purple); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.avatar-style-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 6px; border: 2px solid var(--toolbar-border); border-radius: 10px;
  background: var(--surface-2); cursor: pointer; font-family: inherit; color: var(--btn-text);
  transition: border-color .12s, background .12s;
}
.avatar-style-opt:hover { border-color: var(--purple); }
.avatar-style-opt.selected { border-color: var(--purple); background: var(--purple-light); }

/* Achievements */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
/* ── Dashboard ── */
.dash-game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}
.dash-game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: 13px;
  border: 1.5px solid var(--btn-border);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  white-space: normal;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}
.dash-game-card:hover {
  border-color: var(--purple);
  box-shadow: 0 4px 14px rgba(83,74,183,.10);
}
.dgc-icon {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  background: var(--dgc-bg);
  color: var(--dgc-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dgc-body { flex: 1; min-width: 0; }
.dgc-name { font-size: 14px; font-weight: 700; color: var(--btn-text); margin-bottom: 2px; overflow-wrap: break-word; }
.dgc-desc {
  font-size: 12px; color: var(--text-muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.dgc-badge {
  font-size: 10px; font-weight: 600;
  background: var(--purple-light); color: var(--purple);
  padding: 1px 6px; border-radius: 99px;
  vertical-align: middle; margin-left: 4px;
}
.dgc-arrow { color: var(--text-muted); flex-shrink: 0; opacity: .45; }
.dash-game-card:hover .dgc-arrow { opacity: .9; }
.dash-mindbubble-btn {
  padding: 9px 18px;
  background: var(--surface);
  border: 1.5px solid var(--btn-border);
  border-radius: 9px;
  font-size: 13px; font-weight: 600;
  color: var(--btn-text);
  cursor: pointer;
  font-family: inherit;
  transition: border-color .12s, color .12s;
}
.dash-mindbubble-btn:hover { border-color: var(--purple); color: var(--purple); }

.ach-badge {
  border-radius: 14px;
  border: 2px solid var(--btn-border);
  padding: 18px 12px 14px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.ach-earned {
  border-color: var(--purple);
  background: var(--purple-light);
}
.ach-locked {
  background: var(--surface-2);
  opacity: .45;
  filter: grayscale(1);
}
.ach-icon  { font-size: 36px; line-height: 1; margin-bottom: 8px; }
.ach-name  { font-size: 13px; font-weight: 700; color: var(--btn-text); margin-bottom: 4px; }
.ach-desc  { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.ach-date  { font-size: 10px; color: var(--purple); margin-top: 6px; font-weight: 600; }

/* Verification notice */
.unverified-notice {
  background: #fffbeb; border: 1.5px solid #f0c040; border-radius: 10px;
  padding: 12px 16px; font-size: 13px; color: #7a5c00; line-height: 1.5; margin-bottom: 16px;
}
[data-theme] .unverified-notice { background: color-mix(in srgb, var(--surface) 80%, #ffcc00 20%); color: var(--btn-text); border-color: #c0a000; }
.verify-request-btn {
  padding: 6px 14px; border-radius: 7px; font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1.5px solid #a37a00;
  background: #fff8dc; color: #7a5c00;
}
.verify-request-btn:hover { background: #fef3c7; }
.verify-request-btn:disabled { opacity: .6; cursor: not-allowed; }
.unverified-inline-note { font-size: 12px; color: #a07000; margin: 4px 0 0; }

/* Admin tabs */
.admin-tabs { display: flex; gap: 6px; margin-bottom: 2px; border-bottom: 2px solid var(--toolbar-border); }
.admin-tab {
  padding: 8px 18px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.admin-tab:hover { color: var(--btn-text); }
.admin-tab.active { color: var(--purple); border-bottom-color: var(--purple); }

/* Admin teacher table */
.admin-search-input {
  width: 100%; box-sizing: border-box; padding: 9px 12px; margin-bottom: 14px;
  border: 1.5px solid var(--btn-border); border-radius: 8px;
  background: var(--surface-2); color: var(--btn-text);
  font-size: 13px; font-family: inherit;
}
.admin-search-input:focus { outline: none; border-color: var(--purple); }

.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-table th {
  text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  border-bottom: 2px solid var(--toolbar-border);
}
.admin-table td { padding: 10px 10px; border-bottom: 1px solid var(--toolbar-border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-badge {
  display: inline-block; border-radius: 6px; padding: 2px 9px;
  font-size: 11px; font-weight: 700; line-height: 1.6;
}
.admin-badge.verified { background: #d4f0e0; color: #0a6e3e; }
.admin-badge.pending  { background: #fff3cd; color: #7a5c00; }
.admin-badge.rejected { background: #fee2e2; color: #991b1b; cursor: help; }
.admin-badge.admin    { background: var(--purple-light); color: var(--purple-dark); }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-btn {
  padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1.5px solid var(--btn-border);
  background: var(--surface-2); color: var(--btn-text);
}
.admin-btn:hover { background: var(--btn-hover); }
.admin-btn:disabled { opacity: .5; cursor: not-allowed; }
.admin-btn.success { background: #22c55e; color: #fff; border-color: #16a34a; }
.admin-btn.success:hover { background: #16a34a; }
.admin-btn.danger  { background: #ef4444; color: #fff; border-color: #dc2626; }
.admin-btn.danger:hover  { background: #dc2626; }

.admin-pager {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.admin-pager-info {
  flex: 1; text-align: center; font-size: 12px; color: var(--text-muted);
}

.admin-pack-preview-cell {
  padding: 0 !important;
  background: var(--surface-2);
  border-bottom: 2px solid var(--purple) !important;
}

/* Read-only pack preview (legacy, kept for fallback) */
.admin-pack-qlist {
  margin: 0; padding: 14px 14px 14px 36px; list-style: decimal;
  display: flex; flex-direction: column; gap: 12px;
}
.admin-pack-q { font-size: 13px; }
.admin-pack-qtext { font-weight: 600; color: var(--btn-text); margin-bottom: 6px; }
.admin-pack-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-pack-opt {
  padding: 3px 10px; border-radius: 6px; font-size: 12px;
  border: 1.5px solid var(--btn-border); background: var(--surface); color: var(--text-muted);
}
.admin-pack-opt.correct {
  border-color: #22c55e; background: #dcfce7; color: #15803d; font-weight: 700;
}

/* Editable admin Q&A */
.admin-pack-qlist-edit { padding: 12px 12px 0; list-style: decimal; display: flex; flex-direction: column; gap: 14px; }
.admin-pack-q-edit { font-size: 13px; }
.admin-q-text {
  width: 100%; font-size: 13px; font-family: inherit; font-weight: 600;
  padding: 6px 8px; border: 1.5px solid var(--btn-border); border-radius: 7px;
  background: var(--surface); color: var(--btn-text); resize: vertical; box-sizing: border-box;
  margin-bottom: 8px;
}
.admin-pack-opts-edit { display: flex; flex-direction: column; gap: 5px; }
.admin-opt-row { display: flex; align-items: center; gap: 6px; }
.admin-opt-correct-lbl { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.admin-opt-correct-lbl input { accent-color: #22c55e; width: 15px; height: 15px; cursor: pointer; }
.option-color-dot-sm { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.admin-opt-label-txt { font-size: 12px; font-weight: 700; color: var(--text-muted); flex-shrink: 0; width: 14px; }
.admin-opt-input {
  flex: 1; font-size: 12px; font-family: inherit; padding: 5px 8px;
  border: 1.5px solid var(--btn-border); border-radius: 6px;
  background: var(--surface); color: var(--btn-text);
}
.admin-q-edit-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px; border-top: 1px solid var(--toolbar-border); margin-top: 12px;
}
.admin-q-save-msg { font-size: 12px; font-weight: 600; }

/* Reject form */
.admin-reject-form { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.admin-reject-label { font-size: 12px; font-weight: 600; color: var(--btn-text); }
.admin-reject-textarea {
  width: 100%; font-size: 13px; font-family: inherit; padding: 7px 10px;
  border: 1.5px solid var(--btn-border); border-radius: 7px;
  background: var(--surface); color: var(--btn-text); resize: vertical; box-sizing: border-box;
}

/* Teacher-side rejected badge */
.badge-rejected {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: #fee2e2; color: #991b1b; cursor: help;
}

/* Admin pack controls */
.admin-pack-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 0; border-bottom: 1px solid var(--toolbar-border); margin-bottom: 4px;
}
.admin-pack-controls .admin-search-input {
  flex: 1; min-width: 160px; max-width: 260px;
}
.admin-filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.admin-filter-tab {
  padding: 4px 11px; border-radius: 6px; font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1.5px solid var(--btn-border);
  background: var(--surface-2); color: var(--btn-text); white-space: nowrap;
}
.admin-filter-tab:hover { background: var(--btn-hover); }
.admin-filter-tab.active { background: var(--purple); color: #fff; border-color: var(--purple); }
.admin-filter-tab.flagged { border-color: #f97316; color: #c2410c; }
.admin-filter-tab.flagged.active { background: #f97316; color: #fff; border-color: #f97316; }
.admin-sort-select {
  font-size: 12px; font-family: inherit; padding: 5px 8px;
  border: 1.5px solid var(--btn-border); border-radius: 6px;
  background: var(--surface-2); color: var(--btn-text); cursor: pointer;
}
.admin-badge.flagged   { background: #fff7ed; color: #c2410c; }
.admin-badge.volunteer { background: #e0f2fe; color: #0369a1; }

/* Admin reports section */
.admin-reports-section {
  border-top: 1px solid var(--toolbar-border); margin-top: 4px; padding-top: 4px;
}
.admin-reports-title {
  padding: 10px 12px 6px; font-size: 12px; font-weight: 700;
  color: #c2410c; text-transform: uppercase; letter-spacing: .04em;
}
.admin-report-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 6px 12px; border-top: 1px solid var(--toolbar-border); font-size: 12px;
}
.admin-report-who { font-weight: 600; color: var(--btn-text); }
.admin-report-date { color: var(--text-muted); grid-column: 2; grid-row: 1; text-align: right; }
.admin-report-comment { grid-column: 1 / -1; color: var(--text-muted); font-style: italic; }

/* Community card report button */
.community-card-wrap { display: flex; flex-direction: column; }
.pack-report-btn {
  align-self: flex-end; margin-top: 2px; padding: 2px 8px;
  font-size: 11px; font-weight: 600; font-family: inherit; cursor: pointer;
  background: none; border: none; color: var(--text-muted); opacity: .6;
}
.pack-report-btn:hover { opacity: 1; color: #c2410c; }

/* Danger zone */
.danger-zone {
  border: 2px solid #e0a0a0 !important;
  background: #fff8f8;
}
[data-theme] .danger-zone { background: color-mix(in srgb, var(--surface) 90%, #ff3333 10%); border-color: #b85050 !important; }
.danger-btn {
  padding: 9px 22px; background: #C0392B; color: #fff; border: none;
  border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.danger-btn:hover { background: #962d22; }

/* Delete account modal */
.del-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.del-modal-box {
  background: var(--surface); border-radius: 16px; padding: 32px 28px;
  max-width: 420px; width: 90%; box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.del-modal-icon { font-size: 40px; text-align: center; margin-bottom: 12px; }
.del-modal-title { font-size: 20px; font-weight: 700; color: var(--btn-text); text-align: center; margin-bottom: 10px; }
.del-modal-body { font-size: 14px; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px; }
.del-modal-list {
  font-size: 13px; color: var(--text-muted); padding-left: 20px;
  line-height: 1.9; margin: 0 0 4px;
}
.del-modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.del-cancel-btn {
  flex: 1; padding: 10px; border-radius: 8px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; background: var(--surface-2);
  border: 1.5px solid var(--btn-border); color: var(--btn-text);
}
.del-cancel-btn:hover { background: var(--btn-hover); }
.del-next-btn {
  flex: 1; padding: 10px; border-radius: 8px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; background: var(--purple); color: #fff; border: none;
}
.del-next-btn:hover { background: var(--purple-dark); }
.del-confirm-btn {
  flex: 1; padding: 10px; border-radius: 8px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; background: #C0392B; color: #fff; border: none;
}
.del-confirm-btn:hover { background: #962d22; }
.del-confirm-btn:disabled { opacity: .5; cursor: not-allowed; }
.del-modal-input {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 8px;
  border: 1.5px solid var(--btn-border); background: var(--surface-2); color: var(--btn-text);
  font-size: 14px; font-family: inherit; margin-top: 10px;
}
.del-modal-input:focus { outline: none; border-color: var(--purple); }
.del-modal-error { font-size: 12px; color: #C0392B; margin-top: 6px; min-height: 16px; }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 14px;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }

/* ── Board view ─────────────────────────────────────────── */
#view-board {
  display: none; flex-direction: column; height: 100vh; height: 100svh; overflow: hidden;
}
#view-board.active { display: flex; }

#board-toolbar {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-bottom: 1px solid var(--toolbar-border); flex-shrink: 0; z-index: 100;
}
.sep { width: 1px; height: 22px; background: var(--toolbar-border); margin: 0 3px; flex-shrink: 0; }

#lock-banner {
  display: none; background: #FAEEDA; border-bottom: 1px solid #EF9F27;
  padding: 6px 16px; font-size: 13px; font-weight: 600; color: #633806;
  text-align: center; flex-shrink: 0;
}
#lock-banner.show { display: block; }

#world-wrap { flex: 1; overflow: hidden; position: relative; cursor: default; }
#world { position: absolute; top: 0; left: 0; transform-origin: 0 0; width: 4000px; height: 4000px; }
#grid-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
#edge-svg { position: absolute; top: 0; left: 0; width: 4000px; height: 4000px; pointer-events: none; overflow: visible; }
.edge-del { pointer-events: all; cursor: pointer; }

/* Popples */
.popple { position: absolute; min-width: 130px; min-height: 74px; border-radius: 13px; border: 2.5px solid; padding: 12px 14px; cursor: grab; user-select: none; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: box-shadow .15s; }
.popple:active { cursor: grabbing; }
.popple.dragging { box-shadow: var(--shadow-drag); z-index: 1000 !important; }
.popple.selected { outline: 3px solid rgba(83,74,183,.55); outline-offset: 2px; }
.popple-owner { font-size: 10px; font-weight: 700; opacity: .55; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.popple textarea { background: transparent; border: none; outline: none; font-family: inherit; font-size: 13.5px; font-weight: 500; resize: none; width: 100%; line-height: 1.45; cursor: text; overflow: hidden; min-height: 36px; }
.popple textarea::placeholder { opacity: .5; }
.dot { position: absolute; width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--surface); border: 2.5px solid; cursor: crosshair; opacity: 0; transition: opacity .15s; z-index: 10; }
.popple:hover .dot, .popple.selected .dot { opacity: 1; }
.dot[data-dir="t"] { top: calc(var(--dot)/-2); left: 50%; transform: translateX(-50%); }
.dot[data-dir="b"] { bottom: calc(var(--dot)/-2); left: 50%; transform: translateX(-50%); }
.dot[data-dir="l"] { left: calc(var(--dot)/-2); top: 50%; transform: translateY(-50%); }
.dot[data-dir="r"] { right: calc(var(--dot)/-2); top: 50%; transform: translateY(-50%); }
.popple-del { position: absolute; top: -9px; right: -9px; width: 20px; height: 20px; border-radius: 50%; background: #E24B4A; color: #fff; font-size: 13px; font-weight: 700; line-height: 1; display: none; align-items: center; justify-content: center; cursor: pointer; border: 2px solid var(--surface); z-index: 20; }
.popple.selected .popple-del { display: flex; }
.popple-resize { position: absolute; bottom: 3px; right: 4px; width: 14px; height: 14px; cursor: se-resize; opacity: 0; transition: opacity .15s; }
.popple:hover .popple-resize, .popple.selected .popple-resize { opacity: .4; }

/* Toast */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px); background: #2c2c2a; color: #fff; padding: 8px 18px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 9999; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Help */
#help-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 5000; opacity: 0; pointer-events: none; transition: opacity .2s; }
#help-overlay.show { opacity: 1; pointer-events: all; }
#help-box { background: var(--surface); border-radius: 14px; padding: 28px 32px; max-width: 420px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 88vh; overflow-y: auto; }
#help-box h2 { font-size: 18px; margin-bottom: 16px; color: var(--purple); }
#help-box table { width: 100%; border-collapse: collapse; font-size: 13px; }
#help-box td { padding: 6px 0; vertical-align: top; }
#help-box td:first-child { color: var(--purple); font-weight: 600; padding-right: 14px; white-space: nowrap; }
#help-box tr + tr td { border-top: 1px solid #f0eee8; }
/* ── Room card action buttons ────────────────────────────────── */
.rt-actions {
  display: flex; gap: 6px; align-items: center;
  border-bottom: 1px solid var(--btn-border);
  padding-bottom: 10px; margin-bottom: 8px;
}
.rt-actions .rt-del { margin-left: auto; }

.rt-qr {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--btn-border);
  font-size: 11px; font-weight: 600; color: var(--purple);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.rt-qr:hover { background: var(--purple-light); border-color: var(--purple); }

/* ── QR modal ────────────────────────────────────────────────── */
#qr-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
#qr-modal {
  background: var(--surface); border-radius: 18px; padding: 36px 40px;
  text-align: center; width: 340px; max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.2); position: relative;
}
#qr-close {
  position: absolute; top: 14px; right: 16px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--btn-border); background: var(--surface);
  font-size: 16px; font-weight: 700; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--btn-text);
}
#qr-close:hover { background: #FCEBEB; border-color: #E24B4A; color: #A32D2D; }
#qr-modal h2 {
  font-size: 17px; font-weight: 700; color: var(--btn-text);
  margin-bottom: 4px; padding-right: 20px;
}
.qr-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
#qr-canvas {
  display: flex; justify-content: center; margin-bottom: 16px;
}
#qr-canvas img, #qr-canvas canvas {
  border-radius: 8px; border: 4px solid var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
}
.qr-code-text {
  font-size: 28px; font-weight: 800; letter-spacing: .18em;
  color: var(--purple); margin-bottom: 6px;
}
.qr-url {
  font-size: 11px; color: var(--text-muted); word-break: break-all;
  margin-bottom: 18px; line-height: 1.5;
}
.qr-copy-btn {
  width: 100%; padding: 10px; background: var(--purple); color: #fff;
  border: none; border-radius: 9px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background .12s;
}
.qr-copy-btn:hover { background: var(--purple-dark); }

/* ── Student roster sidebar (teacher board view only) ────────── */
#board-body { flex: 1; display: flex; overflow: hidden; }

#students-panel {
  display: flex; flex-direction: row;
  background: var(--surface); border-left: 1px solid var(--toolbar-border);
  flex-shrink: 0; width: 36px;
  transition: width .22s ease; overflow: hidden;
}
#students-panel.open { width: 220px; }

#sp-toggle {
  flex-shrink: 0; width: 36px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; padding: 14px 0 0; gap: 10px;
  border: none; border-right: 1px solid var(--toolbar-border);
  background: none; cursor: pointer; font-family: inherit;
  transition: background .12s; color: var(--text-muted);
}
#sp-toggle:hover { background: var(--btn-hover); color: var(--btn-text); }
#students-panel.open #sp-toggle { background: var(--purple-light); color: var(--purple); }

/* Chevron: points right (▶) when closed → rotate to left (◀) when open */
#sp-chevron { transition: transform .22s; transform: rotate(180deg); }
#students-panel.open #sp-chevron { transform: rotate(0deg); }

#sp-badge {
  background: var(--purple); color: #fff;
  border-radius: 10px; padding: 2px 5px;
  font-size: 10px; font-weight: 700; min-width: 16px; text-align: center;
  line-height: 1.5;
}
.sp-toggle-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  writing-mode: vertical-rl; transform: rotate(180deg); margin-top: 2px;
}

#sp-drawer {
  flex: 1; display: flex; flex-direction: column; overflow-y: auto; min-width: 0;
}
.sp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px; border-bottom: 1px solid var(--toolbar-border);
  font-size: 12px; font-weight: 700; color: var(--btn-text);
  position: sticky; top: 0; background: var(--surface); flex-shrink: 0;
}
#sp-count {
  background: var(--purple-light); color: var(--purple);
  border-radius: 10px; padding: 1px 7px;
  font-size: 11px; font-weight: 700;
}
#sp-names { list-style: none; padding: 6px 0; margin: 0; }
#sp-names li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; font-size: 12px; color: var(--btn-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; border-radius: 6px; margin: 0 4px;
  transition: background .12s;
}
#sp-names li:hover { background: var(--btn-hover); }
#sp-names li.active {
  background: rgba(83,74,183,.12); color: var(--purple);
  font-weight: 700;
}
#sp-names li.active::before { background: var(--purple) !important; }
#sp-names li::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: #5DCAA5; flex-shrink: 0;
}
#sp-names li[data-offline]::before { background: #bbb; }
#sp-names li[data-offline]:not(.active) { color: var(--text-muted); }
#sp-names .sp-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 14px 2px; cursor: default; pointer-events: none;
}
#sp-names .sp-section-label::before { display: none; }
#sp-names .sp-section-label:hover { background: transparent; }
.sp-empty {
  font-size: 12px; color: var(--text-muted);
  padding: 16px 14px; text-align: center; margin: 0;
}

/* ── Usage stats panel ───────────────────────────────────── */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--btn-border);
  border-radius: 13px;
  padding: 20px;
  text-align: center;
}
.stat-num {
  font-size: 36px;
  font-weight: 700;
  color: var(--purple);
  line-height: 1;
}
.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}
.stats-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 640px) {
  .stats-detail-grid { grid-template-columns: 1fr; }
}

.solo-games-section {
  margin-bottom: 24px;
}
.solo-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--btn-text);
  margin-bottom: 14px;
}
.solo-games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.game-solo-card {
  background: var(--surface);
  border: 1px solid var(--btn-border);
  border-radius: 13px;
  padding: 18px 20px;
}
.game-solo-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--btn-text);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--toolbar-border);
}
.game-solo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--toolbar-border);
  font-size: 13px;
}
.game-solo-row:last-child { border-bottom: none; }
.game-solo-label { color: var(--text-muted); }
.game-solo-num   { font-weight: 700; color: var(--purple); }
@media (max-width: 900px) {
  .solo-games-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .solo-games-grid { grid-template-columns: 1fr; }
}
