/* Classes hub + student-facing classroom */

/* Game-style skin (see play.css): chunky cards with a solid "edge" shadow */
.classes-hub-screen,
.groups-screen {
  --cr-card: #ffffff;
  --cr-card-soft: #fffaf0;
  --cr-edge: rgba(29, 35, 64, 0.16);
  --cr-ring: rgba(29, 35, 64, 0.08);
  --cr-ink: var(--g-ink, #1d2340);
  --cr-glow: rgba(16, 40, 60, 0.12);
}

html[data-theme="dark"] .classes-hub-screen,
html[data-theme="dark"] .groups-screen {
  --cr-card: #15293d;
  --cr-card-soft: #1b3249;
  --cr-edge: rgba(0, 0, 0, 0.5);
  --cr-ring: rgba(255, 255, 255, 0.09);
  --cr-ink: #f3f7fb;
  --cr-glow: rgba(0, 0, 0, 0.35);
}

.classes-hub-screen {
  flex: 1;
  min-height: 0;
  overflow: visible;
  display: flex;
  background:
    radial-gradient(48% 42% at 6% 0%, rgba(255, 204, 51, 0.26), transparent 72%),
    radial-gradient(40% 38% at 96% 6%, rgba(255, 79, 139, 0.18), transparent 72%),
    radial-gradient(60% 50% at 50% 108%, rgba(63, 167, 255, 0.22), transparent 72%);
  border-radius: calc(24px * var(--ui-scale));
}

.classes-hub {
  width: min(calc(1100px * var(--ui-scale)), 100%);
  margin: 0 auto;
  padding: clamp(calc(24px * var(--ui-scale)), 5vh, calc(56px * var(--ui-scale))) calc(20px * var(--ui-scale)) calc(48px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 100%;
  box-sizing: border-box;
}

.classes-hub-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(12px * var(--ui-scale));
  margin-bottom: calc(22px * var(--ui-scale));
  width: 100%;
}

.classes-hub-head h1 {
  margin: 0;
  font-family: var(--g-font);
  font-size: clamp(2rem, 5.4vw, 3.3rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--cr-ink);
  text-shadow: 0 4px 0 color-mix(in srgb, var(--g-sun) 70%, transparent);
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.classes-hub-head h1::before {
  content: "";
  display: block;
  width: calc(64px * var(--ui-scale));
  height: calc(8px * var(--ui-scale));
  margin: 0 auto calc(12px * var(--ui-scale));
  border-radius: 999px;
  background: linear-gradient(90deg, var(--g-sky), var(--g-pink), var(--g-sun));
}

.classes-hub-lead {
  margin: 0;
  max-width: 36rem;
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  font-weight: 600;
}

.classes-hub-actions {
  display: flex;
  gap: calc(10px * var(--ui-scale));
  flex-wrap: wrap;
  justify-content: center;
  margin-top: calc(4px * var(--ui-scale));
}

.classes-hub-actions .primary,
.classes-hub-actions .ghost {
  min-width: calc(148px * var(--ui-scale));
  padding: calc(12px * var(--ui-scale)) calc(22px * var(--ui-scale));
  font-family: var(--g-font);
  font-size: calc(18px * var(--fs));
  font-weight: 600;
  border: 0;
  border-radius: calc(16px * var(--ui-scale));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.classes-hub-actions .primary {
  background: var(--g-sun);
  color: var(--g-ink);
  box-shadow: 0 6px 0 #c98f00;
}

.classes-hub-actions .ghost {
  background: var(--cr-card);
  color: var(--cr-ink);
  box-shadow: 0 6px 0 var(--cr-edge);
}

.classes-hub-actions .primary:hover,
.classes-hub-actions .ghost:hover {
  transform: translateY(-2px);
}

.classes-hub-actions .primary:active,
.classes-hub-actions .ghost:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--cr-edge);
}

.classes-hub-actions .primary:active {
  box-shadow: 0 2px 0 #c98f00;
}

.class-create-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: calc(12px * var(--ui-scale));
  margin-top: calc(12px * var(--ui-scale));
}

.class-create-form[hidden] {
  display: none !important;
}

.class-create-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
}

#class-create-name {
  width: min(22rem, 80vw);
  min-width: 12rem;
  margin: 0;
  text-align: center;
  background: var(--cr-card, #fff);
  color: var(--cr-ink, #1d2340);
  border: 3px solid var(--cr-ring, rgba(29, 35, 64, 0.16));
  border-radius: calc(18px * var(--ui-scale));
  box-shadow: 0 4px 0 var(--cr-edge, rgba(29, 35, 64, 0.16));
}

.class-create-form select {
  min-width: 12rem;
  margin: 0;
}

.class-create-form .class-create-copy {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
}

.class-create-copy input {
  width: auto;
  margin: 0;
}

.class-create-form .primary.small {
  min-height: 44px;
}

.classes-search-row {
  margin-bottom: calc(22px * var(--ui-scale));
  width: 100%;
  display: flex;
  justify-content: center;
}

.classes-search-row input {
  width: min(calc(420px * var(--ui-scale)), 100%);
  border: 3px solid var(--cr-ring);
  background: var(--cr-card);
  color: var(--cr-ink);
  border-radius: calc(18px * var(--ui-scale));
  padding: calc(13px * var(--ui-scale)) calc(16px * var(--ui-scale));
  font: inherit;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 0 var(--cr-edge);
}

.classes-search-row input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--g-sky) 70%, transparent);
}

.classes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(210px * var(--ui-scale)), calc(250px * var(--ui-scale))));
  gap: calc(22px * var(--ui-scale));
  width: 100%;
  justify-content: center;
  align-content: start;
  padding-bottom: calc(10px * var(--ui-scale));
}

/* Пусто: сообщение стоит по центру и по ширине, и по высоте страницы. */
.classes-grid:has(.classes-empty) {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: clamp(240px, 48vh, 560px);
}

.classes-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
  margin: 0;
  padding: calc(28px * var(--ui-scale)) calc(30px * var(--ui-scale));
  border-radius: calc(24px * var(--ui-scale));
  border: 2px dashed var(--cr-ring);
  background: color-mix(in srgb, var(--cr-card) 70%, transparent);
  color: var(--cr-ink);
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  font-weight: 700;
  text-align: center;
}

.classes-empty-ico {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  line-height: 1;
}

.classes-empty small {
  color: var(--muted);
  font-weight: 600;
}

.class-card {
  --card-tint: var(--g-sky);
  position: relative;
  border: 0;
  background: var(--cr-card);
  border-radius: calc(24px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  text-align: center;
  color: var(--cr-ink);
  font: inherit;
  box-shadow: 0 8px 0 var(--cr-edge), 0 18px 34px var(--cr-glow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  width: 100%;
  justify-self: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms + 80ms);
}

.class-card:nth-child(6n + 2) { --card-tint: var(--g-pink); }
.class-card:nth-child(6n + 3) { --card-tint: var(--g-mint); }
.class-card:nth-child(6n + 4) { --card-tint: var(--g-orange); }
.class-card:nth-child(6n + 5) { --card-tint: var(--g-violet); }
.class-card:nth-child(6n + 6) { --card-tint: var(--g-sun); }

.class-card:hover {
  transform: translateY(-6px) rotate(-0.6deg);
  box-shadow: 0 12px 0 var(--cr-edge), 0 26px 44px var(--cr-glow);
}

.class-card-main {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  width: 100%;
}

.class-card h3 {
  margin: calc(4px * var(--ui-scale)) 0 calc(8px * var(--ui-scale));
  font-family: var(--font);
  font-size: calc(22px * var(--fs));
  font-weight: 600;
  white-space: pre-line;
  line-height: 1.15;
}

.class-card .meta {
  display: inline-block;
  padding: calc(3px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: 999px;
  background: color-mix(in srgb, var(--card-tint) 18%, transparent);
  color: var(--cr-ink);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
}

.class-card-ship {
  width: 100%;
  height: calc(104px * var(--ui-scale));
  object-fit: contain;
  margin-bottom: calc(4px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale)) calc(6px * var(--ui-scale));
  box-sizing: border-box;
  border-radius: calc(18px * var(--ui-scale));
  background:
    radial-gradient(60% 50% at 78% 22%, rgba(255, 255, 255, 0.7), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--card-tint) 26%, #fff) 0%, color-mix(in srgb, var(--card-tint) 46%, #9fd4ff) 100%);
  box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--card-tint) 40%, transparent);
  transition: transform 0.4s ease;
}

html[data-theme="dark"] .class-card-ship {
  background:
    radial-gradient(60% 50% at 78% 22%, rgba(255, 255, 255, 0.16), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--card-tint) 32%, #15293d) 0%, color-mix(in srgb, var(--card-tint) 55%, #0b1a2c) 100%);
}

.class-card:hover .class-card-ship {
  transform: scale(1.03);
}

/* —— classroom (student view) —— */
.groups-screen {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  margin: calc(var(--space-sm) * -1);
  padding: 0;
}

.classroom-shell {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.groups-stage-bg {
  position: absolute;
  inset: 0;
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.32;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Removed: right-side bright BG overlay — layout handled by constructor now */
.groups-stage-bg-fore {
  display: none !important;
}

.groups-stage-bg-motion {
  position: absolute;
  inset: -8%;
  background:
    radial-gradient(ellipse 40% 28% at 18% 32%, rgba(255, 255, 255, 0.18), transparent 70%),
    radial-gradient(ellipse 32% 24% at 78% 58%, rgba(255, 240, 180, 0.12), transparent 72%),
    radial-gradient(circle 3px at 22% 70%, rgba(255, 255, 255, 0.35), transparent 100%),
    radial-gradient(circle 2px at 64% 24%, rgba(255, 255, 255, 0.28), transparent 100%),
    radial-gradient(circle 2.5px at 88% 42%, rgba(255, 255, 255, 0.22), transparent 100%);
  animation: bg-drift 28s ease-in-out infinite alternate;
  opacity: 0.85;
  pointer-events: none;
}

@keyframes bg-drift {
  0% { transform: translate3d(-1.2%, -0.6%, 0) scale(1.02); }
  100% { transform: translate3d(1.4%, 0.8%, 0) scale(1.05); }
}

[data-theme="dark"] .groups-stage-bg {
  opacity: 0.42;
}

.layout-main,
.layout-free-canvas {
  position: relative;
  z-index: 2;
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
}

.layout-flex-grow {
  display: none;
}

.layout-slot-row {
  display: contents;
}

.layout-slot {
  position: absolute;
  /* z-index set inline from layer: 1 = front … 10 = back */
  z-index: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.layout-slot-empty {
  display: none !important;
}

.layout-slot-image .layout-slot-img,
.layout-slot-img {
  object-fit: contain;
  pointer-events: none;
  max-width: 100%;
  max-height: 100%;
}

/* Always center content; never larger than the slot */
.layout-slot > .layout-block,
.layout-slot > .layout-sys-title,
.layout-slot > .classroom-ship-wrap,
.layout-slot > .classroom-water-wrap,
.layout-slot > .dojo-grid,
.layout-slot > .wheel-open-btn,
.layout-slot > .wheel-close-btn,
.layout-slot > .dock-chest-section,
.layout-slot > .dock-wheel,
.layout-slot > .layout-slot-img,
.layout-slot > img {
  margin: 0 auto;
  min-height: 0;
  box-sizing: border-box;
  max-width: 100%;
  max-height: 100%;
}

/* ⬚ Only frame: content locked to base size (does not grow with frame); shrinks if frame is smaller */
.layout-slot-contain > .layout-block,
.layout-slot-contain > .layout-sys-title,
.layout-slot-contain > .classroom-ship-wrap,
.layout-slot-contain > .classroom-water-wrap,
.layout-slot-contain > .dojo-grid,
.layout-slot-contain > .wheel-open-btn,
.layout-slot-contain > .wheel-close-btn,
.layout-slot-contain > .dock-chest-section,
.layout-slot-contain > .dock-wheel,
.layout-slot-contain > .layout-slot-img,
.layout-slot-contain > .layout-slot-text-inner,
.layout-slot-contain > img {
  width: calc(100% * var(--slot-fr-x, 1));
  height: calc(100% * var(--slot-fr-y, 1));
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  scale: none;
  flex-shrink: 1;
}

/* ▣ Frame + content: images/text always fill the slot (grow/shrink with frame).
   Do NOT also apply CSS scale on 100%-sized images — that overflows the frame. */
.layout-slot-scale > .layout-slot-img,
.layout-slot-scale > .layout-slot-text-inner,
.layout-slot-scale > img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  scale: none;
  flex-shrink: 1;
}

/* ▣ System widgets: scale from captured base size */
.layout-slot-scale > .layout-block,
.layout-slot-scale > .layout-sys-title,
.layout-slot-scale > .classroom-ship-wrap,
.layout-slot-scale > .classroom-water-wrap,
.layout-slot-scale > .dojo-grid,
.layout-slot-scale > .wheel-open-btn,
.layout-slot-scale > .wheel-close-btn {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  scale: var(--slot-cs-x, 1) var(--slot-cs-y, 1);
  transform-origin: center center;
  flex-shrink: 0;
}

/* ▣ Wheel / chests: fill the frame (no CSS scale — it overflows and breaks hit targets) */
.layout-slot-scale > .dock-chest-section,
.layout-slot-scale > .dock-wheel,
.layout-slot-scale > .shop-board {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  scale: none;
  flex-shrink: 1;
  min-height: 0;
}

.layout-slot-scale .dojo-grid {
  overflow: visible;
}

.layout-slot-image {
  overflow: hidden;
}

.layout-block-image {
  display: flex;
  justify-content: center;
  padding: calc(6px * var(--ui-scale)) 0;
  pointer-events: none;
}

.layout-block-image img {
  max-width: min(92%, 420px);
  max-height: calc(160px * var(--ui-scale));
  object-fit: contain;
  border-radius: 12px;
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.18));
}

