:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #111827;
  --navy: #0d1b4b;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
  --orange: #f97316;
  --stage: #111827;
  --radius: 8px;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

a {
  text-decoration: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  transition: grid-template-columns 0.25s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
}

.sidebar {
  background: #0f172a;
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  transition: width 0.25s ease, padding 0.25s ease, opacity 0.15s ease;
}

.app-shell.sidebar-collapsed .sidebar {
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.3);
  padding: 10px 12px 2px;
  text-transform: uppercase;
  user-select: none;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 8px 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  flex-shrink: 0;
}

.brand-mark-xl {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}

.brand-hero {
  font-size: 34px;
  margin-bottom: 28px;
  gap: 14px;
}

.brand-hero .brand-teal {
  color: var(--teal);
}

.hero-logo-img {
  height: 72px;
  margin-bottom: 20px;
  display: block;
}

.hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.5);
}

.nav-button {
  border: 0;
  border-left: 3px solid transparent;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 9px;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.18s ease, transform 0.15s ease, color 0.15s ease;
}

.nav-button.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border-left-color: var(--teal);
}

.upload-zone {
  border: 2px dashed #c7d2fe;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-zone:hover,
.upload-zone.drag {
  border-color: #6366f1;
  background: #eef2ff;
}

.file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.file-chip {
  background: #eef2ff;
  color: #4338ca;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.file-chip button {
  background: none;
  border: 0;
  color: #4338ca;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  line-height: 1;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.7fr);
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.quiz-card,
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.panel {
  padding: 18px;
}

.quiz-card {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.quiz-card h3,
.panel h2,
.panel h3 {
  margin: 0;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, filter 0.15s ease;
}

.btn:active {
  transform: translateY(0px) scale(0.97);
  box-shadow: none;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.secondary {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.btn.danger {
  background: var(--red);
  color: white;
}

.btn.success {
  background: var(--green);
  color: white;
}

/* Hover apenas em dispositivos com ponteiro real (mouse) — evita problema no iOS */
@media (hover: hover) {
  .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  }

  .btn.primary:hover   { background: var(--primary-dark); }
  .btn.secondary:hover { background: #f1f5f9; border-color: #94a3b8; }
  .btn.danger:hover    { filter: brightness(1.1); }
  .btn.success:hover   { filter: brightness(1.08); }

  .nav-button:not(.active):hover {
    background: rgba(255, 255, 255, 0.08);
    border-left-color: rgba(20, 184, 166, 0.45);
    color: white;
  }
}

/* Efeito ripple */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: ripple-anim 0.55s linear;
  pointer-events: none;
}

@keyframes ripple-anim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field label {
  font-weight: 700;
  font-size: 13px;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}

.textarea {
  min-height: 170px;
  resize: vertical;
}

.question-list {
  display: grid;
  gap: 12px;
  max-height: 70vh;
  overflow: auto;
  padding-right: 4px;
}

.question-editor {
  display: grid;
  gap: 12px;
}

.option-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.login-page,
.join-page,
.play-page,
.stage-page {
  min-height: 100vh;
}

.login-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
}

.hero {
  min-height: 100vh;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(rgba(17, 24, 39, 0.72), rgba(17, 24, 39, 0.84)),
    url("assets/classroom-quiz.svg");
  background-size: cover;
  background-position: center;
  color: white;
}

.hero h1 {
  font-size: 58px;
  line-height: 1;
  margin: 0 0 16px;
  letter-spacing: 0;
}

.hero p {
  max-width: 660px;
  font-size: 20px;
  line-height: 1.5;
}

.login-card {
  padding: 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: white;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--stage);
  color: white;
  box-shadow: var(--shadow);
}

.stage-page {
  background: var(--stage);
  color: white;
  padding: 26px;
}

.stage-grid {
  min-height: calc(100vh - 52px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.stage-panel {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 22px;
}

.code {
  font-size: 72px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 4px;
}

.qr-box {
  width: min(220px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: white;
  padding: 12px;
  border-radius: 8px;
  margin: 10px 0 14px;
}

.qr-box img {
  width: 100%;
  height: 100%;
  display: block;
}

.question-stage {
  display: grid;
  place-items: center;
  text-align: center;
}

.question-stage h1 {
  font-size: 42px;
  max-width: 940px;
}

.answer-grid,
.player-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.answer-tile,
.player-option {
  border: 0;
  border-radius: 8px;
  color: white;
  min-height: 96px;
  padding: 16px;
  font-weight: 900;
  font-size: 18px;
  text-align: left;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  position: relative;
  overflow: hidden;
}

.player-option:active {
  transform: scale(0.97);
  filter: brightness(0.95);
}

@media (hover: hover) {
  .player-option:hover {
    transform: scale(1.03);
    filter: brightness(1.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

.answer-tile:nth-child(1),
.player-option:nth-child(1) { background: #dc2626; }
.answer-tile:nth-child(2),
.player-option:nth-child(2) { background: #2563eb; }
.answer-tile:nth-child(3),
.player-option:nth-child(3) { background: #d97706; }
.answer-tile:nth-child(4),
.player-option:nth-child(4) { background: #16a34a; }

.answer-tile.correct {
  outline: 5px solid white;
}

.player-list,
.ranking-list {
  display: grid;
  gap: 10px;
}

.player-row,
.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.join-page,
.play-page {
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(248, 250, 252, 0.88), rgba(248, 250, 252, 0.92)),
    url("assets/student-phone.svg");
  background-size: cover;
  background-position: center;
}

.phone-card {
  width: min(430px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.join-code-input {
  font-size: 34px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 5px;
}

.timer {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.timer > span {
  display: block;
  height: 100%;
  background: var(--amber);
  width: 100%;
  transition: width 0.2s linear;
}

@media (max-width: 900px) {
  .app-shell,
  .login-page,
  .stage-grid,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    width: 260px;
    z-index: 100;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
    transition: left 0.25s ease;
    gap: 22px;
  }

  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .main {
    padding: 18px;
  }

  .hero {
    min-height: auto;
    padding: 36px 24px;
  }

  .hero h1 {
    font-size: 40px;
  }

  .login-card {
    padding: 24px;
  }

  .answer-grid,
  .player-options {
    grid-template-columns: 1fr;
  }

  .code {
    font-size: 52px;
  }

  .question-stage h1 {
    font-size: 30px;
  }
}
