:root { --theme-primary: #16a34a; --theme-secondary: #243b55; --theme-accent: #fde68a; }
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; font-family: Arial, Helvetica, sans-serif; background: #0e1117; color: #eef2ff; }
button, input, select { font: inherit; }
.screen { display: none; width: 100vw; height: 100vh; }
.screen.active { display: flex; }
#startScreen, #endScreen { align-items: center; justify-content: center; background: radial-gradient(circle at top, var(--theme-secondary) 0, #141e30 42%, #090b10 100%); }
.start-card, .end-card { width: min(760px, 92vw); background: rgba(18, 24, 38, .94); border: 1px solid rgba(255,255,255,.12); border-radius: 22px; padding: 34px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
h1 { margin: 0 0 8px; font-size: 42px; letter-spacing: .5px; }
.subtitle { margin: 0 0 28px; color: #b8c7e8; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: 180px 1fr 180px; gap: 16px; margin-bottom: 22px; }
label { display: flex; flex-direction: column; gap: 8px; color: #d8e2ff; font-weight: 700; }
input, select { height: 46px; border-radius: 12px; border: 1px solid rgba(255,255,255,.18); background: #0c1220; color: #fff; padding: 0 14px; outline: none; }
input:focus, select:focus { border-color: #86efac; }
button:focus-visible { outline: 2px solid #86efac; outline-offset: 2px; }
.rules { background: rgba(255,255,255,.06); padding: 16px 18px; border-radius: 16px; margin: 20px 0; color: #dbe7ff; line-height: 1.45; }
button { border: 0; border-radius: 12px; padding: 12px 18px; color: #fff; background: #334155; cursor: pointer; transition: transform .08s ease, filter .15s ease; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border: 0; border-radius: 12px; padding: 12px 18px; color: #fff; background: #334155; }
button:hover:not(:disabled) { filter: brightness(1.1); }
.button-link:hover { filter: brightness(1.1); }
button:active { transform: scale(.98); }
button:disabled { cursor: not-allowed; opacity: .62; }
button.primary { background: linear-gradient(135deg, var(--theme-primary), #15803d); font-weight: 800; }
#gameScreen { align-items: center; justify-content: center; background: #090b10; }
.game-wrap { width: min(1128px, 96vw); height: min(720px, 96vh); display: grid; grid-template-columns: minmax(0, 768px) minmax(280px, 340px); gap: 20px; align-items: start; }
.game-frame { position: relative; background: #020617; padding: 0; border: 1px solid rgba(255,255,255,.14); border-radius: 18px; overflow: hidden; box-shadow: 0 16px 45px rgba(0,0,0,.4); align-self: start; }
canvas { display: block; width: 100%; max-width: 768px; aspect-ratio: 12 / 7; height: auto; image-rendering: pixelated; }
#hintBar { height: 48px; display: flex; align-items: center; justify-content: center; background: #111827; color: #d1d5db; border-top: 1px solid rgba(255,255,255,.12); font-weight: 700; }
.panel { height: min(608px, 96vh); background: rgba(15, 23, 42, .96); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 20px; box-shadow: 0 16px 45px rgba(0,0,0,.32); }
.panel h2 { margin: 0 0 12px; }
.student-box { display: grid; gap: 4px; padding: 12px; background: rgba(255,255,255,.06); border-radius: 14px; color: #dbeafe; }
.timer { margin: 18px 0; text-align: center; font-size: 48px; font-weight: 900; color: var(--theme-accent); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats div { background: rgba(255,255,255,.07); border-radius: 14px; padding: 12px; display: grid; gap: 6px; }
.stats span { color: #aebbd5; font-size: 13px; }
.stats b { font-size: 24px; }
.objective { margin: 18px 0; padding: 14px; border-radius: 14px; background: rgba(22, 163, 74, .12); border: 1px solid rgba(22, 163, 74, .28); color: #dcfce7; line-height: 1.35; }
.log-box { height: 120px; overflow: auto; background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px; font-size: 12px; color: #cbd5e1; }
.log-box p { margin: 0 0 8px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.66); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal.hidden { display: none; }
.modal-card { width: 720px; background: #f8fafc; color: #0f172a; border-radius: 22px; padding: 26px; box-shadow: 0 20px 70px rgba(0,0,0,.55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #d8dee9; padding-bottom: 12px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 26px; }
#questionMeta { background: var(--theme-accent); color: #075985; padding: 6px 10px; border-radius: 999px; font-weight: 800; }
#questionMeta:empty { display: none; }
#questionText { font-size: 20px; line-height: 1.4; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.answers button { background: #1e293b; min-height: 52px; text-align: left; }
.answers button.correct { background: #16a34a; }
.answers button.wrong { background: #dc2626; }
.feedback { min-height: 26px; font-weight: 800; }
.summary { background: rgba(255,255,255,.06); padding: 18px; border-radius: 16px; line-height: 1.7; margin: 18px 0; }
.analysis-summary { max-height: 40vh; overflow: auto; }
.analysis-summary h2, .analysis-summary h3 { margin: 0 0 8px; }
.analysis-summary p { margin: 0 0 10px; }
.analysis-summary ul { margin: 8px 0 0; padding-left: 20px; }
.end-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 1200px), (max-height: 690px) {
  .game-wrap { width: 96vw; height: 96vh; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
  .timer { font-size: 38px; }
  .panel { padding: 16px; }
}
@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
}

.teacher-page { overflow: auto; }
.teacher-shell { width: min(1220px, 94vw); margin: 0 auto; padding: 32px 0 48px; }
.teacher-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.teacher-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.teacher-control-panel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.control-card { display: grid; align-content: start; gap: 12px; }
.control-card h2 { margin: 0; font-size: 20px; }
.control-card label { font-size: 13px; }
.control-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.control-note { font-size: .92rem; line-height: 1.35; }
.backup-status { color: #dbeafe; font-size: .92rem; line-height: 1.35; }
.backup-status small { display: block; color: #9fb0d0; margin-top: 4px; overflow-wrap: anywhere; }
.backup-status.error-text { color: #fecaca; }
.warning-text { color: #fde68a !important; font-weight: 700; }
.admin-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.json-editor { width: 100%; min-height: 420px; resize: vertical; margin-top: 12px; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; padding: 12px; background: #020617; color: #dbeafe; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.recovery-track { margin-bottom: 16px; }
.compact-report { margin: 12px 0; }
.recovery-questions { display: grid; gap: 12px; }
.recovery-question { border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 14px; background: rgba(2, 6, 23, .45); }
.recovery-question h4 { margin: 0 0 8px; }
.recovery-question p { margin: 0 0 8px; }
.recovery-question ol { margin: 0 0 8px 22px; padding: 0; }
.teacher-only summary { cursor: pointer; color: #bfdbfe; }
.primary-link { background: linear-gradient(135deg, #16a34a, #15803d); font-weight: 800; }
.teacher-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-card, .teacher-card { background: rgba(15, 23, 42, .96); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 16px; box-shadow: 0 12px 32px rgba(0,0,0,.24); }
.metric-card { display: grid; gap: 8px; }
.metric-card span { color: #aebbd5; font-size: 13px; }
.metric-card b { font-size: 30px; }
.teacher-groups { display: grid; gap: 16px; }
.teacher-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.teacher-card h2 { margin: 0; }
.teacher-card p { margin: 0; color: #b8c7e8; }
.teacher-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.teacher-metrics span { background: rgba(255,255,255,.06); border-radius: 10px; padding: 10px; color: #cbd5e1; }
.teacher-metrics b { display: block; color: #fff; font-size: 20px; margin-top: 4px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,.1); white-space: nowrap; }
th { color: #aebbd5; font-size: 12px; text-transform: uppercase; }
.release-attempt-btn { padding: 7px 10px; border-radius: 8px; background: #7f1d1d; font-size: 12px; }
.teacher-report { margin-top: 18px; }
.teacher-report h2, .teacher-report h3 { margin: 0 0 8px; }
.teacher-report ul { margin: 8px 0 14px; padding-left: 20px; }
.teacher-audit { margin-top: 18px; }
.teacher-page a { color: #93c5fd; }
.report-shell { max-width: 1220px; }
.report-filters { display: grid; grid-template-columns: minmax(180px, 240px) minmax(180px, 280px) auto; gap: 12px; align-items: end; margin-bottom: 18px; background: rgba(15, 23, 42, .96); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 16px; }
.periodic-filters { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.report-card h2 { margin: 0 0 8px; }
.report-card p { margin: 6px 0; color: #dbe7ff; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top, #243b55 0, #141e30 42%, #090b10 100%); padding: 24px; }
.login-card { width: min(440px, 94vw); display: grid; gap: 16px; background: rgba(18, 24, 38, .96); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.login-card h1 { font-size: 34px; }
.login-card .subtitle { margin-bottom: 4px; }
.login-card .feedback { color: #fecaca; margin: 0; min-height: 22px; }
@media print {
  html, body { overflow: visible; background: #fff; color: #111827; }
  .teacher-page { background: #fff; color: #111827; }
  .teacher-shell { width: 100%; padding: 0; }
  .teacher-actions, .report-filters { display: none; }
  .metric-card, .teacher-card, .summary { box-shadow: none; border: 1px solid #d1d5db; background: #fff; color: #111827; break-inside: avoid; }
  .metric-card span, .teacher-card p, .report-card p, th { color: #374151; }
  .metric-card b, .teacher-metrics b { color: #111827; }
  table { color: #111827; }
  th, td { border-bottom: 1px solid #d1d5db; }
  a { color: #111827; text-decoration: none; }
}
@media (max-width: 900px) {
  .teacher-header { display: block; }
  .teacher-actions { justify-content: flex-start; margin-top: 14px; }
  .teacher-control-panel { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .teacher-overview, .teacher-metrics, .report-filters, .periodic-filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .teacher-overview, .teacher-metrics, .report-filters, .periodic-filters { grid-template-columns: 1fr; }
}

/* ── Toggle de disponibilidade ── */
.availability-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(255,255,255,.04); border-radius: 10px; padding: 10px 14px; }
.availability-row .av-info { display: grid; gap: 2px; flex: 1; min-width: 0; }
.availability-row .av-nome { font-size: 14px; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.availability-row .av-detalhe { font-size: 12px; color: #64748b; }
.av-toggle-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.av-toggle-label { font-size: 12px; font-weight: 600; min-width: 80px; text-align: right; }
.av-toggle-label.on { color: #4ade80; }
.av-toggle-label.off { color: #64748b; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #334155; border-radius: 24px; transition: background .2s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle-switch input:checked + .toggle-slider { background: #16a34a; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch input:disabled + .toggle-slider { opacity: .5; cursor: default; }