.layout-sys-title {
  text-align: center;
  padding: 0 calc(48px * var(--ui-scale));
}

.classroom-chrome-btn {
  position: absolute;
  top: calc(8px * var(--ui-scale));
  z-index: 8;
}

#btn-groups-back {
  z-index: 30;
  pointer-events: auto;
}

.classroom-chrome-btn.classroom-back {
  left: calc(10px * var(--ui-scale));
}

.classroom-chrome-end {
  right: calc(10px * var(--ui-scale));
  left: auto;
}

.classroom-hero {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: calc(48px * var(--ui-scale)) 1fr calc(48px * var(--ui-scale));
  align-items: start;
  padding: calc(4px * var(--ui-scale)) calc(12px * var(--ui-scale)) 0;
  min-height: 0;
}

.classroom-back {
  width: calc(44px * var(--ui-scale));
  height: calc(44px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale));
  border: 0;
  background: var(--cr-card);
  color: var(--cr-ink);
  box-shadow: 0 4px 0 var(--cr-edge);
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.classroom-back:hover {
  transform: translateY(-2px);
}

.classroom-back:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--cr-edge);
}

.classroom-back-ico {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
  transform: translateY(-1px);
}

.classroom-secret {
  width: calc(36px * var(--ui-scale));
  height: calc(36px * var(--ui-scale));
  justify-self: end;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: default;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.classroom-shell:hover .classroom-secret,
.classroom-secret:focus-visible {
  opacity: 0.35;
  color: var(--muted);
  cursor: pointer;
}

.classroom-secret:hover {
  opacity: 0.85;
  background: var(--panel-soft);
  color: var(--ink);
}

.class-settings-btn {
  z-index: 30;
  width: calc(36px * var(--ui-scale));
  height: calc(36px * var(--ui-scale));
  padding: 0;
  border: 0;
  border-radius: calc(10px * var(--ui-scale));
  background: var(--g-sun, #ffcc33);
  cursor: pointer;
  opacity: 1;
}

.classroom-dock .class-settings-btn {
  z-index: 40;
}

.classroom-shell:has(#classroom-dock:not([hidden])) #btn-groups-settings,
.classroom-shell:has(#classroom-shop:not([hidden])) #btn-groups-settings {
  display: none;
}

.class-settings-btn:hover {
  transform: translateY(-2px);
}

.class-settings-btn:active {
  transform: translateY(1px);
}

.class-settings-btn.is-secret {
  opacity: 0;
  background: transparent;
}

.class-settings-btn.is-secret:focus-visible,
.class-settings-btn.is-secret:hover {
  opacity: 1;
  background: var(--g-sun, #ffcc33);
}

.class-settings-btn.is-secret:hover,
.class-settings-btn.is-secret:active {
  transform: none;
}

.settings-btn-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.settings-btn-swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid var(--line);
  padding: 0;
  cursor: pointer;
}

#settings-btn-hide.on,
.settings-btn-swatch.on {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--panel);
}

.classroom-ship-wrap {
  position: relative;
  text-align: center;
  pointer-events: none;
  padding: 0;
  transform: none;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  opacity: 1;
}

.ship-stage {
  position: relative;
  width: min(100%, calc(460px * var(--ui-scale)));
  max-width: 100%;
  margin: 0 auto;
  height: min(70%, calc(160px * var(--ui-scale)));
  min-height: calc(96px * var(--ui-scale));
  overflow: visible;
  perspective: 680px;
  flex: 1 1 auto;
}

.classroom-ship {
  position: absolute;
  left: 50%;
  bottom: calc(-6px * var(--ui-scale));
  z-index: 2;
  width: min(58vw, var(--ship-max));
  height: calc(170px * var(--ui-scale));
  max-height: none;
  transform: translateX(-50%);
  filter: drop-shadow(0 10px 18px rgba(0, 40, 80, 0.3));
  animation: ship-rock 5.6s ease-in-out infinite;
  transform-origin: 50% 94%;
  pointer-events: none;
  display: grid;
  place-items: end center;
  overflow: visible;
}

/* Hide SVG water shadow — stage water provides contact */
.classroom-ship .part-shadow {
  opacity: 0.35;
}

.classroom-ship img,
.classroom-ship svg.ship-svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  overflow: visible;
}

.classroom-ship .part-sail-main,
.classroom-ship .part-sail-jib,
.classroom-ship .part-flag-l,
.classroom-ship .part-flag-r {
  transform-box: view-box;
  will-change: transform;
}

.classroom-ship .part-sail-main {
  transform-origin: 240px 73px;
}
.classroom-ship .part-sail-jib {
  transform-origin: 360px 110px;
}
.classroom-ship .part-flag-l,
.classroom-ship .part-flag-r {
  transform-origin: 400px 168px;
}

/* Wind: reef / billow sails */
.classroom-ship.wind-calm .part-sail-main {
  animation: sail-reef 1.8s ease-in-out forwards;
}
.classroom-ship.wind-calm .part-sail-jib {
  animation: sail-jib-reef 1.6s ease-in-out forwards;
}
.classroom-ship.wind-calm .part-flag-l,
.classroom-ship.wind-calm .part-flag-r {
  animation: flag-droop 2.4s ease-in-out infinite;
}

.classroom-ship.wind-breeze .part-sail-main {
  animation: sail-billow 3.2s ease-in-out infinite;
}
.classroom-ship.wind-breeze .part-sail-jib {
  animation: sail-jib-billow 2.8s ease-in-out infinite;
}
.classroom-ship.wind-breeze .part-flag-l {
  animation: flag-flutter 1.8s ease-in-out infinite;
}
.classroom-ship.wind-breeze .part-flag-r {
  animation: flag-flutter 1.8s ease-in-out infinite 0.2s;
}

.classroom-ship.wind-gale .part-sail-main {
  animation: sail-gale 2.2s ease-in-out infinite;
}
.classroom-ship.wind-gale .part-sail-jib {
  animation: sail-jib-gale 1.8s ease-in-out infinite;
}
.classroom-ship.wind-gale .part-flag-l,
.classroom-ship.wind-gale .part-flag-r {
  animation: flag-gale 0.9s ease-in-out infinite;
}

@keyframes ship-rock {
  0%, 100% { transform: translateX(-50%) rotate(-1.2deg); }
  50% { transform: translateX(-50%) rotate(1.4deg); }
}
@keyframes sail-reef {
  0% { transform: scaleY(1); }
  100% { transform: scaleY(0.12); }
}
@keyframes sail-jib-reef {
  0% { transform: scale(1, 1); opacity: 1; }
  100% { transform: scale(0.35, 0.2); opacity: 0.35; }
}
@keyframes sail-billow {
  0%, 100% { transform: scaleY(1) skewX(0deg); }
  50% { transform: scaleY(1.02) skewX(-1.5deg); }
}
@keyframes sail-jib-billow {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-3deg); }
}
@keyframes sail-gale {
  0%, 100% { transform: scaleY(1) skewX(-2deg); }
  50% { transform: scaleY(1.04) skewX(2.5deg); }
}
@keyframes sail-jib-gale {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(5deg); }
}
@keyframes flag-flutter {
  0%, 100% { transform: rotate(0deg) skewY(0deg); }
  50% { transform: rotate(-8deg) skewY(4deg); }
}
@keyframes flag-droop {
  0%, 100% { transform: rotate(12deg) scaleX(0.85); }
  50% { transform: rotate(16deg) scaleX(0.8); }
}
@keyframes flag-gale {
  0%, 100% { transform: rotate(-6deg) skewY(-6deg); }
  50% { transform: rotate(10deg) skewY(8deg); }
}

.classroom-water-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  perspective: 680px;
  overflow: visible;
}

.classroom-water-wrap .ship-water {
  position: relative;
  left: auto;
  bottom: auto;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: calc(72px * var(--ui-scale));
  transform: rotateX(58deg) scaleY(1.15);
  transform-origin: 50% 50%;
  overflow: hidden;
  border-radius: 8% 8% 42% 42% / 10% 10% 55% 55%;
  mask-image: linear-gradient(180deg, transparent 0%, #000 18%, #000 100%);
  box-shadow:
    0 18px 28px rgba(8, 50, 80, 0.22),
    inset 0 12px 20px rgba(255, 255, 255, 0.12);
}

.ship-water {
  position: absolute;
  left: 50%;
  bottom: calc(-88px * var(--ui-scale));
  z-index: 1;
  width: 118%;
  height: calc(132px * var(--ui-scale));
  transform: translateX(-50%) rotateX(58deg) scaleY(1.2);
  transform-origin: 50% 100%;
  overflow: hidden;
  border-radius: 8% 8% 42% 42% / 10% 10% 55% 55%;
  mask-image: linear-gradient(180deg, transparent 0%, #000 18%, #000 100%);
  box-shadow:
    0 18px 28px rgba(8, 50, 80, 0.22),
    inset 0 12px 20px rgba(255, 255, 255, 0.12);
}

.water-deep {
  position: absolute;
  inset: 8% 2% 0;
  border-radius: 12% 12% 40% 40% / 18% 18% 60% 60%;
  background:
    linear-gradient(180deg, rgba(34, 160, 200, 0.35) 0%, rgba(14, 116, 144, 0.7) 35%, rgba(6, 55, 78, 0.92) 100%),
    repeating-linear-gradient(
      95deg,
      transparent 0 18px,
      rgba(255, 255, 255, 0.04) 18px 20px
    );
}

.water-mid {
  position: absolute;
  left: -18%;
  bottom: 18%;
  width: 136%;
  height: 38%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.5), rgba(14, 165, 233, 0.22));
  animation: water-sway 3.4s ease-in-out infinite;
}

