@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --green-900: #0a4609;
  --green-800: #0f630e;
  --green-700: #148213;
  --green-600: #1a9d18;
  --green-100: #e9f7e9;
  --green-50: #f4fbf4;
  --amber-400: #fbbf24;
  --amber-300: #fcd34d;
  --amber-200: #fde68a;
  --warm-100: #f4fbf4;
  --warm-200: #e9f7e9;
  --text: #0a4609;
  --text-light: #ffffff;
  --muted: #5a8a59;
  --danger: #e11d48;
  --success: #16a34a;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 12px 40px rgba(10, 70, 9, 0.18);
  --shadow-soft: 0 6px 20px rgba(10, 70, 9, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--green-900);
  color: var(--text-light);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Warm background pattern */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 10%, rgba(26, 157, 24, 0.12) 0%, transparent 35%),
    radial-gradient(circle at 85% 75%, rgba(15, 99, 14, 0.25) 0%, transparent 40%);
  z-index: -1;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 34px;
}

.logo {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  background: var(--warm-100);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.logo svg {
  width: 42px;
  height: 42px;
}

h1, h2, h3 {
  font-family: 'Space Grotesk', sans-serif;
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  letter-spacing: -0.03em;
}

.subtitle {
  color: var(--amber-200);
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 500;
}

/* Cards */
.card {
  background: var(--green-800);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

label {
  display: block;
  color: var(--amber-200);
  font-size: 0.92rem;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

input[type="text"], textarea {
  width: 100%;
  padding: 18px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text-light);
  font-size: 1.2rem;
  outline: none;
  resize: none;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--amber-400);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.15);
}

input[type="text"]::placeholder, textarea::placeholder {
  color: #9ca3db;
}

textarea {
  min-height: 130px;
  line-height: 1.5;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 26px;
  border: none;
  border-radius: 14px;
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--amber-400);
  color: var(--green-900);
  box-shadow: 0 6px 0 #d97706;
}

.btn-primary:hover {
  background: var(--amber-300);
}

.btn-primary:active {
  box-shadow: 0 2px 0 #d97706;
  transform: translateY(4px) scale(0.97);
}

.btn-danger {
  background: #fff1f2;
  color: var(--danger);
  box-shadow: 0 4px 0 rgba(225, 29, 72, 0.35);
}

.btn-danger:hover {
  background: #ffe4e6;
}

.btn-success {
  background: #dcfce7;
  color: var(--success);
  box-shadow: 0 4px 0 rgba(22, 163, 74, 0.35);
}

.btn-success:hover {
  background: #bbf7d0;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

/* Join info grid */
.join-info {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 2fr;
  gap: 22px;
  margin-bottom: 22px;
}

.pin-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--warm-100);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.pin-box .label {
  color: var(--green-700);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.pin-big {
  font-size: clamp(3rem, 8vw, 4.6rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--green-900);
  font-family: 'Space Grotesk', ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: var(--radius);
  padding: 20px;
}

#qrCanvas {
  border-radius: 16px;
  background: #fff;
  padding: 10px;
  max-width: 100%;
}

.url-box {
  display: flex;
  gap: 10px;
  width: 100%;
}

.url-box input {
  flex: 1;
  font-size: 0.98rem;
  color: var(--text-light);
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 800;
  background: rgba(22, 163, 74, 0.16);
  color: #86efac;
}

.status-badge.off {
  background: rgba(225, 29, 72, 0.16);
  color: #fda4af;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.count-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.16);
  color: var(--amber-300);
  font-weight: 800;
  font-size: 0.95rem;
}

/* Responses */
.responses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.response-card {
  background: var(--warm-100);
  color: var(--text);
  border-radius: 18px;
  padding: 20px;
  font-size: 1.12rem;
  line-height: 1.5;
  box-shadow: var(--shadow-soft);
  animation: popIn .35s ease-out;
  word-break: break-word;
  font-weight: 600;
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Empty states */
.empty-state {
  text-align: center;
  color: #b8b4e6;
  padding: 52px 24px;
}

.empty-state .icon {
  display: block;
  width: 90px;
  height: 90px;
  margin: 0 auto 18px;
}

.empty-state .title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-light);
  margin-bottom: 8px;
}

.empty-state p {
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Student view */
.student-view {
  text-align: center;
  max-width: 620px;
  margin: 0 auto;
  padding: 6vh 20px 40px;
}

.student-view .logo {
  margin: 0 auto 20px;
}

.student-view h2 {
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  margin-bottom: 10px;
}

.question-display {
  font-size: clamp(1.25rem, 4vw, 1.55rem);
  color: var(--amber-300);
  margin-bottom: 30px;
  font-weight: 700;
  line-height: 1.35;
}

/* Pin input */
.pin-input-wrap {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 22px;
}

.pin-digit {
  width: 64px;
  height: 76px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-light);
  font-size: 2.2rem;
  font-weight: 800;
  text-align: center;
  font-family: 'Space Grotesk', monospace;
  transition: border-color .15s, box-shadow .15s;
  caret-color: var(--amber-400);
}

.pin-digit:focus {
  border-color: var(--amber-400);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.15);
  outline: none;
}

.pin-hint {
  text-align: center;
  color: #b8b4e6;
  font-size: 0.95rem;
  margin-top: 12px;
}

#responseInput {
  min-height: 160px;
  font-size: 1.25rem;
}

.success-check {
  width: 90px;
  height: 90px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #dcfce7;
  display: grid;
  place-items: center;
}

.success-check svg {
  width: 52px;
  height: 52px;
}

.closed-lock {
  width: 80px;
  height: 80px;
  margin: 0 auto 18px;
}

