/* Name wheel tab (public/js/wheel.js) */
.wheel-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.wheel-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.wheel-box { position: relative; width: min(100%, 420px); aspect-ratio: 1; }
.wheel-box canvas { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: var(--shadow); }
.wheel-pointer { position: absolute; top: -10px; left: 50%; z-index: 2; width: 0; height: 0; transform: translateX(-50%);
  border-left: 16px solid transparent; border-right: 16px solid transparent; border-top: 30px solid var(--ink); filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.wheel-hub { position: absolute; top: 50%; left: 50%; z-index: 2; width: 23%; aspect-ratio: 1; padding: 0; transform: translate(-50%, -50%); border-radius: 50%;
  border: 5px solid #fff; font-weight: 800; font-size: clamp(15px, 3.6vw, 22px); letter-spacing: .02em;
  background: radial-gradient(circle at 35% 30%, #6ea0ff, var(--brand) 55%, var(--navy));
  box-shadow: 0 8px 22px rgba(107, 99, 224, .45), inset 0 -6px 12px rgba(0,0,0,.18); }
.wheel-song-sel { width: auto; min-width: 220px; max-width: 100%; }
.wheel-parts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 14px 0 4px; padding: 4px; border-radius: 16px;
  background: rgba(127, 140, 170, .12);
}
.wheel-part {
  min-height: 44px; border-radius: 12px; border: 0; box-shadow: none;
  background: transparent; color: inherit; font-weight: 800; font-size: 15px;
}
.wheel-part.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.wheel-gnum { width: 100% !important; max-width: 160px; font-size: 22px; font-weight: 800; text-align: center; }
.wheel-fs-x {
  display: none; position: absolute; top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right)); z-index: 50;
  width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25); background: rgba(20,24,40,.78); color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer; box-shadow: 0 8px 20px rgba(0,0,0,.28);
}
.wheel-fs-x:hover { background: #fff; color: var(--navy); }
.wheel-hub:disabled { opacity: .75; }
.wheel-tools { justify-content: center; }
.wheel-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 360px; overflow-y: auto; }
.wheel-chip { min-height: 36px; padding: 4px 12px; border-radius: 999px; font-size: 15px; width: auto; }
.wheel-chip.off { text-decoration: line-through; opacity: .5; }
.wheel-chip.done { background: var(--brand-soft); border-color: var(--brand); }
/* winner popup + fireworks live inside the stage so they also show in fullscreen */
.wheel-stage { position: relative; }
.wheel-fw { position: fixed; inset: 0; z-index: 90; width: 100vw; height: 100vh; pointer-events: none; }
.wheel-pop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(10, 18, 30, .55); animation: wheel-fade .2s ease-out; }
.wheel-pop-card { width: min(92vw, 640px); padding: 26px 22px 22px; text-align: center; border-radius: 24px; background: #fff; border: 3px solid var(--brand); box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: wheel-pop .45s cubic-bezier(.2, 1.4, .4, 1); }
.wheel-pop-card small { display: block; color: var(--muted); font-size: 16px; }
.wheel-pop-card b { display: block; margin: 6px 0 16px; font-size: clamp(34px, 9vw, 72px); line-height: 1.4; color: var(--brand-dark); overflow-wrap: anywhere; }
@keyframes wheel-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes wheel-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .wheel-pop, .wheel-pop-card { animation: none; } }
.wheel-chip.g-m { border-left: 5px solid #1c7ed6; }
.wheel-chip.g-f { border-left: 5px solid #d6336c; }
.wheel-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; max-height: 420px; overflow-y: auto; margin-top: 12px; }
.wheel-g { padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); border: 1px solid var(--line); }
.wheel-g b { display: block; margin-bottom: 4px; color: var(--brand-dark); }
.wheel-g ol { margin: 0; padding-left: 22px; font-size: 15px; line-height: 1.7; }
.wheel-stage:fullscreen { justify-content: center; background: var(--bg); padding: 12px; }
.wheel-stage:fullscreen .wheel-box { width: min(72vh, 86vw); }
.wheel-stage:fullscreen .wheel-fs-x { display: grid; place-items: center; }
[hidden] { display: none !important; }
@media (max-width: 860px) { .wheel-layout { grid-template-columns: 1fr; } }

.wheel-chk { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 8px 0; line-height: 1.6; }
.wheel-hist { margin: 10px 0; padding-left: 26px; max-height: 240px; overflow-y: auto; font-size: 15px; line-height: 1.8; }
.wheel-hist.tally { list-style: none; padding-left: 0; }
.wheel-hist .cnt { float: right; font-weight: 700; color: var(--brand-dark); }
.wheel-layout input[type="range"] { width: 100%; }