.water-foam {
  position: absolute;
  left: -22%;
  bottom: 42%;
  width: 144%;
  height: 18%;
  border-radius: 50%;
  background: rgba(224, 242, 254, 0.62);
  box-shadow: 0 0 14px rgba(186, 230, 253, 0.45);
  animation: water-sway 2.6s ease-in-out infinite reverse;
}

.water-shine {
  position: absolute;
  left: 18%;
  bottom: 52%;
  width: 42%;
  height: 10%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: water-shine 3.8s ease-in-out infinite;
}

.splash {
  position: absolute;
  bottom: 48%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(240, 249, 255, 0.95);
  animation: splash-pop 2.8s ease-in-out infinite;
}
.splash-l { left: 18%; animation-delay: 0.15s; }
.splash-m { left: 48%; width: 6px; height: 6px; animation-delay: 0.7s; }
.splash-r { right: 18%; animation-delay: 1.25s; }

@keyframes water-sway {
  0%, 100% { transform: translateX(-3%) scaleY(1); }
  50% { transform: translateX(4%) scaleY(1.1); }
}

@keyframes water-shine {
  0%, 100% { opacity: 0.22; transform: translateX(-6%); }
  50% { opacity: 0.8; transform: translateX(8%); }
}

@keyframes splash-pop {
  0%, 100% { transform: translateY(0) scale(0.5); opacity: 0; }
  35% { transform: translateY(-10px) scale(1); opacity: 0.9; }
  70% { opacity: 0.12; }
}


.classroom-title {
  margin: 0 0 calc(2px * var(--ui-scale));
  padding: calc(4px * var(--ui-scale)) calc(36px * var(--ui-scale)) calc(6px * var(--ui-scale));
  width: fit-content;
  box-sizing: border-box;
  font-family: var(--font);
  font-size: clamp(1.5rem, 3.2vw, 2.05rem);
  font-weight: 600;
  color: var(--cr-ink);
  background: var(--cr-card);
  border-radius: calc(22px * var(--ui-scale));
  box-shadow: 0 6px 0 var(--cr-edge), 0 14px 30px var(--cr-glow);
  position: relative;
  z-index: 3;
  white-space: pre-line;
  line-height: 1.2;
  max-width: min(92vw, 34rem);
  margin-left: auto;
  margin-right: auto;
}

.classroom-title:not(:empty)::before,
.classroom-title:not(:empty)::after {
  content: "★";
  position: absolute;
  top: 50%;
  font-size: 0.62em;
  line-height: 1;
  color: var(--g-sun);
  text-shadow: 0 2px 0 #c98f00;
  transform: translateY(-50%) rotate(-12deg);
}

.classroom-title::before { left: calc(12px * var(--ui-scale)); }
.classroom-title::after { right: calc(12px * var(--ui-scale)); transform: translateY(-50%) rotate(12deg); }

.classroom-ship-name {
  margin: calc(36px * var(--ui-scale)) auto 0;
  padding: calc(2px * var(--ui-scale)) calc(14px * var(--ui-scale)) calc(3px * var(--ui-scale));
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  font-family: var(--g-font);
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  font-weight: 600;
  color: var(--g-ink);
  background: color-mix(in srgb, #fff 78%, transparent);
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(29, 35, 64, 0.14);
  opacity: 1;
  position: relative;
  z-index: 3;
  line-height: 1.15;
  flex: 0 0 auto;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
}

.classroom-ship-name-input {
  font: inherit;
  color: inherit;
  text-align: center;
  border: 0;
  background: transparent;
  width: 12rem;
  max-width: 70vw;
  padding: 0;
  margin: 0;
  outline: none;
  pointer-events: auto;
}

.classroom-ship-name:empty {
  visibility: hidden;
}

/* Dark theme: keep models fully opaque — no brightness/contrast filters
   (those punched white speckles through PNG alpha on the ship hull). */
html[data-theme="dark"] .classroom-ship,
html[data-theme="dark"] .classroom-ship img,
html[data-theme="dark"] .classroom-ship-img,
html[data-theme="dark"] .classroom-ship svg,
html[data-theme="dark"] .dojo-avatar,
html[data-theme="dark"] .dojo-avatar-anim,
html[data-theme="dark"] .dojo-avatar-anim img,
html[data-theme="dark"] .layout-slot-img,
html[data-theme="dark"] .chest-fallback-img,
html[data-theme="dark"] .chest-closed img,
html[data-theme="dark"] .chest-base img,
html[data-theme="dark"] .chest-lid img {
  opacity: 1 !important;
}

html[data-theme="dark"] .classroom-ship-wrap,
html[data-theme="dark"] .ship-stage {
  opacity: 1;
}

html[data-theme="dark"] .classroom-ship {
  z-index: 2;
  /* Avoid drop-shadow on raster PNG — it speckles punched alpha as white holes */
  filter: none;
}

html[data-theme="dark"] .classroom-ship img,
html[data-theme="dark"] .classroom-ship-img {
  filter: none;
  /* Soft shadow without alpha re-rasterization */
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.4);
}

.groups-panel label.grp-name-label {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

.groups-panel label.grp-name-label.muted.small,
label.grp-name-label.muted.small {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--muted);
}

.groups-panel label.grp-name-label textarea#grp-name,
#grp-name.grp-name-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  resize: vertical;
  min-height: 3.2em;
  font: inherit;
  font-family: inherit;
  font-size: var(--text);
  font-weight: 400;
  line-height: 1.35;
  white-space: pre-wrap;
  padding: 8px 10px;
  color: var(--ink);
}

.grp-name-hint {
  margin: 4px 0 10px;
}

.drop-hint {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  z-index: 25;
  padding: 14px 20px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 92%, #000);
  color: #fff;
  font-weight: 800;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.dojo-grid {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  align-items: center;
  gap: calc(12px * var(--ui-scale));
  padding: calc(8px * var(--ui-scale));
  margin: 0;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}

.dojo-grid.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.dojo-card-wrap {
  zoom: var(--students-zoom, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(6px * var(--ui-scale));
  width: max-content;
  min-width: calc(var(--avatar-size) + 28px * var(--ui-scale));
  max-width: min(52vw, calc(260px * var(--ui-scale)));
  overflow: visible;
  flex: 0 0 auto;
}

.dojo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: calc(4px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale)) calc(10px * var(--ui-scale));
  width: max-content;
  min-width: calc(var(--avatar-size) + 28px * var(--ui-scale));
  max-width: min(52vw, calc(260px * var(--ui-scale)));
  min-height: calc(168px * var(--ui-scale));
  border-radius: calc(22px * var(--ui-scale));
  background: var(--cr-card);
  border: 0;
  box-shadow: 0 6px 0 var(--cr-edge), 0 14px 26px var(--cr-glow);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-align: center;
  color: var(--cr-ink);
  font: inherit;
  overflow: visible;
  isolation: isolate;
}

.dojo-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(62% 46% at 50% 58%, color-mix(in srgb, var(--card-tint, var(--g-sky)) 30%, transparent), transparent 72%),
    linear-gradient(180deg, color-mix(in srgb, var(--card-tint, var(--g-sky)) 24%, transparent) 0%, transparent 62%);
  box-shadow: inset 0 calc(5px * var(--ui-scale)) 0 var(--card-tint, var(--g-sky));
}

.dojo-card:hover {
  transform: translateY(-5px) rotate(-0.8deg);
  box-shadow: 0 10px 0 var(--cr-edge), 0 22px 34px var(--cr-glow);
}

.dojo-card:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--cr-edge), 0 8px 16px var(--cr-glow);
}

.dojo-card.whole {
  --card-tint: var(--g-sun);
}

.dojo-avatar-box {
  width: var(--avatar-size);
  height: calc(118px * var(--ui-scale));
  display: grid;
  place-items: center;
  overflow: visible;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.dojo-avatar-anim {
  display: grid;
  place-items: center;
  width: var(--avatar-size);
  height: calc(118px * var(--ui-scale));
  position: relative;
  left: auto;
  transform-origin: 50% 85%;
}

.dojo-whole-ico {
  width: calc(96px * var(--ui-scale));
  height: calc(96px * var(--ui-scale));
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.45rem;
  background: color-mix(in srgb, var(--accent) 18%, var(--panel-soft));
  border: 3px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

.dojo-avatar {
  width: var(--avatar-size);
  height: calc(118px * var(--ui-scale));
  max-width: var(--avatar-size);
  max-height: calc(118px * var(--ui-scale));
  object-fit: contain;
  object-position: center bottom;
  background: transparent;
  border: 0;
  display: block;
  margin: 0;
  transform: none;
}

svg.dojo-avatar.monster-svg {
  overflow: visible;
  width: 100%;
  height: 100%;
}

.monster-svg .part-shadow,
.monster-svg .part-foot-l,
.monster-svg .part-foot-r,
.monster-svg .part-leg-l,
.monster-svg .part-leg-r,
.monster-svg .part-arm-l,
.monster-svg .part-arm-r,
.monster-svg .part-body,
.monster-svg .part-face,
.monster-svg .part-ear-l,
.monster-svg .part-ear-r,
.monster-svg .part-eye,
.monster-svg .part-accent,
.monster-svg .part-mouth,
.monster-svg .part-cheek-l,
.monster-svg .part-cheek-r {
  transform-box: view-box;
  transform-origin: center;
  will-change: transform;
  /* keep painted eyes/face visible during blink (scaleY) */
  opacity: 1;
  visibility: visible;
}

.monster-svg .part-eye,
.monster-svg .part-eye-1,
.monster-svg .part-eye-2,
.monster-svg .part-eye-3 {
  opacity: 1 !important;
  visibility: visible !important;
}

.monster-svg .part-shadow { transform-origin: 100px 228px; }
.monster-svg .part-foot-l { transform-origin: 72px 214px; }
.monster-svg .part-foot-r { transform-origin: 128px 214px; }
.monster-svg .part-leg-l { transform-origin: 72px 176px; }
.monster-svg .part-leg-r { transform-origin: 128px 176px; }
.monster-svg .part-arm-l { transform-origin: 42px 100px; }
.monster-svg .part-arm-r { transform-origin: 158px 100px; }
.monster-svg .part-body { transform-origin: 100px 170px; }
.monster-svg .part-face { transform-origin: 100px 100px; }
.monster-svg .part-ear-l { transform-origin: 62px 56px; }
.monster-svg .part-ear-r { transform-origin: 138px 56px; }
.monster-svg .part-eye { transform-origin: 100px 88px; }
.monster-svg .part-accent { transform-origin: 100px 52px; }
.monster-svg .part-mouth { transform-origin: 100px 118px; }
.monster-svg .part-cheek-l { transform-origin: 50px 112px; }
.monster-svg .part-cheek-r { transform-origin: 150px 112px; }

/* Idle: arms / blink / ears — paused during mood */
.dojo-avatar-anim:not(.is-rigged):not(.mood-happy):not(.mood-sad).alive-sway,
.dojo-avatar-anim:not(.is-rigged):not(.mood-happy):not(.mood-sad).alive-bounce,
.dojo-avatar-anim:not(.is-rigged):not(.mood-happy):not(.mood-sad).alive-wiggle {
  animation: png-idle-bob 3.2s ease-in-out infinite;
}

/* Photo / bean monsters (raster SVG): same whole-body bob as plain PNG students.
   They are marked is-rigged but have no waving arms — only a still image in part-body. */
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad):has(.monster-svg--raster).alive-sway,
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad):has(.monster-svg--raster).alive-bounce,
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad):has(.monster-svg--raster).alive-wiggle {
  animation: png-idle-bob 3.2s ease-in-out infinite;
}

