:root {
  --bg: #0f1117;
  --panel: #171a23;
  --tile: #202636;
  --text: #f5f7fb;
  --muted: #9ca3af;
  --blue: #2d8cff;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --border: rgba(255,255,255,.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  background: radial-gradient(circle at top left, rgba(45,140,255,.15), transparent 35%), var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  height: 64px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15,17,23,.85);
  border-bottom: 1px solid var(--border);
}

header span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

header button,
footer button,
.join-card button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  color: white;
  background: var(--blue);
  cursor: pointer;
  font-weight: 700;
}

.classroom {
  flex: 1;
  min-height: 0;
  padding: 16px;
  padding-bottom: 104px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.stage-area {
  flex: 1;
  min-height: 260px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  overflow: auto;
}

.student-dock {
  height: 170px;
  min-height: 170px;
  border-radius: 22px;
  background: rgba(23,26,35,.72);
  border: 1px solid var(--border);
  padding: 12px;
  overflow: hidden;
}

.dock-title {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dock-title span {
  color: var(--muted);
  font-size: 13px;
}

.student-strip {
  height: calc(100% - 32px);
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-top: 8px;
}

.tile {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--tile), #111827);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}

.tile.hand-raised {
  outline: 3px solid rgba(245,158,11,.95);
}

.stage-tile {
  min-height: 280px;
}

.dock-tile {
  min-width: 210px;
  width: 210px;
  height: 110px;
  border-radius: 16px;
  box-shadow: none;
  cursor: pointer;
}

.dock-tile:hover {
  outline: 2px solid rgba(45,140,255,.65);
}

.teacher-clickable {
  cursor: pointer;
}

.teacher-clickable:hover {
  outline: 2px solid rgba(245,158,11,.75);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #05070b;
}

.name {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  font-size: 14px;
}

.status {
  position: absolute;
  left: 14px;
  top: 14px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  color: #fde68a;
  font-size: 13px;
  font-weight: 700;
}

.metrics {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  color: #dbeafe;
  font-size: 12px;
  text-align: right;
  line-height: 1.25;
}

.dock-tile .name {
  left: 8px;
  bottom: 8px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 10px;
}

.dock-tile .status {
  left: 8px;
  top: 8px;
  padding: 5px 7px;
  font-size: 11px;
  border-radius: 9px;
}

.dock-tile .metrics {
  right: 8px;
  bottom: 8px;
  max-width: 100px;
  padding: 6px 8px;
  font-size: 10px;
  border-radius: 10px;
}

footer {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 12px;
  background: rgba(23,26,35,.92);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}

footer button {
  background: rgba(255,255,255,.08);
}

footer button.active {
  background: rgba(45,140,255,.35);
}

footer button.hand {
  background: rgba(245,158,11,.35);
}

footer button.hand.active {
  background: var(--yellow);
  color: #111827;
}

footer button.danger {
  background: var(--red);
}

footer button.disabled {
  opacity: .55;
  cursor: not-allowed;
}

.join {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(15,17,23,.95);
  padding: 20px;
}

.join.hidden {
  display: none;
}

.join-card {
  width: min(560px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: rgba(23,26,35,.95);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
}

.logo {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--blue);
  font-size: 28px;
  margin-bottom: 18px;
}

.join-card h1 {
  margin: 0 0 8px;
}

.join-card p,
.hint,
.class-links {
  color: var(--muted);
  line-height: 1.45;
}

.role-info {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(45,140,255,.16);
  border: 1px solid rgba(45,140,255,.35);
  color: var(--text);
  font-size: 14px;
}

.join-card label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
}

.join-card input {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.25);
  color: white;
  font-size: 16px;
  outline: none;
}

.join-card > button {
  width: 100%;
  margin-top: 14px;
}

.hint {
  margin-top: 16px;
  font-size: 13px;
  word-break: break-all;
}

.class-links {
  margin-top: 16px;
  display: grid;
  gap: 10px;
  font-size: 13px;
}

.class-links div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
}

.class-links b {
  display: block;
  color: var(--text);
  margin-bottom: 8px;
}

.class-links span {
  display: block;
  margin-top: 8px;
  word-break: break-all;
}

.class-links button {
  padding: 8px 10px;
  font-size: 12px;
}

@media (max-width: 700px) {
  .classroom {
    padding: 10px;
    padding-bottom: 96px;
  }

  .stage-area {
    grid-template-columns: 1fr;
  }

  .student-dock {
    height: 150px;
    min-height: 150px;
  }

  .dock-tile {
    min-width: 170px;
    width: 170px;
    height: 95px;
  }

  footer {
    width: calc(100% - 20px);
    left: 10px;
    right: 10px;
    transform: none;
    overflow-x: auto;
  }

  footer button {
    min-width: 120px;
  }
}