/* group-maker popup */
.wheel-gcard { width: min(96vw, 980px); max-height: 94vh; display: flex; flex-direction: column; padding: 18px 16px 16px; }
.wheel-pop-card.wheel-gcard small { font-size: 18px; font-weight: 700; color: var(--brand-dark); }
.wheel-ggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 12px 0 14px; overflow-y: auto; text-align: left; flex: 1; min-height: 0; max-height: 66vh; }
.wheel-ggrid .wheel-g li { font-size: 16px; overflow-wrap: anywhere; }
.wheel-pop-card.wheel-gcard .wheel-g b { margin: 0 0 4px; font-size: 17px; line-height: 1.5; color: var(--brand-dark); }
.wheel-ggrid .wheel-g.wait { opacity: .45; }
.wheel-ggrid .wheel-g li.ph { color: var(--muted); list-style: none; letter-spacing: 2px; }
.wheel-ggrid .wheel-g.active { border-color: #f0b000; background: #fff6dc; box-shadow: 0 0 0 3px rgba(240, 176, 0, .4); animation: wheel-shake .12s infinite alternate; }
.wheel-ggrid .wheel-g.done { animation: wheel-card .55s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes wheel-shake { from { transform: translateX(-1.5px) rotate(-.3deg); } to { transform: translateX(1.5px) rotate(.3deg); } }
@keyframes wheel-card { from { transform: translateY(24px) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .wheel-ggrid .wheel-g.active, .wheel-ggrid .wheel-g.done { animation: none; } }

/* finished result: poster look */
.wheel-gsub { margin-top: 8px; color: var(--muted); font-size: 17px; white-space: pre-line; line-height: 1.7; }
.wheel-gbrand { margin: 0 0 12px; font-weight: 700; color: var(--brand-dark); letter-spacing: .3px; }
.wheel-pop-card.wheel-gcard.final small { display: block; padding: 12px 18px; border-radius: 16px; color: #fff; font-size: clamp(24px, 4.2vw, 38px); line-height: 1.5; background: linear-gradient(100deg, #1f6f66, #2d8f7e 60%, #3aa68f); box-shadow: 0 6px 18px rgba(31, 111, 102, .35); }
.wheel-gcard.final .wheel-ggrid { gap: 14px; margin-top: 16px; }
.wheel-ggrid .wheel-g.done { padding: 0; overflow: hidden; border: 0; background: #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, .14); }
.wheel-pop-card.wheel-gcard .wheel-g.done b { margin: 0 0 6px; padding: 10px 14px; font-size: 18px; color: #fff; background: var(--gc, var(--brand)); border-radius: 0; }
.wheel-ggrid .wheel-g.done ol { padding: 2px 14px 12px 38px; }
.wheel-ggrid .wheel-g.done li::marker { color: var(--gc, var(--brand)); font-weight: 700; }

/* fixed columns: 2 for up to 4 groups, 3 for five or more (6 groups = 3 x 2); fewer on small screens */
.wheel-gcard { width: min(96vw, 1080px); }
.wheel-gcard.count-8, .wheel-gcard.count-10, .wheel-gcard.count-12 { width: min(98vw, 1360px); }
.wheel-ggrid.cols-1 { grid-template-columns: 1fr; }
.wheel-ggrid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wheel-ggrid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wheel-ggrid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wheel-ggrid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.wheel-ggrid.count-5 { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.wheel-ggrid.count-5 > .wheel-g { flex: 0 1 calc(33.333% - 10px); min-width: 200px; box-sizing: border-box; }
@media (max-width: 900px) { .wheel-ggrid.cols-5, .wheel-ggrid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .wheel-ggrid.cols-3, .wheel-ggrid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .wheel-ggrid.count-5 > .wheel-g { flex: 0 1 calc(50% - 10px); } }
@media (max-width: 440px) { .wheel-ggrid.cols-5, .wheel-ggrid.cols-4, .wheel-ggrid.cols-3, .wheel-ggrid.cols-2 { grid-template-columns: 1fr; } .wheel-ggrid.count-5 > .wheel-g { flex: 0 1 100%; } }
.wheel-fw.behind { z-index: 79; }
/* cards keep their full height and the grid scrolls (without this, short screens squash every card to one name) */
.wheel-ggrid { grid-auto-rows: max-content; align-content: start; }
.wheel-ggrid .wheel-g { min-height: min-content; }

/* last picked name, always visible under the wheel (also if the popup cannot be shown) */
.wheel-last { margin: 0; width: min(100%, 420px); padding: 10px 16px; border-radius: 14px; background: var(--brand-soft); border: 2px solid var(--brand); text-align: center; font-size: 18px; color: var(--muted); }
.wheel-last b { display: block; font-size: clamp(26px, 7vw, 40px); line-height: 1.5; color: var(--brand-dark); overflow-wrap: anywhere; }
/* PNG preview for phones */
.wheel-pv { position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 12px; background: rgba(10, 18, 30, .97); overflow-y: auto; }
.wheel-pv p { margin: 0; color: #fff; text-align: center; line-height: 1.7; font-size: 15px; }
.wheel-pv img { width: min(100%, 900px); height: auto; border-radius: 12px; background: #fff; }

/* phones: sizes are relative to the visible area (not 100vh, which runs under Safari's bottom toolbar); a close ✕ is always at the top */
.wheel-pop { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.wheel-pop-card { position: relative; max-height: 100%; overflow-y: auto; }
.wheel-gcard { max-height: 100%; overflow: hidden; }
.wheel-ggrid { max-height: none; }
.wheel-x { position: absolute; top: 8px; right: 8px; z-index: 3; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.wheel-x:hover { background: var(--brand-soft); }
.wheel-pop-card.wheel-gcard small, .wheel-pop-card small { padding-right: 56px; }
.wheel-pv .row { order: -1; }

/* ✕ on the picture preview: always visible in the top-right corner */
.wheel-pv .wheel-x-pv { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; z-index: 130; width: 48px; height: 48px; background: #fff; }
.wheel-pv p { padding-right: 52px; }
.wheel-pv { padding-top: max(66px, calc(env(safe-area-inset-top) + 58px)); }


/* Manual Group Manager below the spin */
.wheel-stage:fullscreen .wheel-group-mgmt {
  display: none !important;
}

.wheel-group-mgmt {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
  margin-top: 14px;
}

.wh-mgmt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line, #f1f5f9);
}

.wh-mgmt-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--brand-dark, #0f172a);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wh-mgmt-sub {
  font-size: 13px;
  color: var(--muted, #64748b);
  margin: 2px 0 0;
}

.wh-mgmt-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft, #f0fdf4);
  color: var(--brand, #166534);
  border: 1px solid #bbf7d0;
}

.wh-mgmt-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  margin-bottom: 14px;
}

.wh-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.wh-group-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 5px solid var(--gc, #2d8f7e);
  transition: all 0.2s ease;
  min-height: 120px;
}

.wh-group-card.drag-over {
  border-color: #0284c7;
  background: #f0f9ff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.wh-group-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
}

.wh-group-card-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--brand-dark, #0f172a);
}

.wh-student-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 48px;
}

.wh-student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.15s, transform 0.1s;
}

.wh-student-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.wh-student-item:active {
  cursor: grabbing;
}

.wh-student-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.wh-student-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: #1e293b;
}

.wh-gender-icon {
  font-size: 12px;
  font-weight: 700;
  flex: none;
}
.wh-gender-icon.f { color: #d6336c; }
.wh-gender-icon.m { color: #1c7ed6; }

.wh-student-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.wh-move-select {
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  height: 24px;
}

.wh-remove-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.wh-remove-btn:hover {
  color: #ef4444;
  background: #fee2e2;
}

.wh-unassigned-box {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

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

.wh-unassigned-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #fde68a;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.wh-unassigned-chip:hover {
  border-color: #f59e0b;
  background: #fef3c7;
}

.wh-empty-group {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  color: #94a3b8;
  height: 100%;
}

/* name wheel: the same dark teardrop button as the teaching-mode Spin; its tip points at the winner, so the separate triangle is gone */
.wheel-box .wheel-pointer { display: none; }
button.wheel-hub {
  width: 26%; height: auto; aspect-ratio: 100 / 110; padding: 8% 0 0; box-sizing: border-box; border: 0; border-radius: 0; box-shadow: none; transform: translate(-50%, -64%);
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 110'><defs><linearGradient id='g' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23505766'/><stop offset='.55' stop-color='%23262a35'/><stop offset='1' stop-color='%23101319'/></linearGradient><radialGradient id='h' cx='.32' cy='.3' r='.5'><stop offset='0' stop-color='white' stop-opacity='.55'/><stop offset='1' stop-color='white' stop-opacity='0'/></radialGradient></defs><path d='M50 3 C50 3 10 41 10 70 a40 40 0 0 0 80 0 C90 41 50 3 50 3Z' fill='url(%23g)' stroke='white' stroke-width='3.2'/><path d='M50 3 C50 3 10 41 10 70 a40 40 0 0 0 80 0 C90 41 50 3 50 3Z' fill='url(%23h)'/></svg>") center / 100% 100% no-repeat !important;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)); color: #fff; text-shadow: 0 2px 5px rgba(0, 0, 0, .7); position: absolute; display: grid; place-items: center; line-height: 1;
}
button.wheel-hub:hover:not(:disabled) { filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)) brightness(1.2); background-color: transparent; }