.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-arm-l {
  animation: part-arm-l-wave 2.6s ease-in-out infinite;
}
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-arm-r {
  animation: part-arm-r-wave 2.6s ease-in-out infinite 0.2s;
}
.dojo-avatar-anim.is-rigged.alive-bounce:not(.mood-happy):not(.mood-sad) .part-arm-l { animation-duration: 2.1s; }
.dojo-avatar-anim.is-rigged.alive-bounce:not(.mood-happy):not(.mood-sad) .part-arm-r { animation-duration: 2.1s; animation-delay: 0.12s; }
.dojo-avatar-anim.is-rigged.alive-wiggle:not(.mood-happy):not(.mood-sad) .part-arm-l { animation: part-arm-l-wave 1.8s ease-in-out infinite; }
.dojo-avatar-anim.is-rigged.alive-wiggle:not(.mood-happy):not(.mood-sad) .part-arm-r { animation: part-arm-r-wave 1.8s ease-in-out infinite 0.15s; }

.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-ear-l { animation: part-ear-l 2.8s ease-in-out infinite; }
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-ear-r { animation: part-ear-r 2.8s ease-in-out infinite 0.14s; }
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-accent { animation: part-accent-bob 3s ease-in-out infinite; }
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-eye,
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-eye-1,
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-eye-2,
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-eye-3 { animation: part-blink 4.6s ease-in-out infinite; }
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-eye-2 { animation-delay: 0.35s; }
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-eye-3 { animation-delay: 0.7s; }
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-cheek-l,
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-cheek-r { animation: part-cheek-glow 3.8s ease-in-out infinite; }
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .part-mouth { animation: part-mouth-idle 4.2s ease-in-out infinite; }

@keyframes png-idle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes part-arm-l-wave {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-22deg); }
}
@keyframes part-arm-r-wave {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(22deg); }
}
@keyframes part-ear-l {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-10deg); }
}
@keyframes part-ear-r {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(10deg); }
}
@keyframes part-accent-bob {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(5deg); }
}
@keyframes part-blink {
  0%, 88%, 96%, 100% { transform: scaleY(1); }
  91%, 93% { transform: scaleY(0.08); }
}
@keyframes part-cheek-glow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.95; }
}
@keyframes part-mouth-idle {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.06); }
}

/* Mood: clear joy jump / clear sadness — works for PNG + SVG */
.dojo-avatar-anim.mood-happy {
  animation: mood-jump-happy 2s cubic-bezier(0.34, 1.4, 0.64, 1);
  transform-origin: 50% 90%;
}
.dojo-avatar-anim.mood-sad {
  animation: mood-droop-sad 2s ease-in-out;
  transform-origin: 50% 90%;
}

.dojo-avatar-anim.mood-happy::after {
  content: "✦";
  position: absolute;
  width: auto;
  height: auto;
  background: none;
  color: #fbbf24;
  font-size: 18px;
  top: -6%;
  right: 2%;
  opacity: 1;
  pointer-events: none;
  animation: mood-spark 2s ease-in-out;
}
.dojo-avatar-anim.mood-sad::after {
  content: "💧";
  position: absolute;
  width: auto;
  height: auto;
  background: none;
  font-size: 14px;
  top: 18%;
  right: 8%;
  opacity: 1;
  pointer-events: none;
  animation: mood-tear 2s ease-in-out;
}

@keyframes mood-jump-happy {
  0%, 100% { transform: translateY(0) rotate(0); }
  12% { transform: translateY(-22px) rotate(-6deg); }
  24% { transform: translateY(-4px) rotate(5deg); }
  38% { transform: translateY(-26px) rotate(-4deg); }
  52% { transform: translateY(-2px) rotate(4deg); }
  68% { transform: translateY(-16px) rotate(-3deg); }
  82% { transform: translateY(0) rotate(2deg); }
}
@keyframes mood-droop-sad {
  0%, 100% { transform: translateY(0) rotate(0) scale(1); filter: saturate(1) brightness(1); }
  25% { transform: translateY(6px) rotate(-4deg) scale(0.96); filter: saturate(0.55) brightness(0.92); }
  55% { transform: translateY(10px) rotate(3deg) scale(0.94); filter: saturate(0.35) brightness(0.88); }
  80% { transform: translateY(4px) rotate(-2deg) scale(0.97); filter: saturate(0.7) brightness(0.95); }
}
@keyframes mood-spark {
  0%, 100% { opacity: 0; transform: translateY(6px) scale(0.6); }
  25%, 65% { opacity: 1; transform: translateY(-4px) scale(1.2); }
}
@keyframes mood-tear {
  0% { opacity: 0; transform: translateY(-4px); }
  30%, 70% { opacity: 1; transform: translateY(10px); }
  100% { opacity: 0; transform: translateY(18px); }
}