/* Soundwave decoration */
.soundwave {
  position: fixed;
  bottom: -20px;
  left: 0;
  right: 0;
  height: 140px;
  pointer-events: none;
  z-index: -1;
  opacity: 0.25;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 160' preserveAspectRatio='none'%3E%3Cpath fill='%23fbbf24' d='M0,96L48,90.7C96,85,192,75,288,80C384,85,480,107,576,112C672,117,768,107,864,90.7C960,75,1056,53,1152,48C1248,43,1344,53,1392,58.7L1440,64L1440,160L1392,160C1344,160,1248,160,1152,160C1056,160,960,160,864,160C768,160,672,160,576,160C480,160,384,160,288,160C192,160,96,160,48,160L0,160Z'%3E%3C/path%3E%3C/svg%3E") repeat-x bottom;
  background-size: cover;
  animation: wave 8s ease-in-out infinite alternate;
}

@keyframes wave {
  from { transform: translateY(0) scaleY(1); }
  to { transform: translateY(12px) scaleY(1.08); }
}

/* Helper text */
.helper-text {
  color: #b8b4e6;
  font-size: 1rem;
  margin-top: 10px;
}

/* Footer note */
.footer-note {
  text-align: center;
  color: #8a85b8;
  font-size: 0.9rem;
  margin-top: auto;
  padding-top: 36px;
}

/* Mobile */
@media (max-width: 720px) {
  .app { padding: 20px 18px 40px; }
  header { margin-bottom: 26px; }
  .card { padding: 22px; }
  .join-info { grid-template-columns: 1fr; }
  .pin-box { order: -1; }
  .responses-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .btn { width: 100%; }
  .btn-row { flex-direction: column; }
  .url-box { flex-direction: column; }
  .url-box input { width: 100%; }
  .pin-digit { width: 56px; height: 68px; font-size: 1.9rem; }
}

/* Landing page */
.app-center {
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 100vh;
  padding-top: 5vh;
}

.header-landing {
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.logo-lg {
  width: 92px;
  height: 92px;
  border-radius: 26px;
}

.logo-xl {
  width: 140px;
  height: 140px;
  border-radius: 34px;
}

.logo-xl .logo-img {
  padding: 16px;
}

.logo-lg svg {
  width: 64px;
  height: 64px;
}

.headline-stack {
  text-align: center;
}

.landing-card {
  width: 100%;
  max-width: 560px;
  padding: 34px 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.landing-card .lead {
  font-size: 1.15rem;
  line-height: 1.55;
  color: #e8e6f5;
  margin: 0 0 28px;
}

.landing-card .lead strong {
  color: var(--amber-300);
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.btn-hero {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  width: 100%;
  padding: 22px 24px;
  border-radius: 20px;
  text-align: left;
  text-decoration: none;
  font-size: 1.15rem;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}

.btn-hero .hero-icon {
  font-size: 2.2rem;
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 14px;
}

.btn-hero .hero-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-hero .hero-title {
  font-size: 1.35rem;
  font-weight: 800;
}

.btn-hero .hero-sub {
  font-size: 0.98rem;
  font-weight: 600;
  opacity: 0.85;
}

.btn-secondary {
  background: var(--green-700);
  color: var(--text-light);
  box-shadow: 0 6px 0 #221e5c;
}

.btn-secondary:hover {
  background: var(--green-600);
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  font-size: 0.98rem;
  color: #b8b4e6;
}

.feature-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.back-link {
  margin-left: auto;
  padding: 10px 16px;
  font-size: 0.95rem;
  text-decoration: none;
}

/* Mobile landing */
@media (max-width: 720px) {
  .landing-card { padding: 26px 22px; }
  .btn-hero { padding: 18px 18px; }
  .btn-hero .hero-icon { width: 46px; height: 46px; font-size: 1.8rem; }
  .btn-hero .hero-title { font-size: 1.2rem; }
  .btn-hero .hero-sub { font-size: 0.9rem; }
  .back-link { margin-left: 0; margin-top: 10px; width: auto; }
  header { flex-wrap: wrap; }
}

/* QR thumb next to pin */
.pin-with-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.qr-thumb {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 14px;
  background: var(--amber-400);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 0 #d97706;
  transition: transform .1s, box-shadow .15s, background .15s;
}

.qr-thumb:hover {
  background: var(--amber-300);
}

.qr-thumb:active {
  transform: translateY(4px) scale(0.97);
  box-shadow: 0 1px 0 #d97706;
}

.qr-thumb svg {
  width: 32px;
  height: 32px;
}

/* QR Modal */
.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.qr-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 12, 36, 0.92);
  backdrop-filter: blur(4px);
}

.qr-modal-content {
  position: relative;
  background: var(--warm-100);
  border-radius: var(--radius);
  padding: 34px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 520px;
  width: 100%;
  animation: popIn .3s ease-out;
}

.qr-modal-content canvas {
  width: 100%;
  max-width: 420px;
  height: auto;
  border-radius: 18px;
  background: #fff;
  padding: 14px;
}

.qr-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 2.2rem;
  color: var(--green-800);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: background .15s;
}

.qr-modal-close:hover {
  background: rgba(30, 26, 75, 0.08);
}

.qr-modal-hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

@media (max-width: 720px) {
  .qr-modal-content { padding: 24px 18px; }
  .qr-modal-content canvas { padding: 10px; }
  .qr-thumb { width: 46px; height: 46px; }
  .qr-thumb svg { width: 28px; height: 28px; }
}


.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.logo-lg .logo-img {
  padding: 12px;
}

.school-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 16px;
  background: rgba(15, 99, 14, 0.06);
  border-radius: var(--radius-sm);
}

.school-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.school-logo-img {
  width: 100%;
  max-width: 200px;
  height: auto;
  min-height: 50px;
  object-fit: contain;
}