.dojo-avatar-anim.is-rigged.mood-happy .part-arm-l { animation: mood-arm-l-happy 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-happy .part-arm-r { animation: mood-arm-r-happy 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-happy .part-ear-l { animation: mood-ear-l-happy 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-happy .part-ear-r { animation: mood-ear-r-happy 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-happy .part-mouth { animation: mood-mouth-happy 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-happy .part-eye,
.dojo-avatar-anim.is-rigged.mood-happy .part-eye-1,
.dojo-avatar-anim.is-rigged.mood-happy .part-eye-2,
.dojo-avatar-anim.is-rigged.mood-happy .part-eye-3 { animation: mood-eye-happy 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-happy .part-cheek-l,
.dojo-avatar-anim.is-rigged.mood-happy .part-cheek-r { animation: mood-cheek-happy 2s ease-in-out; }

.dojo-avatar-anim.is-rigged.mood-sad .part-arm-l { animation: mood-arm-l-sad 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-sad .part-arm-r { animation: mood-arm-r-sad 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-sad .part-ear-l { animation: mood-ear-l-sad 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-sad .part-ear-r { animation: mood-ear-r-sad 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-sad .part-mouth { animation: mood-mouth-sad 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-sad .part-face { animation: mood-face-sad 2s ease-in-out; }
.dojo-avatar-anim.is-rigged.mood-sad .part-eye,
.dojo-avatar-anim.is-rigged.mood-sad .part-eye-1,
.dojo-avatar-anim.is-rigged.mood-sad .part-eye-2,
.dojo-avatar-anim.is-rigged.mood-sad .part-eye-3 {
  animation: none;
  transform: scaleY(0.72) translateY(3px);
}

@keyframes mood-arm-l-happy {
  0%, 100% { transform: rotate(0); }
  20%, 55% { transform: rotate(-55deg); }
  35% { transform: rotate(-35deg); }
}
@keyframes mood-arm-r-happy {
  0%, 100% { transform: rotate(0); }
  20%, 55% { transform: rotate(55deg); }
  35% { transform: rotate(35deg); }
}
@keyframes mood-ear-l-happy {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(-20deg); }
}
@keyframes mood-ear-r-happy {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(20deg); }
}
@keyframes mood-mouth-happy {
  0%, 100% { transform: scaleY(1); }
  40%, 70% { transform: scaleY(1.35); }
}
@keyframes mood-eye-happy {
  0%, 100% { transform: scaleY(1); }
  30%, 70% { transform: scaleY(0.45) translateY(3px); }
}
@keyframes mood-cheek-happy {
  0%, 100% { opacity: 0.7; }
  40%, 70% { opacity: 1; }
}
@keyframes mood-arm-l-sad {
  0%, 100% { transform: rotate(0); }
  35%, 70% { transform: rotate(28deg) translateY(4px); }
}
@keyframes mood-arm-r-sad {
  0%, 100% { transform: rotate(0); }
  35%, 70% { transform: rotate(-28deg) translateY(4px); }
}
@keyframes mood-ear-l-sad {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(18deg); }
}
@keyframes mood-ear-r-sad {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(-18deg); }
}
@keyframes mood-mouth-sad {
  0%, 100% { transform: scaleY(1) translateY(0); }
  40%, 70% { transform: scaleY(0.55) translateY(4px); }
}
@keyframes mood-face-sad {
  0%, 100% { transform: translateY(0) rotate(0); }
  40%, 70% { transform: translateY(5px) rotate(-5deg); }
}

@media (prefers-reduced-motion: reduce) {
  .dojo-avatar-anim,
  .dojo-avatar-anim *,
  .classroom-ship,
  .classroom-ship * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.dojo-name {
  font-family: var(--g-font);
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--cr-ink);
  width: max-content;
  min-width: var(--avatar-size);
  max-width: min(90vw, calc(240px * var(--ui-scale)));
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow: visible;
  text-overflow: clip;
  margin-top: auto;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  line-height: 1.25;
  letter-spacing: normal;
  font-stretch: normal;
  padding: 0 2px;
  text-align: center;
}

.dojo-bday {
  font-family: var(--font);
  font-weight: 600;
  font-synthesis: none;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.15;
  margin-top: 2px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  letter-spacing: 0.02em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dojo-pts {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(6px * var(--ui-scale));
  box-sizing: border-box;
  min-width: 2.4em;
  min-height: 1.85em;
  height: auto;
  padding: calc(4px * var(--ui-scale)) calc(14px * var(--ui-scale)) calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
  margin: calc(-16px * var(--ui-scale)) 0 0;
  position: relative;
  z-index: 3;
  border-radius: 999px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: 0;
  font-stretch: 100%;
  font-variant-numeric: tabular-nums;
  font-feature-settings: normal;
  font-synthesis: none;
  color: #16324f;
  background: linear-gradient(180deg, #e7f3ff 0%, #c5dff6 100%);
  border: 2px solid #8ebbe0;
  box-shadow: 0 4px 0 #7eabd4, 0 8px 16px rgba(40, 90, 140, 0.16);
  text-shadow: none;
  transform: none !important;
  scale: none;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

html[data-theme="dark"] .dojo-pts {
  color: #ffd9ee;
  background: linear-gradient(180deg, #3a2c4d 0%, #2a2140 100%);
  border-color: rgba(255, 217, 238, 0.18);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.3);
}

button.dojo-pts {
  cursor: pointer;
  transition: translate 0.15s ease, box-shadow 0.15s ease;
}

button.dojo-pts:hover {
  translate: 0 -2px;
}

button.dojo-pts:active {
  translate: 0 3px;
  box-shadow: 0 1px 0 #7eabd4;
}

button.dojo-pts:focus-visible,
.dojo-pts.is-editing {
  outline: 3px solid var(--g-pink);
  outline-offset: 2px;
}

.dojo-pts.is-invalid {
  outline-color: var(--g-red);
  animation: pts-shake 0.36s ease;
}

@keyframes pts-shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -5px 0; }
  75% { translate: 5px 0; }
}

.dojo-pts-input {
  width: 5.2ch;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.dojo-pts-input::-webkit-outer-spin-button,
.dojo-pts-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dojo-pearl {
  width: calc(26px * var(--ui-scale));
  height: calc(26px * var(--ui-scale));
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.dojo-pts-num {
  line-height: 1;
  font-weight: 700;
  color: #16324f;
}

html[data-theme="dark"] .dojo-pts-num,
html[data-theme="dark"] .dojo-pts-input {
  color: #fff;
}

.settings-stu-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wheel-open-btn {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: calc(8px * var(--ui-scale));
  margin: 0 auto 6px;
  padding: calc(9px * var(--ui-scale)) calc(24px * var(--ui-scale));
  border: 0;
  border-radius: 999px;
  background: var(--g-sun);
  color: var(--g-ink);
  box-shadow: 0 6px 0 #c98f00, 0 14px 26px rgba(201, 143, 0, 0.25);
  font: inherit;
  font-family: var(--g-font);
  font-size: calc(18px * var(--fs));
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wheel-open-arrow {
  display: grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.95em;
  line-height: 1;
  animation: arrow-bounce 1.4s ease-in-out infinite;
}

@keyframes arrow-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

.wheel-open-btn:hover {
  transform: translateY(-2px);
}

.wheel-open-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #c98f00;
}

/* wheel panel — full stage */
.classroom-dock {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  gap: 0;
  padding: calc(8px * var(--ui-scale));
  background: transparent;
  overflow: hidden;
}

.classroom-dock .classroom-secret {
  z-index: 40;
}

html[data-theme="dark"] .classroom-dock {
  background: transparent;
}

.classroom-dock[hidden] {
  display: none !important;
}

.wheel-close-btn {
  position: sticky;
  top: 4px;
  z-index: 25;
  flex-shrink: 0;
  align-self: center;
  margin: 0 auto 6px;
  border: 0;
  background: var(--cr-card);
  color: var(--cr-ink);
  border-radius: 999px;
  padding: calc(8px * var(--ui-scale)) calc(20px * var(--ui-scale));
  font: inherit;
  font-family: var(--g-font);
  font-size: calc(17px * var(--fs));
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--cr-edge), 0 12px 22px var(--cr-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wheel-close-btn:hover {
  transform: translateY(-2px);
}

.wheel-close-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--cr-edge);
}

#sys-shopWheel {
  background: #fff;
  color: #1d2340;
  box-shadow: 0 5px 0 rgba(29, 35, 64, 0.16), 0 12px 22px rgba(29, 35, 64, 0.12);
}

#sys-shopWheel:active {
  box-shadow: 0 2px 0 rgba(29, 35, 64, 0.16);
}

.dock-main {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: calc(28px * var(--ui-scale));
  width: 100%;
  max-width: calc(1100px * var(--ui-scale));
}

.dock-main-split {
  align-items: center;
  justify-content: space-between;
  gap: calc(18px * var(--ui-scale));
}

.layout-main[hidden] {
  display: none !important;
}

.layout-slot > .wheel-open-btn,
.layout-slot > .wheel-close-btn {
  position: relative;
  top: auto;
  margin: 0;
}

.layout-wheel.dock-main-split,
.layout-wheel.layout-free-canvas,
.layout-shop.layout-free-canvas {
  display: block;
  position: relative;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  box-sizing: border-box;
}

.layout-slot-row-wheel {
  display: contents;
}

.layout-slot[data-bind="wheel"] .dock-wheel,
.layout-slot .dock-wheel {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  padding-top: 22px;
  gap: 8px;
}

.classroom-shell.is-constructor .layout-wheel.dock-main-split {
  overflow: hidden;
}

.dock-chest-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(10px * var(--ui-scale));
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  flex: 0 0 auto;
  --section-tint: var(--g-sky);
  --section-edge: #1f7fd6;
  padding: calc(8px * var(--ui-scale));
  background:
    radial-gradient(80% 60% at 50% 100%, color-mix(in srgb, var(--section-tint) 16%, transparent), transparent 72%),
    color-mix(in srgb, var(--cr-card) 72%, transparent);
  border: 3px solid color-mix(in srgb, var(--section-tint) 30%, transparent);
  border-radius: calc(26px * var(--ui-scale));
  box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--section-tint) 22%, transparent);
  overflow: hidden;
  box-sizing: border-box;
}

.dock-chest-section[data-side="right"] {
  --section-tint: var(--g-pink);
  --section-edge: #c42a63;
}

.dock-chest-title {
  margin: 0;
  font-family: var(--g-font);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  padding: calc(4px * var(--ui-scale)) calc(16px * var(--ui-scale)) calc(5px * var(--ui-scale));
  background: var(--section-tint);
  border-radius: calc(14px * var(--ui-scale));
  box-shadow: 0 4px 0 var(--section-edge);
}

.chest-shuffle-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: calc(7px * var(--ui-scale));
  margin: 0;
  padding: calc(7px * var(--ui-scale)) calc(18px * var(--ui-scale)) calc(8px * var(--ui-scale)) calc(13px * var(--ui-scale));
  border: 0;
  border-radius: 999px;
  background: var(--g-violet);
  color: #fff;
  box-shadow: 0 5px 0 #5a3fd1, 0 10px 18px rgba(90, 63, 209, 0.25);
  font-family: var(--g-font);
  font-size: calc(16px * var(--fs));
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.chest-shuffle-ico {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 3h5v5M4 20 21 3M21 16v5h-5M15 15l6 6M4 4l5 5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 3h5v5M4 20 21 3M21 16v5h-5M15 15l6 6M4 4l5 5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.dock-chest-section {
  container-type: inline-size;
}

@container (max-width: 150px) {
  .chest-shuffle-btn {
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
  }
  .chest-shuffle-label {
    display: none;
  }
  .dock-chest-title {
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 0.95rem;
    padding-inline: calc(8px * var(--ui-scale));
  }
}

.chest-shuffle-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.chest-shuffle-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #5a3fd1;
}

.chest-shuffle-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.dock-chest-section.is-shuffling .chest-shuffle-btn .chest-shuffle-ico {
  animation: shuffle-spin 0.7s linear infinite;
}

@keyframes shuffle-spin {
  to { transform: rotate(360deg); }
}

.layout-slot:has(> .dock-chest-section.is-shuffling),
.dock-chest-section.is-shuffling,
.dock-chest-section.is-shuffling .dock-chests {
  overflow: visible;
}

.dock-chest-section.is-shuffling .chest-btn {
  position: relative;
  pointer-events: none;
}

.chest-btn.chest-refreshed {
  animation: chest-pop 0.6s cubic-bezier(0.2, 0.8, 0.2, 1.3) var(--pop-delay, 0ms) both;
}

@keyframes chest-pop {
  0% { transform: scale(0.7); filter: drop-shadow(0 0 0 rgba(255, 204, 51, 0)); }
  55% { transform: scale(1.1); filter: drop-shadow(0 0 14px rgba(255, 204, 51, 0.9)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 204, 51, 0)); }
}

@media (prefers-reduced-motion: reduce) {
  .chest-btn.chest-refreshed,
  .dock-chest-section.is-shuffling .chest-shuffle-btn .chest-shuffle-ico,
  .dojo-pts.is-invalid,
  .class-card,
  .classes-hub-head h1 {
    animation: none;
  }
}

.dock-wheel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(12px * var(--ui-scale));
  padding-top: 28px;
}

.wheel-pointer {
  position: absolute;
  top: 2px;
  left: 50%;
  z-index: 6;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 26px solid #e8c547;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.wheel-pointer::after {
  content: '';
  position: absolute;
  top: -26px;
  left: -11px;
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 20px solid #f5d76e;
}

#wheel-canvas {
  border-radius: 50%;
  box-shadow: 0 0 0 5px #fff, 0 0 0 9px var(--g-sun), 0 18px 40px rgba(16, 40, 60, 0.28);
  background: #fff;
  display: block;
  max-width: 100%;
  max-height: 100%;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 0;
}

.layout-slot #wheel-canvas,
.dock-wheel #wheel-canvas {
  max-width: 100% !important;
  max-height: 100% !important;
}

.classroom-dock.chests-left .dock-main {
  flex-direction: row-reverse;
}

.dock-wheel .dock-spin {
  min-width: calc(170px * var(--ui-scale));
  font-family: var(--g-font);
  font-size: calc(21px * var(--fs));
  font-weight: 700;
  padding: calc(11px * var(--ui-scale)) calc(26px * var(--ui-scale));
  border: 0;
  border-radius: calc(18px * var(--ui-scale));
  background: var(--g-pink);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 0 #c42a63, 0 14px 26px rgba(196, 42, 99, 0.28);
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dock-wheel .dock-spin:hover {
  transform: translateY(-2px);
}

.dock-wheel .dock-spin:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #c42a63;
}

.dock-chests {
  display: flex;
  gap: calc(12px * var(--ui-scale));
  align-items: flex-end;
  align-content: center;
  flex-wrap: wrap;
  justify-content: center;
  padding-bottom: 4px;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  width: 100%;
}

.range-field-label {
  font-size: var(--text-sm);
  color: var(--muted);
}

.range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  display: block;
}

.range-input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 80%, #94a3b8);
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.range-input::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 80%, #94a3b8);
}

.range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
}

.chest-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 18px 6px 4px;
  transition: transform 0.15s ease;
  overflow: visible;
  perspective: 700px;
  perspective-origin: 50% 70%;
}

.chest-stage {
  position: relative;
  display: block;
  margin: 0 auto;
  overflow: visible;
  transform-style: preserve-3d;
}

.chest-closed,
.chest-open {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
}

.chest-closed {
  z-index: 1;
  opacity: 1;
  transition: opacity 0.1s ease;
}

.chest-closed img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.28));
  pointer-events: none;
}

.chest-open {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  transform-style: preserve-3d;
}

.chest-base,
.chest-lid {
  position: absolute;
  left: 0;
  right: 0;
  display: block;
}

/* Body stays fixed */
.chest-base {
  top: 36%;
  bottom: 0;
  z-index: 1;
  overflow: hidden;
}

.chest-base img {
  position: absolute;
  left: 0;
  width: 100%;
  height: 156.25%; /* 100 / 0.64 */
  bottom: 0;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.28));
  pointer-events: none;
}

/* Lid hinged at the BACK edge — opens away like a real chest */
.chest-lid {
  top: 0;
  height: 50%;
  z-index: 4;
  overflow: hidden;
  transform-origin: 50% 100%;
  transform: rotateX(0deg);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  transition: transform 0.85s cubic-bezier(0.22, 0.8, 0.2, 1);
  will-change: transform;
}

.chest-lid img {
  width: 100%;
  height: 200%;
  object-fit: contain;
  object-position: center top;
  display: block;
  pointer-events: none;
}

.chest-glow {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 28%;
  height: 46%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 252, 230, 1) 0%, rgba(255, 210, 70, 0.85) 40%, rgba(255, 150, 20, 0.35) 70%, transparent 100%);
  opacity: 0;
  transform: scale(0.65);
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.chest-btn:hover:not(.chest-opened):not(.chest-opening):not(:disabled) {
  transform: translateY(-4px);
}

.chest-btn:hover:not(.chest-opened):not(.chest-opening) .chest-closed img {
  animation: chest-shake 0.45s ease-in-out infinite;
}

/* Live SVG chests (data-rigged) */
.chest-live-host {
  display: grid;
  place-items: end center;
  overflow: visible;
  transform-style: preserve-3d;
  perspective: 600px;
}

.chest-live-host svg.chest-svg,
.chest-live-host .chest-fallback-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.28));
  transform-style: preserve-3d;
}

.chest-btn-live .part-lid,
.chest-btn-live .part-body,
.chest-btn-live .part-lock,
.chest-btn-live .part-spark {
  transform-box: view-box;
  transform-style: preserve-3d;
}

.chest-btn-live .part-lid {
  transform-origin: 100px 96px;
  transition: transform 0.85s cubic-bezier(0.22, 0.8, 0.2, 1);
  will-change: transform;
}

.chest-btn-live:not(.chest-opened):not(.chest-opening) .part-body {
  animation: chest-alive-bob 3.2s ease-in-out infinite;
}

.chest-btn-live:not(.chest-opened):not(.chest-opening) .part-lock {
  animation: chest-lock-glint 2.8s ease-in-out infinite;
}

.chest-btn-live:hover:not(.chest-opened):not(.chest-opening) .chest-live-host svg {
  animation: chest-shake 0.45s ease-in-out infinite;
}

.chest-btn-live.chest-lid-up .part-lid {
  transform: rotateX(-125deg);
}

.chest-btn-live.chest-glowing .part-spark .chest-spark-core,
.chest-btn-live.chest-glowing .part-spark .chest-spark-dot {
  opacity: 1 !important;
  animation: chest-glow-pulse 1s ease-in-out infinite;
}

.chest-btn-live.chest-opened:not(.chest-glowing) .part-spark .chest-spark-core,
.chest-btn-live.chest-opened:not(.chest-glowing) .part-spark .chest-spark-dot {
  opacity: 0 !important;
  animation: none;
}

@keyframes chest-alive-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes chest-lock-glint {
  0%, 100% { filter: brightness(1); }
  40% { filter: brightness(1.25); }
  55% { filter: brightness(1.05); }
}

.chest-btn.chest-opening .chest-closed,
.chest-btn.chest-opened .chest-closed {
  opacity: 0;
}

.chest-btn.chest-opening .chest-open,
.chest-btn.chest-opened .chest-open {
  opacity: 1;
}

/* Open lid backwards (away from camera) */
.chest-btn.chest-lid-up .chest-lid {
  transform: rotateX(-125deg);
}

.chest-btn.chest-glowing .chest-glow {
  opacity: 1;
  transform: scale(1.08);
  animation: chest-glow-pulse 1s ease-in-out infinite;
}

.chest-btn.chest-opened {
  cursor: default;
  pointer-events: none;
}

.chest-btn.chest-opened:not(.chest-glowing) .chest-glow {
  opacity: 0;
  transform: scale(0.8);
  animation: none;
}

@keyframes chest-shake {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

@keyframes chest-glow-pulse {
  0%,
  100% {
    opacity: 0.8;
    filter: brightness(1);
  }
  50% {
    opacity: 1;
    filter: brightness(1.3);
  }
}

.chest-count-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.chest-slots-section-title {
  margin: 10px 0 6px;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--ink);
}

.catalog-row-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.catalog-edit-preview img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 4px;
}

.celebrate-modal {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 24, 0.42);
  backdrop-filter: blur(3px);
  overflow: hidden;
}

.celebrate-modal[hidden] {
  display: none !important;
}

.celebrate-burst {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(251, 191, 36, 0.55) 0 6px, transparent 7px),
    radial-gradient(circle at 70% 25%, rgba(56, 189, 248, 0.55) 0 5px, transparent 6px),
    radial-gradient(circle at 40% 70%, rgba(244, 114, 182, 0.5) 0 7px, transparent 8px),
    radial-gradient(circle at 80% 65%, rgba(52, 211, 153, 0.5) 0 6px, transparent 7px),
    radial-gradient(circle at 55% 40%, rgba(167, 139, 250, 0.55) 0 5px, transparent 6px),
    radial-gradient(circle at 15% 75%, rgba(251, 146, 60, 0.5) 0 4px, transparent 5px),
    radial-gradient(circle at 88% 40%, rgba(250, 204, 21, 0.45) 0 8px, transparent 9px),
    radial-gradient(circle at 30% 50%, rgba(34, 211, 238, 0.4) 0 5px, transparent 6px);
  background-size: 120% 120%;
  animation: celebrate-sparkle 1.8s ease-out both;
}

.celebrate-burst::before,
.celebrate-burst::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: rgba(250, 204, 21, 0.7);
  border-right-color: rgba(56, 189, 248, 0.55);
  animation: celebrate-ring 1.1s ease-out both;
}

.celebrate-burst::after {
  inset: 28%;
  animation-delay: 0.12s;
  border-top-color: rgba(244, 114, 182, 0.65);
  border-left-color: rgba(52, 211, 153, 0.5);
}

@keyframes celebrate-sparkle {
  0% { opacity: 0; transform: scale(0.7); }
  30% { opacity: 1; }
  100% { opacity: 0.55; transform: scale(1.15); }
}

@keyframes celebrate-ring {
  0% { opacity: 0.9; transform: scale(0.4) rotate(0deg); }
  100% { opacity: 0; transform: scale(1.35) rotate(40deg); }
}

.chest-reward-toast {
  z-index: 41;
}

.chest-reward-card,
.wheel-result-card {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 28px 36px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  min-width: min(320px, 86vw);
  margin: 0;
  transform: none;
  animation: result-pop 0.4s cubic-bezier(0.2, 1.3, 0.3, 1);
}

.chest-reward-card img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  display: block;
  margin: 8px auto;
}

.chest-reward-title {
  margin: 4px 0 14px;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
  color: var(--accent);
}

.chest-reward-card .primary {
  min-width: 120px;
}

@keyframes result-pop {
  0% { opacity: 0; transform: scale(0.86); }
  100% { opacity: 1; transform: scale(1); }
}

.wheel-result-name {
  margin: 8px 0 18px;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  color: var(--accent);
}

.wheel-editor-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  max-height: 280px;
  overflow: auto;
}

.wheel-editor-row {
  display: grid;
  grid-template-columns: 1fr 40px 44px;
  gap: 8px;
  align-items: center;
}

.wheel-editor-row input[type="text"] {
  margin: 0;
}

.wheel-color-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
  margin: 0;
}

.wheel-del-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  color: var(--danger);
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin: 0;
  display: grid;
  place-items: center;
}

.wheel-editor-add {
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.wheel-editor-add input {
  flex: 1;
  min-width: 140px;
  margin: 0;
}

.wheel-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 12px;
}

.wheel-preview-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  padding-top: 4px;
  margin-bottom: 8px;
}

#wheel-preview-canvas {
  width: var(--wheel-preview);
  height: var(--wheel-preview);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  background: #fff;
}

.color-picker-card .color-picker-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.color-picker-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-preview-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex-shrink: 0;
}

.color-hue {
  flex: 1;
  margin: 0;
}

.color-rgb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.color-rgb-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

.color-rgb-row input[type="number"] {
  width: 72px;
  margin: 0;
  background: #fff;
}

#color-sv-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 280px;
  border-radius: 14px;
  cursor: crosshair;
  border: 1px solid var(--line);
  touch-action: none;
}

.color-swatch-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.color-swatch-grid .color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  margin: 0;
}

.color-swatch-grid .color-swatch.on {
  border-color: var(--ink);
}

.asset-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 100px;
  margin: 0 0 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
  width: 100%;
  color: inherit;
  font: inherit;
}

.asset-preview-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.asset-preview-clickable:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
}

html[data-theme="dark"] .asset-preview {
  background: var(--panel-soft);
}

.asset-preview img {
  width: 100%;
  height: 96px;
  max-width: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.asset-preview span,
.asset-preview-caption {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.asset-preview-bg {
  min-height: 0;
  padding: 8px;
  gap: 8px;
  justify-content: flex-start;
}

.asset-preview-bg-frame {
  display: block;
  width: 100%;
  height: 110px;
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, var(--panel-soft) 80%, #94a3b8);
  flex-shrink: 0;
}

.asset-preview-bg-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.asset-preview-bg .asset-preview-caption {
  position: static;
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.sr-only-file {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.settings-pick-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.settings-students-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.settings-students-head h3 {
  margin: 0;
}

.groups-panel input,
.groups-panel select,
.groups-panel textarea {
  background: #fff;
  color: var(--ink);
}

html[data-theme="dark"] .groups-panel input,
html[data-theme="dark"] .groups-panel select,
html[data-theme="dark"] .groups-panel textarea {
  background: var(--input-bg);
}

.chest-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 12px;
}

.chest-slot-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: stretch;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-soft) 70%, #fff);
}

.chest-slot {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  cursor: pointer;
  text-align: center;
  width: 100%;
  margin: 0;
}

html[data-theme="dark"] .chest-slot {
  background: var(--panel-soft);
}

.chest-slot img {
  width: 100%;
  height: 56px;
  object-fit: contain;
  object-position: center;
  display: block;
}

.chest-slot span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.chest-reward-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--line));
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  margin: 0;
  width: 100%;
}

html[data-theme="dark"] .chest-reward-pick {
  background: var(--panel-soft);
}

.chest-reward-pick img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.chest-reward-pick strong {
  display: block;
  font-size: 0.92rem;
}

.chest-reward-pick small {
  color: var(--muted);
  font-size: 0.78rem;
}

/* large 5×5 asset picker */
.asset-picker-overlay {
  z-index: 70;
  padding: 2vh 2vw;
}

.modal-card.asset-picker-card {
  width: min(920px, 96vw) !important;
  max-width: 96vw !important;
  height: min(92vh, 900px);
  max-height: 92vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  overflow: hidden;
  padding: 0;
}

.asset-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.asset-picker-head h2 {
  margin: 0;
  font-family: var(--font-display);
}

.asset-picker-sections {
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.asset-picker-sections[hidden] {
  display: none !important;
}

.asset-section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.asset-section-tab {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.asset-section-tab.active {
  background: color-mix(in srgb, var(--accent) 22%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.asset-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.asset-picker-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 16px;
  align-content: start;
}

.asset-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 12px 8px 10px;
  cursor: pointer;
  text-align: center;
  color: inherit;
  font: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
  min-height: 148px;
  overflow: hidden;
  box-sizing: border-box;
}

html[data-theme="dark"] .asset-pick {
  background: var(--panel-soft);
}

.asset-pick:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.asset-pick img {
  width: 100%;
  height: 92px;
  object-fit: contain;
  object-position: center bottom;
  flex-shrink: 0;
}

.asset-pick span {
  display: block;
  width: 100%;
  font-size: 12px;
  margin: 0;
  padding: 0 2px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.asset-pick.bg {
  min-height: 0;
  padding: 10px 8px 8px;
}

.asset-pick-bg-frame {
  display: block;
  width: 100%;
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, var(--panel-soft) 80%, #94a3b8);
  flex-shrink: 0;
}

.asset-pick-bg-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.asset-pick.bg > span:last-child {
  position: static;
  padding: 2px 4px;
}

.modal-card.name-modal-card {
  width: min(420px, 92vw) !important;
  text-align: center;
  z-index: 80;
}

#name-modal {
  z-index: 80;
}

#color-palette-modal {
  z-index: 80;
}

.name-modal-preview {
  min-height: 100px;
  display: grid;
  place-items: center;
  margin: 8px 0 14px;
}

.name-modal-preview img {
  width: 110px;
  height: 130px;
  object-fit: contain;
}

.name-modal-actions {
  justify-content: center;
}

.color-palette-card {
  width: min(560px, 94vw);
  max-height: 85vh;
  overflow: auto;
}

.color-palette-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0 16px;
}

.color-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  margin: 0;
}

.color-swatch.on {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--panel);
}

@media (max-width: 720px) {
  .asset-picker-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@keyframes reward-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
  }
  60% {
    transform: translate(-50%, -50%) scale(1.12);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

.points-fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.points-fx {
  position: absolute;
  font-family: var(--font);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: normal;
  transform: translate(-50%, 0);
  animation: points-rise 2.8s ease-out forwards;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.points-fx-pearl {
  width: 1.2em;
  height: 1.2em;
  object-fit: contain;
}

.points-fx.up {
  color: #3ddc97;
}
.points-fx.down {
  color: #ff6b7a;
}

@keyframes points-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.85);
  }
  12% {
    opacity: 1;
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -36px) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -78px) scale(1.1);
  }
}

.dojo-card.flash-up {
  animation: flash-up 0.45s ease;
}
.dojo-card.flash-down {
  animation: flash-down 0.45s ease;
}
@keyframes flash-up {
  0%,
  100% {
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.55);
  }
}
@keyframes flash-down {
  0%,
  100% {
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(255, 107, 122, 0.55);
  }
}

/* settings drawer — must beat display:flex when hidden */
.dojo-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 24, 0.35);
  z-index: 40;
  backdrop-filter: blur(2px);
}

.dojo-scrim.drag-pass {
  pointer-events: none;
  background: rgba(8, 12, 24, 0.15);
}

.dojo-scrim[hidden],
.dojo-drawer[hidden] {
  display: none !important;
}

.dojo-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--drawer-w);
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.22);
  animation: drawer-in 0.22s ease;
}

@keyframes drawer-in {
  from {
    transform: translateX(28px);
    opacity: 0.5;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.dojo-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(10px * var(--ui-scale));
  padding: calc(14px * var(--ui-scale)) calc(16px * var(--ui-scale));
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.dojo-drawer-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.dojo-drawer-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.groups-panel h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.groups-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.groups-panel input,
.groups-panel select,
.groups-panel textarea {
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.avatar-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 4px;
  margin-bottom: 10px;
}

.palette-av {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 14px;
  padding: 6px;
  cursor: grab;
  text-align: center;
}

.palette-av:active {
  cursor: grabbing;
}

.palette-av img {
  width: 100%;
  height: 64px;
  object-fit: contain;
  pointer-events: none;
}

.palette-av span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-students {
  display: flex;
  flex-direction: column;
  gap: calc(6px * var(--ui-scale));
  max-height: calc(400px * var(--ui-scale));
  overflow: auto;
}

.settings-stu-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.settings-stu-row img,
.settings-stu-row .settings-stu-av {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: color-mix(in srgb, var(--panel) 70%, #94a3b8);
  border-radius: 8px;
}

.settings-stu-av-empty {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 70%, #94a3b8);
}

.catalog-btns {
  display: flex;
  flex-wrap: wrap;
  gap: calc(8px * var(--ui-scale));
  justify-content: center;
  text-align: center;
}

.catalog-btns .ghost {
  min-width: 7.5rem;
  font-size: var(--text-sm);
}

.muted.small {
  font-size: 0.95rem;
  line-height: 1.4;
  margin: 0 0 10px;
}

.groups-panel .muted.small {
  font-size: 1rem;
}

.settings-stu-row .tiny {
  font-size: 0.92rem;
  padding: 6px 10px;
}

.settings-stu-row .tiny.danger-text {
  font-size: 1.15rem;
  font-weight: 800;
  min-width: 1.8em;
}

.award-card {
  width: min(560px, 94vw);
  max-height: 85vh;
  overflow: auto;
  border: 0;
  border-radius: 28px;
  background:
    radial-gradient(120% 80% at 0% 0%, #ffe7a3 0%, transparent 42%),
    radial-gradient(90% 70% at 100% 0%, #ffd0e8 0%, transparent 46%),
    linear-gradient(180deg, #fffaf2 0%, #fff 40%);
  box-shadow: 0 10px 0 #e7c98a, 0 24px 40px rgba(80, 40, 20, 0.18);
  font-family: var(--font, inherit);
}

.catalog-card {
  width: min(1120px, 96vw);
  max-height: 85vh;
  overflow: auto;
  border: 0;
  border-radius: 28px;
  background:
    radial-gradient(120% 80% at 0% 0%, #ffe7a3 0%, transparent 42%),
    radial-gradient(90% 70% at 100% 0%, #ffd0e8 0%, transparent 46%),
    linear-gradient(180deg, #fffaf2 0%, #fff 40%);
  box-shadow: 0 10px 0 #e7c98a, 0 24px 40px rgba(80, 40, 20, 0.18);
  font-family: var(--font, inherit);
}

.sheet-x {
  position: absolute;
  top: calc(4px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #1d2340;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(29, 35, 64, 0.25);
}

.sheet-x svg {
  display: block;
}

.sheet-x:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(29, 35, 64, 0.25); }

.catalog-split {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.award-card h2 {
  margin: 0 0 4px;
  font-family: var(--font);
  font-size: 1.55rem;
  font-weight: 600;
  color: #4a4458;
}

.award-card > .muted {
  margin-top: 0;
  color: #8b8498;
  font-weight: 500;
}

.award-card label {
  color: #7d768a;
  font-weight: 500;
}

.award-card select {
  color: #5c5670;
  font-weight: 500;
}

.catalog-hint {
  margin: 0 0 10px;
  line-height: 1.35;
}

#catalog-modal label[hidden],
#catalog-modal [hidden] {
  display: none !important;
}

.award-reasons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.award-reason-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: #241e32;
  box-shadow: 0 4px 0 #ead9c4, 0 8px 16px rgba(80, 40, 20, 0.08);
}

.award-reason-btn:hover {
  transform: translateY(-2px);
}

.award-reason-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #ead9c4;
}

.award-reason-btn img {
  width: 42px;
  height: 42px;
  margin: -6px 0;
  filter: drop-shadow(0 3px 4px rgba(60, 30, 10, 0.18));
  object-fit: contain;
  flex-shrink: 0;
}

.award-reason-btn strong {
  flex: 1;
  text-align: left;
  font-weight: 700;
}

.award-reason-btn span {
  color: #241e32;
  font-weight: 700;
}

.award-card .row {
  justify-content: center;
}

#btn-award-close {
  min-width: 160px;
  margin-top: 4px;
  border: 0;
  border-radius: 999px;
  background: #ff7a1a;
  color: #fff;
  font-weight: 700;
  padding: 12px 28px;
  box-shadow: 0 4px 0 #d85a00;
}

#btn-award-close:hover {
  background: #ff8d38;
}

.catalog-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
  max-height: min(72vh, 760px);
  overflow: auto;
  align-content: start;
}

.catalog-section-select {
  display: block;
  margin-top: 4px;
  max-width: 100%;
}

.catalog-row strong {
  font-weight: 600;
}

.catalog-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.catalog-row img {
  width: 100%;
  height: 156px;
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
  background:
    linear-gradient(45deg, #dbe4ee 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #dbe4ee 25%, transparent 25%) 0 8px / 16px 16px,
    #f8fafc;
}

.catalog-dot {
  width: 48px;
  height: 48px;
  align-self: center;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.danger-text {
  color: var(--danger) !important;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tiny {
  border: 0;
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
}

@media (max-width: 720px) {
  .classroom-hero {
    min-height: 0;
  }
  .ship-stage {
    height: 170px;
    width: min(92vw, 480px);
  }
  .classroom-ship {
    max-height: 180px;
    width: min(86vw, 400px);
    bottom: -8px;
  }
  .classroom-water-wrap .ship-water {
    min-height: 88px;
  }
  .ship-water {
    height: 110px;
    width: 175%;
    bottom: -76px;
  }
  .classroom-ship-name {
    margin-top: calc(40px * var(--ui-scale));
  }
  .classroom-title {
    font-size: clamp(1.3rem, 4.5vw, 1.75rem);
    font-weight: 600;
  }
  .dojo-avatar {
    width: 80px;
    height: 92px;
  }
  .dojo-grid {
    padding-top: 8px;
    margin-top: 4px;
  }
  #wheel-canvas {
    width: min(88vw, 360px) !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
  }
  .chest-btn img {
    width: 72px;
  }
  .dojo-drawer {
    width: min(96vw, 840px);
  }
  .chest-slot-row {
    grid-template-columns: 64px 1fr;
  }
  .classroom-ship-wrap {
    transform: none;
  }

  /* Additive classroom mobile shell */
  .classroom-shell {
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .classroom-toolbar,
  .classroom-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .classroom-toolbar button,
  .classroom-actions button {
    min-height: 44px;
    min-width: 44px;
  }
  .dojo-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
  }
  .dojo-card {
    padding: 8px 6px;
  }
  .dojo-drawer {
    max-height: min(78dvh, 640px);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .classroom-shell.is-constructor .ctor-block-chrome {
    font-size: 0.8rem;
  }
  .classroom-shell.is-constructor .ctor-resize {
    width: 22px;
    height: 22px;
  }
  .constructor-card {
    width: min(96vw, 560px);
    max-height: min(88dvh, 720px);
  }
}

@media (max-width: 480px) {
  .dojo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .dojo-avatar {
    width: 70px;
    height: 80px;
  }
  .classroom-ship-name {
    font-size: 0.95rem;
  }
}

/* Raster image rigs: soft face bob (when face group exists) */
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad) .monster-svg--raster .part-face {
  animation: part-face-bob 3.4s ease-in-out infinite;
}
/* Body breathe only if host is not already doing whole-avatar bob */
.dojo-avatar-anim.is-rigged:not(.mood-happy):not(.mood-sad):not(.alive-sway):not(.alive-bounce):not(.alive-wiggle) .monster-svg--raster .part-body {
  animation: part-body-breathe 4.2s ease-in-out infinite;
}
@keyframes part-face-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes part-body-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}

.constructor-card {
  width: min(560px, 94vw);
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.constructor-tabs {
  display: flex;
  gap: 8px;
}
.constructor-tab {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.constructor-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.constructor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 160px;
  max-height: 48vh;
  padding-right: 4px;
}
.constructor-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}
.ctor-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
}
.ctor-sys-badge {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--muted);
}
.ctor-label {
  font-weight: 700;
}
.ctor-moves {
  display: inline-flex;
  gap: 4px;
}
.constructor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* —— Live constructor mode on classroom page —— */
.ctor-toolbar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(10px);
  max-width: min(96vw, 960px);
  touch-action: none;
}

.ctor-toolbar[hidden] {
  display: none !important;
}

.ctor-toolbar input[type="file"],
#ctor-live-image-file,
#ctor-image-file {
  display: none !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.ctor-toolbar-move {
  cursor: grab;
  font-weight: 900;
  letter-spacing: -2px;
  padding: 4px 6px;
  border-radius: 8px;
  background: var(--panel-soft);
  user-select: none;
  touch-action: none;
}

.ctor-toolbar-move:active {
  cursor: grabbing;
}

.ctor-toolbar-title {
  font-family: var(--font-display);
  font-weight: 800;
  margin-right: 4px;
}

.ctor-toolbar-tabs {
  display: inline-flex;
  gap: 4px;
}

.ctor-tab {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ctor-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.classroom-shell.is-constructor #btn-groups-back {
  display: none !important;
}

/* Foreground BG must not steal hits from resize handles */
.classroom-shell.is-constructor .groups-stage-bg-fore {
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}

.classroom-shell.is-constructor .layout-main,
.classroom-shell.is-constructor .layout-wheel {
  overflow: hidden;
  z-index: 4;
  pointer-events: auto;
  position: relative;
}

.classroom-shell.is-constructor .layout-slot {
  position: absolute;
  z-index: 4;
  outline: 2px dashed color-mix(in srgb, var(--accent) 70%, #fff);
  outline-offset: 2px;
  border-radius: 12px;
  box-sizing: border-box;
  margin: 0;
  pointer-events: auto;
  overflow: hidden;
}

.classroom-shell.is-constructor .layout-slot-empty,
.classroom-shell.is-constructor .layout-slot-empty-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 2px dashed color-mix(in srgb, var(--muted) 55%, transparent);
  background: color-mix(in srgb, var(--panel) 35%, transparent);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.classroom-shell.is-constructor .ctor-slot-plus {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px dashed color-mix(in srgb, var(--accent) 65%, transparent);
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  color: var(--accent);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

.ctor-plus-menu {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.ctor-plus-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.ctor-plus-menu button:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.layout-slot-text-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 800;
  font-size: clamp(1rem, 2.6vw, 1.6rem);
  padding: 8px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.catalog-file-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.catalog-file-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

.catalog-file-label input[type="file"] {
  display: block;
  max-width: 100%;
}

.classroom-shell.is-constructor .layout-slot-ph {
  pointer-events: none;
}

.classroom-shell.is-constructor .layout-slot.ctor-dragging {
  opacity: 0.35;
  outline-style: solid;
}

.classroom-shell.is-constructor .layout-block,
.classroom-shell.is-constructor .layout-block-image {
  position: relative;
  outline: none;
  box-sizing: border-box;
}

.classroom-shell.is-constructor .layout-block.ctor-dragging {
  opacity: 0.35;
  outline-style: solid;
}

.classroom-shell.is-constructor .ctor-drop-target {
  outline: 3px solid var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 14%, transparent) !important;
}

.classroom-shell.is-constructor .ctor-block-chrome {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  pointer-events: auto;
}

.classroom-shell.is-constructor .ctor-block-chrome .ghost.small,
.classroom-shell.is-constructor .ctor-block-chrome .ctor-chrome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 28px;
  min-width: 28px;
  margin: 0;
  padding: 0 7px;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, #000);
  color: var(--ink);
  opacity: 1;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.classroom-shell.is-constructor .ctor-block-chrome .ghost.small.active,
.classroom-shell.is-constructor .ctor-block-chrome .ctor-chrome-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 6px color-mix(in srgb, var(--accent) 45%, transparent);
}

.classroom-shell.is-constructor .ctor-layer-pick {
  appearance: auto;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  height: 28px;
  line-height: 1;
  padding: 0 4px 0 6px;
  margin: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, #000);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  max-width: 4.2em;
  box-sizing: border-box;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.classroom-shell.is-constructor .ctor-layer-pick option {
  background: var(--input-bg);
  color: var(--ink);
}

html[data-theme="dark"] .classroom-shell.is-constructor .ctor-layer-pick,
html[data-theme="dark"] .classroom-shell.is-constructor .ctor-layer-pick option {
  background: #12283a;
  color: #f3f7fb;
  border-color: color-mix(in srgb, #94a3b8 45%, transparent);
}

.stu-name-input {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 3.2em;
  font: inherit;
  white-space: pre-wrap;
  padding: 8px 10px;
}

.classroom-shell.is-constructor .ctor-block-label {
  position: absolute;
  top: 4px;
  left: 36px;
  z-index: 7;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 88%, #000);
  color: #fff;
  pointer-events: none;
}

.classroom-shell.is-constructor .ctor-drag-handle {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 9;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, #000);
  border: 1px solid var(--line);
  cursor: grab;
  font-weight: 900;
  letter-spacing: -2px;
  user-select: none;
  touch-action: none;
  pointer-events: auto;
}

.classroom-shell.is-constructor .ctor-drag-handle:active {
  cursor: grabbing;
}

.classroom-shell.is-constructor .ctor-resize {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 9;
  width: 16px;
  height: 16px;
  border-radius: 4px 0 10px 0;
  background:
    linear-gradient(135deg, transparent 50%, color-mix(in srgb, var(--accent) 80%, #000) 50%);
  cursor: nwse-resize;
  touch-action: none;
  pointer-events: auto;
}

.classroom-shell.is-constructor .ctor-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  margin: 6px 0;
  border: 2px dashed color-mix(in srgb, var(--muted) 55%, transparent);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--panel) 35%, transparent);
}

.classroom-shell.is-constructor .ctor-slot.ctor-drop-target {
  border-color: var(--accent);
  color: var(--ink);
}

.ctor-ghost {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
}

.classroom-shell.is-constructor .layout-block-image {
  pointer-events: auto;
  min-height: 72px;
  background: color-mix(in srgb, var(--panel) 40%, transparent);
}

.classroom-shell.is-constructor #sys-openWheel,
.classroom-shell.is-constructor #sys-closeWheel {
  pointer-events: none;
}

.classroom-shell.is-constructor .dojo-card {
  pointer-events: none;
}

/* Pass clicks through overlapping slot bodies so covered handles stay reachable */
.classroom-shell.is-constructor .layout-slot {
  pointer-events: none;
}

.classroom-shell.is-constructor .ctor-drag-handle,
.classroom-shell.is-constructor .ctor-resize,
.classroom-shell.is-constructor .ctor-block-chrome,
.classroom-shell.is-constructor .ctor-block-chrome *,
.classroom-shell.is-constructor .ctor-slot-plus,
.classroom-shell.is-constructor .ctor-plus-menu,
.classroom-shell.is-constructor .shop-img-handle,
.classroom-shell.is-constructor .shop-card {
  pointer-events: auto;
}

html[data-theme="dark"] .classroom-shell.is-constructor .ctor-block-chrome .ghost.small,
html[data-theme="dark"] .classroom-shell.is-constructor .ctor-block-chrome .ctor-chrome-btn,
html[data-theme="dark"] .classroom-shell.is-constructor .ctor-layer-pick {
  background: #1a3348;
  color: #f3f7fb;
  border-color: color-mix(in srgb, #94a3b8 50%, transparent);
}

/* Title and page buttons sit under the constructor handles, not over them */
.classroom-shell.is-constructor .layout-slot[data-bind="title"],
.classroom-shell.is-constructor .layout-slot[data-bind="shopTitle"],
.classroom-shell.is-constructor .layout-slot[data-bind="openWheel"],
.classroom-shell.is-constructor .layout-slot[data-bind="closeWheel"],
.classroom-shell.is-constructor .layout-slot[data-bind="openShop"],
.classroom-shell.is-constructor .layout-slot[data-bind="closeShop"] {
  overflow: visible;
  justify-content: flex-end;
  min-height: 92px;
  padding: 34px 8px 12px;
}

.layout-slot[data-bind="title"] > .layout-sys-title,
.layout-slot[data-bind="shopTitle"] > .shop-heading,
.layout-slot[data-bind="openWheel"] > .wheel-open-btn,
.layout-slot[data-bind="openWheel"] > .wheel-close-btn,
.layout-slot[data-bind="closeWheel"] > .wheel-close-btn,
.layout-slot[data-bind="openShop"] > .wheel-open-btn,
.layout-slot[data-bind="closeShop"] > .wheel-close-btn {
  width: auto;
  height: auto;
  max-width: calc(100% - 4px);
  max-height: none;
}

.ctor-library {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(520px, 70vw);
}

.settings-bg-trio {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.shop-board {
  width: min(1080px, 100%);
  height: 100%;
  margin: 0 auto;
  overflow: auto;
  padding: 8px 12px 28px;
  border-radius: 24px;
  background: transparent;
}

.shop-heading {
  margin: 8px 0 4px;
  text-align: center;
  font-family: Georgia, "Palatino Linotype", Palatino, serif;
  font-size: 2rem;
  letter-spacing: 0.04em;
  color: #fffaf3;
  text-shadow: 0 2px 10px rgba(20, 12, 4, 0.55);
}

.shop-students[hidden],
.shop-balance[hidden] {
  display: none !important;
}

.shop-rank {
  margin: 18px 0 8px;
  text-align: center;
  font-family: Georgia, "Palatino Linotype", Palatino, serif;
  color: #fffaf3;
  text-shadow: 0 2px 8px rgba(20, 12, 4, 0.5);
}

.shop-rank-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.shop-grid {
  position: relative;
  min-height: 420px;
}

.shop-card {
  position: absolute;
  width: max-content;
  max-width: 100%;
  padding: 10px 12px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffaf3 0%, #f3e6d4 100%);
  box-shadow: 0 10px 24px rgba(74, 48, 24, 0.16);
  text-align: center;
}

.shop-card .shop-rank {
  margin: 0 auto 4px;
  font-size: 0.78rem;
  max-width: 220px;
  color: #8a6240;
  text-shadow: none;
}

.shop-card-pic {
  position: relative;
  margin: 0 auto 8px;
  border-radius: 14px;
  overflow: hidden;
  background: #e7f3fb;
}

.shop-card-pic img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.shop-img-handle {
  display: none;
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 0 0 2px #c98f00;
  cursor: nwse-resize;
}

.classroom-shell.is-constructor .shop-img-handle {
  display: block;
}

.shop-card h3,
.shop-price,
.shop-blurb {
  max-width: 220px;
  margin-left: auto;
  margin-right: auto;
}

.shop-card h3 {
  margin: 0 auto 0.7rem;
  font-family: Georgia, "Palatino Linotype", Palatino, serif;
  font-size: 1.05rem;
  color: #3d2918;
}

.shop-buy {
  margin-top: 10px;
  border: 0;
  border-radius: 999px;
  padding: 8px 18px;
  background: #ffc53d;
  color: #1d2340;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #c98f00;
}

.shop-buy:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #c98f00;
}

.shop-buy-card {
  width: min(420px, 100%);
}

.shop-buy-name {
  margin: 0 0 12px;
  font-weight: 700;
}

.shop-buy-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
  margin-bottom: 14px;
}

.shop-pay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
  box-shadow: 0 4px 0 #ead9c4;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.shop-pay span {
  color: #6b4a2e;
  font-weight: 500;
  font-synthesis: none;
  white-space: nowrap;
}

.asset-picker-kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 18px 0;
}

.asset-picker-kinds[hidden] {
  display: none !important;
}

.asset-picker-kinds button.on {
  background: #ffc53d;
  color: #1d2340;
}

.shop-price {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 220px;
  margin: 0 auto;
  font-weight: 500;
  font-synthesis: none;
  color: #6b4a2e;
}

.shop-price img {
  width: 18px;
  height: 18px;
}

.shop-blurb {
  max-width: 220px;
  margin: 0.7rem auto 0;
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: pre-line;
  color: #6d5844;
}

.shop-edit-img {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #e7f3fb;
  cursor: pointer;
}

.shop-edit-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shop-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.shop-rank-block {
  width: min(1040px, 100%);
}

.shop-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-student, .shop-item, .shop-edit-row {
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 0 #ead9c4;
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.shop-edit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  cursor: default;
}

.shop-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b4a2e;
}

.shop-edit-main,
.shop-add {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex: 1 1 220px;
  min-width: 180px;
}

.shop-add > button {
  align-self: flex-start;
}

.shop-field input,
.shop-field textarea.shop-blurb-input {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: inherit;
  border: 0;
  border-radius: 10px;
  padding: 6px 8px;
  background: #fff8ee;
  min-width: 0;
}

.shop-field textarea.shop-blurb-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 3.2em;
  line-height: 1.35;
  white-space: pre-wrap;
  padding: 8px 10px;
}

.shop-student.on, .shop-item:hover {
  outline: 3px solid var(--g-sun, #ffc53d);
}

.shop-item img, .shop-edit-row img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.shop-dock { z-index: 15; }

@media (max-width: 720px) {
  .lobby-preview { grid-template-columns: 72px 1fr; }
  .ctor-library { max-width: 100%; }
  .catalog-split { grid-template-columns: 1fr; }
}

/* Библиотека кабинета: сброс к стандарту, порядок, шаблоны классов */
.library-note {
  margin: 0 0 8px;
  line-height: 1.35;
}

.catalog-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
}

.catalog-move {
  min-width: 32px;
  padding-inline: 8px;
}

.catalog-move:disabled {
  opacity: 0.35;
  cursor: default;
}

.catalog-tpl-swatch {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  border-radius: 12px;
  background: linear-gradient(180deg, #e8f3ff, #fff7e6);
}

.catalog-row .catalog-tpl-swatch img {
  width: 30%;
  height: 84px;
  background: none;
}

/* «Общий каталог» библиотеки класса */
#lib-global-modal { z-index: 1300; }
.lg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 48vh; overflow: auto; margin-top: 8px; }
.lg-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px; border: 1px solid rgba(127,127,127,.25); border-radius: 12px; text-align: center; font-size: 13px; cursor: pointer; }
.lg-item input { position: absolute; top: 8px; left: 8px; width: auto; }
.lg-item img { width: 72px; height: 72px; object-fit: contain; }
.lg-item.have { opacity: .55; cursor: default; }
