/**
 * Quizzman Fantasy Arcade Design System
 * Visual Direction: Dark Neon, Soft 3D, Playful Game Controls
 */

:root {
  /* ── 1. Color Tokens ── */
  --game-bg: #080d29;
  --game-surface: #111832;
  --game-surface-raised: #1b2345;

  --game-primary: #7546f9;
  --game-secondary: #253b9f;
  --game-accent: #5ed7ff;

  --game-success: #58e6a0;
  --game-warning: #ffbd59;
  --game-error: #ff526b;

  --game-text: #f8f7ff;
  --game-text-muted: #a5accb;

  /* ── 2. 2.5D Surface, Bevels & Glow Tokens ── */
  --game-bevel-top: rgba(255, 255, 255, 0.28);
  --game-bevel-bottom: rgba(0, 0, 0, 0.38);
  --game-edge-primary: #4c22b8;
  --game-edge-secondary: #162463;
  --game-edge-danger: #b3253b;
  --game-edge-success: #2ea66e;

  --game-glow-primary: rgba(117, 70, 249, 0.45);
  --game-glow-accent: rgba(94, 215, 255, 0.45);
  --game-glow-error: rgba(255, 82, 107, 0.45);
  --game-glow-success: rgba(88, 230, 160, 0.45);
  --game-glow-warning: rgba(255, 189, 89, 0.45);

  /* ── 3. Geometry & Radii ── */
  --game-radius-xs: 0.5rem;
  --game-radius-sm: 0.75rem;
  --game-radius-md: 1rem;
  --game-radius-lg: 1.35rem;
  --game-radius-xl: 1.75rem;
  --game-radius-full: 9999px;

  /* ── 4. Motion Language Tokens ── */
  --game-ease-bounce: cubic-bezier(0.22, 1.25, 0.36, 1);
  --game-ease-smooth: cubic-bezier(0.25, 1, 0.5, 1);
  --game-ease-press: cubic-bezier(0.3, 0, 0.8, 0.15);

  --game-dur-hover: 160ms;
  --game-dur-press: 110ms;
  --game-dur-toggle: 180ms;
  --game-dur-modal: 250ms;
  --game-dur-toast: 220ms;
}

/* ── Global Lock for Modals ── */
body.qz-modal-locked {
  overflow: hidden !important;
  touch-action: none;
}

/* ══════════════════════════════════════════════════════════════════
   3. TACTILE GAME BUTTONS
   Rounded rectangular silhouette, vertical gradient, beveled edges,
   3D push depth, outer glow, inner shadow, bold rounded typography.
   ══════════════════════════════════════════════════════════════════ */

.qz-game-btn,
.qmf-btn {
  --btn-face-top: #8b5cf6;
  --btn-face-mid: #7546f9;
  --btn-face-bot: #5b28d6;
  --btn-edge: var(--game-edge-primary);
  --btn-glow: var(--game-glow-primary);
  --btn-push-y: 0px;
  --btn-edge-h: 5px;

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  box-sizing: border-box;
  margin: 0;
  padding: 0.85rem 1.65rem;
  border: 0;
  border-bottom: var(--btn-edge-h) solid var(--btn-edge);
  border-radius: var(--game-radius-md);
  background:
    linear-gradient(180deg, var(--game-bevel-top) 0%, transparent 42%),
    linear-gradient(180deg, var(--btn-face-top) 0%, var(--btn-face-mid) 54%, var(--btn-face-bot) 100%);
  color: var(--game-text);
  font-family: "Fredoka", "Baloo 2", var(--qmf-font-sans, system-ui, sans-serif);
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  line-height: 1.25;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  isolation: isolate;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -2px 5px rgba(0, 0, 0, 0.25),
    0 2px 0 rgba(0, 0, 0, 0.28),
    0 8px 22px var(--btn-glow);
  transform: translateY(var(--btn-push-y));
  transition:
    transform var(--game-dur-hover) var(--game-ease-bounce),
    filter var(--game-dur-hover) ease,
    border-bottom-width var(--game-dur-press) ease,
    box-shadow var(--game-dur-hover) ease;
}

/* Light beam sweep on hover */
.qz-game-btn::before,
.qmf-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 28%,
    rgba(255, 255, 255, 0.35) 48%,
    transparent 64%
  );
  transform: translateX(-140%);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

/* Button Variants */
.qmf-btn--primary,
.qz-game-btn--primary {
  --btn-face-top: #8b5cf6;
  --btn-face-mid: #7546f9;
  --btn-face-bot: #5821d6;
  --btn-edge: #4316ad;
  --btn-glow: rgba(117, 70, 249, 0.48);
}

.qmf-btn--secondary,
.qz-game-btn--secondary {
  --btn-face-top: #3654d9;
  --btn-face-mid: #253b9f;
  --btn-face-bot: #1a2a78;
  --btn-edge: var(--game-edge-secondary);
  --btn-glow: rgba(37, 59, 159, 0.45);
}

.qmf-btn--danger,
.qmf-btn--destructive,
.qz-game-btn--danger {
  --btn-face-top: #ff6e82;
  --btn-face-mid: #ff526b;
  --btn-face-bot: #d62440;
  --btn-edge: var(--game-edge-danger);
  --btn-glow: var(--game-glow-error);
}

.qmf-btn--success,
.qz-game-btn--success {
  --btn-face-top: #73f0b2;
  --btn-face-mid: #58e6a0;
  --btn-face-bot: #28b871;
  --btn-edge: var(--game-edge-success);
  --btn-glow: var(--game-glow-success);
}

.qz-game-btn--accent {
  --btn-face-top: #89e4ff;
  --btn-face-mid: #5ed7ff;
  --btn-face-bot: #22a9d6;
  --btn-edge: #0f7596;
  --btn-glow: var(--game-glow-accent);
  color: #080d29;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* Sizes */
.qmf-btn--sm {
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  border-radius: var(--game-radius-sm);
  --btn-edge-h: 3.5px;
}

.qmf-btn--md {
  padding: 0.75rem 1.35rem;
  font-size: 1rem;
}

.qmf-btn--lg {
  min-height: 3.45rem;
  padding: 0.95rem 1.85rem;
  font-size: 1.15rem;
  border-radius: var(--game-radius-md);
  --btn-edge-h: 5px;
}

.qz-btn-block {
  width: 100%;
}

/* Icon Buttons */
.qz-game-btn--icon {
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: var(--game-radius-md);
}

/* Hover State */
.qz-game-btn:hover:not(:disabled):not(.is-loading):not(.qmf-btn--loading),
.qmf-btn:hover:not(:disabled):not(.is-loading):not(.qmf-btn--loading) {
  --btn-push-y: -2.5px;
  filter: brightness(1.1) saturate(1.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 6px rgba(0, 0, 0, 0.2),
    0 3px 0 rgba(0, 0, 0, 0.25),
    0 12px 28px var(--btn-glow),
    0 0 18px var(--btn-glow);
}

.qz-game-btn:hover:not(:disabled):not(.is-loading):not(.qmf-btn--loading)::before,
.qmf-btn:hover:not(:disabled):not(.is-loading):not(.qmf-btn--loading)::before {
  opacity: 1;
  animation: qz-btn-shine 850ms ease-out;
}

/* Pressed State */
.qz-game-btn:active:not(:disabled):not(.is-loading):not(.qmf-btn--loading),
.qmf-btn:active:not(:disabled):not(.is-loading):not(.qmf-btn--loading),
.qz-game-btn.is-pressed,
.qmf-btn.is-pressed {
  --btn-push-y: 3px;
  border-bottom-width: 2px;
  filter: brightness(0.96);
  box-shadow:
    inset 0 2px 7px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(0, 0, 0, 0.3),
    0 4px 12px var(--btn-glow);
  transition-duration: var(--game-dur-press);
}

/* Focus State */
.qz-game-btn:focus-visible,
.qmf-btn:focus-visible {
  outline: 2px solid var(--game-accent);
  outline-offset: 3px;
}

/* Disabled State */
.qz-game-btn:disabled,
.qmf-btn:disabled {
  opacity: 0.45;
  filter: grayscale(0.55);
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  border-bottom-width: 3px !important;
}

/* Loading State */
.qz-game-btn.is-loading,
.qmf-btn.is-loading,
.qmf-btn--loading {
  pointer-events: none;
  cursor: wait;
  position: relative;
  color: transparent !important;
  text-shadow: none !important;
}

.qz-game-btn.is-loading::after,
.qmf-btn.is-loading::after,
.qmf-btn--loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.4rem;
  height: 1.4rem;
  margin: -0.7rem 0 0 -0.7rem;
  border: 2.5px solid rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
  border-radius: 50%;
  animation: qz-spin 650ms linear infinite;
  z-index: 2;
}

@keyframes qz-btn-shine {
  from { transform: translateX(-140%); opacity: 0.1; }
  40% { opacity: 0.9; }
  to { transform: translateX(140%); opacity: 0; }
}

@keyframes qz-spin {
  to { transform: rotate(360deg); }
}


/* ══════════════════════════════════════════════════════════════════
   4. NOTIFICATIONS AND ERROR MESSAGES (HUD TOAST SYSTEM)
   Floating rounded panel, dark tinted background, colored illuminated
   border, leading status icon, readable message, dimensional shadow.
   ══════════════════════════════════════════════════════════════════ */

.qz-hud-toast-container {
  position: fixed;
  top: max(1.15rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: min(30rem, calc(100vw - 1.5rem));
  pointer-events: none;
}

.qz-hud-toast {
  --toast-accent: var(--game-error);
  --toast-glow: var(--game-glow-error);
  --toast-border: rgba(255, 82, 107, 0.55);

  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.85rem 1.05rem;
  border-radius: var(--game-radius-md);
  border: 1.5px solid var(--toast-border);
  background:
    radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--toast-accent) 22%, transparent) 0%, transparent 60%),
    linear-gradient(165deg, rgba(27, 35, 69, 0.96) 0%, rgba(17, 24, 50, 0.98) 100%);
  backdrop-filter: blur(18px) saturate(1.2);
  color: var(--game-text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 0 24px var(--toast-glow);
  pointer-events: auto;
  animation: qz-toast-enter var(--game-dur-toast) var(--game-ease-bounce) both;
}

.qz-hud-toast.is-leaving {
  animation: qz-toast-leave 180ms ease forwards;
}

/* Toast Variants */
.qz-hud-toast--error {
  --toast-accent: var(--game-error);
  --toast-glow: var(--game-glow-error);
  --toast-border: rgba(255, 82, 107, 0.55);
}

.qz-hud-toast--warning {
  --toast-accent: var(--game-warning);
  --toast-glow: var(--game-glow-warning);
  --toast-border: rgba(255, 189, 89, 0.55);
}

.qz-hud-toast--success {
  --toast-accent: var(--game-success);
  --toast-glow: var(--game-glow-success);
  --toast-border: rgba(88, 230, 160, 0.55);
}

.qz-hud-toast--info {
  --toast-accent: var(--game-accent);
  --toast-glow: var(--game-glow-accent);
  --toast-border: rgba(94, 215, 255, 0.55);
}

.qz-hud-toast__icon-wrap {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: var(--game-radius-sm);
  background: color-mix(in srgb, var(--toast-accent) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--toast-accent) 45%, transparent);
  color: var(--toast-accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--toast-accent) 35%, transparent);
  flex-shrink: 0;
}

.qz-hud-toast__icon-wrap svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.qz-hud-toast__body {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.qz-hud-toast__msg {
  margin: 0;
  font-family: "Fredoka", "Baloo 2", var(--qmf-font-sans, system-ui, sans-serif);
  font-size: 0.96rem;
  font-weight: 650;
  line-height: 1.35;
  color: var(--game-text);
  word-break: break-word;
}

.qz-hud-toast__close {
  display: grid;
  place-items: center;
  width: 1.95rem;
  height: 1.95rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--game-radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: var(--game-text-muted);
  cursor: pointer;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    color 140ms ease;
}

.qz-hud-toast__close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  transform: scale(1.08);
}

.qz-hud-toast__close svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

@keyframes qz-toast-enter {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes qz-toast-leave {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }
}


/* ══════════════════════════════════════════════════════════════════
   5. GAME MODALS / POPUPS
   Layered dark glass surface, rounded corners, thin luminous edge,
   subtle bevel, ambient shadow, dimmed blurred backdrop.
   ══════════════════════════════════════════════════════════════════ */

.qz-game-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 50% 30%, rgba(117, 70, 249, 0.16) 0%, transparent 65%),
    rgba(8, 13, 41, 0.76);
  backdrop-filter: blur(12px) saturate(1.15);
  animation: qz-fade-in var(--game-dur-modal) ease-out;
}

.qz-game-modal-backdrop[hidden] {
  display: none !important;
}

/* ── Shared Game Dialog Chassis ── */
.qz-dialog-chassis,
.qz-game-modal {
  position: relative;
  width: min(32rem, 100%);
  max-height: calc(100dvh - 2.5rem);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border-radius: var(--game-radius-xl);
  border: 2px solid #2e265c;
  border-top: 2.5px solid #8b5cf6;
  border-bottom: 5px solid #0d0922;
  background:
    radial-gradient(ellipse 90% 50% at 50% 0%, rgba(139, 92, 246, 0.22), transparent 70%),
    linear-gradient(180deg, #182046 0%, #111832 50%, #0d1228 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(117, 70, 249, 0.2),
    0 24px 60px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(117, 70, 249, 0.28);
  color: var(--game-text);
  animation: qz-modal-scale-in var(--game-dur-modal) var(--game-ease-bounce);
}

.qz-game-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.4rem 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.qz-game-modal__titles {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.qz-game-modal__kicker {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--game-accent);
  text-shadow: 0 0 14px var(--game-glow-accent);
}

.qz-game-modal__title {
  margin: 0;
  font-family: "Baloo 2", "Fredoka", sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 0 16px rgba(117, 70, 249, 0.4);
}

/* Compact tactile 3D red arcade close button */
.qz-dialog-close,
.qz-game-modal__close {
  display: grid;
  place-items: center;
  position: relative;
  width: 2rem;
  height: 2rem;
  padding: 0;
  flex: 0 0 auto;
  border: 0;
  border-bottom: 3.5px solid #851628;
  border-radius: 0.55rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, transparent 45%),
    linear-gradient(180deg, #ff6b81 0%, #e8334d 50%, #c41e37 100%);
  color: #fff;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.4),
    0 0 12px rgba(255, 82, 107, 0.35);
  transform: translateY(0);
  transition:
    transform 110ms cubic-bezier(0.22, 1.25, 0.36, 1),
    border-bottom-width 90ms ease,
    filter 120ms ease;
}

.qz-dialog-close svg,
.qz-game-modal__close svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.qz-dialog-close:hover,
.qz-game-modal__close:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.45),
    0 0 16px rgba(255, 82, 107, 0.55);
}

.qz-dialog-close:active,
.qz-game-modal__close:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  filter: brightness(0.95);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.qz-dialog-close:focus-visible,
.qz-game-modal__close:focus-visible {
  outline: 2px solid var(--game-accent);
  outline-offset: 2px;
}

/* Inset console content surface — NO cards-in-card */
.qz-dialog-surface,
.qz-game-modal__content {
  margin: 0.85rem 1rem;
  padding: 1.15rem 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 0.95rem;
  background: #080d22;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.75),
    inset 0 0 1px rgba(255, 255, 255, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.06);
}

.qz-game-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.qz-lumen-dialog {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 50% 30%, rgba(117, 70, 249, 0.22) 0%, transparent 65%),
    rgba(8, 13, 41, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  animation: qz-fade-in var(--game-dur-modal) ease-out;
}

.qz-lumen-dialog__card {
  position: relative;
  width: min(24rem, 100%);
  padding: 1.85rem 1.65rem 1.65rem;
  display: grid;
  gap: 0.85rem;
  text-align: center;
  border-radius: var(--game-radius-xl);
  border: 1px solid rgba(117, 70, 249, 0.42);
  background:
    radial-gradient(ellipse 90% 50% at 50% 0%, rgba(94, 215, 255, 0.16), transparent 70%),
    linear-gradient(165deg, rgba(27, 35, 69, 0.95) 0%, rgba(17, 24, 50, 0.98) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 24px 55px rgba(0, 0, 0, 0.6),
    0 0 38px rgba(117, 70, 249, 0.32);
  color: var(--game-text);
  animation: qz-modal-scale-in var(--game-dur-modal) var(--game-ease-bounce);
}

.qz-lumen-dialog__icon {
  font-size: 2.25rem;
  line-height: 1;
  margin: 0;
  filter: drop-shadow(0 0 16px var(--game-glow-warning));
}

.qz-lumen-dialog__title {
  margin: 0;
  font-family: "Baloo 2", "Fredoka", sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 20px rgba(117, 70, 249, 0.4);
}

.qz-lumen-dialog__desc {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--game-text-muted);
}

.qz-lumen-dialog__perks {
  margin: 0.35rem 0;
  padding: 0.85rem 1rem;
  list-style: none;
  text-align: left;
  border-radius: var(--game-radius-md);
  background: rgba(8, 13, 41, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.4);
}

.qz-lumen-dialog__perks li {
  color: var(--game-text);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.5;
}

.qz-lumen-dialog__actions {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.qz-lumen-dialog__skip {
  padding: 0.65rem;
  border: 0;
  background: transparent;
  color: var(--game-text-muted);
  font-family: "Fredoka", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--game-dur-hover) ease;
}

.qz-lumen-dialog__skip:hover {
  color: #fff;
}

/* Homework Join Screen Fantasy Arcade Polish */
.hw-join__card {
  border-radius: var(--game-radius-xl) !important;
  border: 1px solid rgba(117, 70, 249, 0.35) !important;
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(117, 70, 249, 0.22) 0%, transparent 60%),
    linear-gradient(170deg, rgba(27, 35, 69, 0.95) 0%, rgba(17, 24, 50, 0.98) 100%) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 20px 48px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(117, 70, 249, 0.22) !important;
}

.hw-join__field {
  border-radius: var(--game-radius-md) !important;
  border: 1.5px solid rgba(117, 70, 249, 0.35) !important;
  background:
    linear-gradient(180deg, rgba(8, 13, 41, 0.95) 0%, rgba(17, 24, 50, 0.9) 100%) !important;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.6),
    inset 0 0 14px rgba(117, 70, 249, 0.08) !important;
  transition: border-color var(--game-dur-hover) ease, box-shadow var(--game-dur-hover) ease !important;
}

.hw-join__field:focus-within {
  border-color: var(--game-accent) !important;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.5),
    0 0 0 3px rgba(94, 215, 255, 0.25),
    0 0 24px rgba(94, 215, 255, 0.35) !important;
}

.hw-join__cta {
  border-bottom: 5px solid #0f7596 !important;
  border-radius: var(--game-radius-md) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32) 0%, transparent 42%),
    linear-gradient(180deg, #89e4ff 0%, #5ed7ff 54%, #22a9d6 100%) !important;
  color: #080d29 !important;
  font-size: 1.12rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.04em !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 2px 0 rgba(0, 0, 0, 0.28),
    0 8px 24px var(--game-glow-accent) !important;
  transform: translateY(0);
  transition: transform var(--game-dur-hover) var(--game-ease-bounce), filter var(--game-dur-hover) ease, border-bottom-width var(--game-dur-press) ease, box-shadow var(--game-dur-hover) ease !important;
}

.hw-join__cta:hover:not(:disabled) {
  transform: translateY(-2px) !important;
  filter: brightness(1.08) saturate(1.1) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 3px 0 rgba(0, 0, 0, 0.25),
    0 12px 28px var(--game-glow-accent),
    0 0 22px var(--game-glow-accent) !important;
}

.hw-join__cta:active:not(:disabled) {
  transform: translateY(3px) !important;
  border-bottom-width: 2px !important;
  filter: brightness(0.96) !important;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.35),
    0 1px 0 rgba(0, 0, 0, 0.3),
    0 4px 12px var(--game-glow-accent) !important;
}

@keyframes qz-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes qz-modal-scale-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ══════════════════════════════════════════════════════════════════
   6. INPUTS & VALIDATION STATES
   Recessed dark surface, illuminated focus glow, clear placeholder,
   distinct error border without causing layout shifts.
   ══════════════════════════════════════════════════════════════════ */

.qz-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 3.35rem;
  margin: 0;
  padding: 0.85rem 1.15rem;
  border-radius: var(--game-radius-md);
  border: 1.5px solid rgba(117, 70, 249, 0.35);
  background:
    linear-gradient(180deg, rgba(8, 13, 41, 0.95) 0%, rgba(17, 24, 50, 0.9) 100%);
  color: var(--game-text);
  caret-color: var(--game-accent);
  font-family: "Fredoka", "Baloo 2", var(--qmf-font-sans, system-ui, sans-serif);
  font-size: 1.05rem;
  font-weight: 650;
  outline: none;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.6),
    inset 0 0 14px rgba(117, 70, 249, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.25);
  transition:
    border-color var(--game-dur-hover) ease,
    box-shadow var(--game-dur-hover) ease,
    background-color var(--game-dur-hover) ease;
}

.qz-input::placeholder {
  color: var(--game-text-muted);
  font-weight: 500;
  opacity: 0.78;
}

.qz-input:hover:not([readonly]) {
  border-color: rgba(94, 215, 255, 0.5);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.6),
    0 0 14px rgba(94, 215, 255, 0.2);
}

.qz-input:focus {
  border-color: var(--game-accent);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.5),
    0 0 0 3px rgba(94, 215, 255, 0.25),
    0 0 24px rgba(94, 215, 255, 0.35);
}

/* Distinct Error State */
.qz-input.qz-input--error,
.qz-input.is-invalid {
  border-color: var(--game-error) !important;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.5),
    0 0 0 3px rgba(255, 82, 107, 0.3),
    0 0 24px rgba(255, 82, 107, 0.45) !important;
  animation: qz-input-shake 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes qz-input-shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(3px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}


/* ══════════════════════════════════════════════════════════════════
   7. AVATAR SELECTION (TACTILE 2.5D CHARACTER TILES)
   Centerpiece character tokens with subtle bevel, physical press,
   and clean selection badge.
   ══════════════════════════════════════════════════════════════════ */

.qz-avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(0.45rem, 1.2vw, 0.65rem);
  width: 100%;
}

.qz-avatar-pick {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0.3rem;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #242c55 0%, #161c3c 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -2px 4px rgba(0, 0, 0, 0.35),
    0 3px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  user-select: none;
  transition:
    transform 140ms cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.qz-avatar-pick .qmf-avatar,
.qz-avatar-pick .qz-face,
.qz-avatar-pick .qz-mascot {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.qz-avatar-pick:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 6px 14px rgba(0, 0, 0, 0.4);
}

.qz-avatar-pick:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.3);
}

.qz-avatar-pick.is-selected {
  border-color: #38bdf8;
  background: linear-gradient(180deg, #2b396e 0%, #1c2752 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 0 0 1.5px #38bdf8,
    0 4px 14px rgba(56, 189, 248, 0.25);
}

.qz-avatar-pick:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/* Floating Checkmark Badge */
.qz-avatar-check {
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  display: none;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid #0d1228;
  background: #22c55e;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  z-index: 3;
}

.qz-avatar-pick.is-selected .qz-avatar-check {
  display: grid;
  animation: qz-check-pop 200ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.qz-avatar-check svg {
  width: 0.8rem;
  height: 0.8rem;
}

@keyframes qz-check-pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}



/* ══════════════════════════════════════════════════════════════════
   8. CASUAL GAME CONSOLE ARCHITECTURE (Unified Cohesive Chassis)
   Grounded, tactile, soft 2.5D game panel with clear visual hierarchy,
   integrated single-border input, character dock, and physical button.
   ══════════════════════════════════════════════════════════════════ */

.qz-identity--casual,
.qz-identity--scene {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: clamp(1rem, 3.5vh, 2.5rem) 1rem !important;
  box-sizing: border-box !important;
  overflow-x: hidden;
  background: transparent !important;
}

/* Central Casual Game Console Chassis */
.qz-game-console,
.qz-scene-stage {
  position: relative;
  z-index: 1;
  width: clamp(320px, 92vw, 540px);
  margin: auto;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(23, 29, 58, 0.94) 0%, rgba(14, 18, 38, 0.97) 100%) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 26px !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 20px 48px rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: blur(16px) !important;
  padding: clamp(1.4rem, 3vh, 2rem) clamp(1.2rem, 3.5vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

/* Console Header */
.qz-console-header,
.qz-scene-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  text-align: center;
  width: 100%;
}

.qz-console-kicker,
.qz-scene-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.26rem 0.85rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.28);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.qz-console-kicker__dot,
.qz-scene-kicker__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.6);
  flex-shrink: 0;
}

.qz-console-kicker__text,
.qz-scene-kicker__text {
  font-family: "Fredoka", sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #a5b4fc;
  letter-spacing: 0.02em;
}

.qz-console-title,
.qz-scene-title {
  margin: 0;
  padding: 0;
  font-family: "Fredoka", "Baloo 2", sans-serif;
  font-size: clamp(1.45rem, 4.2vw, 1.85rem);
  font-weight: 700;
  line-height: 1.25;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Form Orchestrator */
.qz-game-form,
.qz-scene-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Control Groups & Labels */
.qz-game-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.qz-game-label,
.qz-scene-pod-label {
  font-family: "Fredoka", sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  color: #cbd5e1;
  text-align: left;
  letter-spacing: 0.01em;
}

/* Unified Name Input Component (Single border system, no nested pills) */
.qz-game-input-wrap,
.qz-scene-name-capsule {
  width: 100%;
  height: 3.15rem;
  border-radius: 14px;
  background: #090d20;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  padding: 0 0.95rem;
  gap: 0.65rem;
  box-sizing: border-box;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.qz-game-input-wrap:focus-within,
.qz-scene-name-capsule:focus-within {
  border-color: #6366f1;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.55),
    0 0 0 3px rgba(99, 102, 241, 0.22);
}

.qz-game-input-wrap.is-error,
.qz-scene-name-capsule.qz-scene-capsule--error {
  border-color: #f43f5e !important;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.55),
    0 0 0 3px rgba(244, 63, 94, 0.25) !important;
  animation: qz-input-shake 380ms ease;
}

.qz-game-input-icon,
.qz-scene-name-icon {
  display: grid;
  place-items: center;
  color: #64748b;
  flex-shrink: 0;
  transition: color 160ms ease;
}

.qz-game-input-wrap:focus-within .qz-game-input-icon,
.qz-scene-name-capsule:focus-within .qz-scene-name-icon {
  color: #818cf8;
}

.qz-game-input,
.qz-scene-nick-input,
.qz-identity__nick {
  flex: 1;
  min-width: 0;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: #ffffff !important;
  font-family: "Fredoka", sans-serif !important;
  font-size: 1.05rem !important;
  font-weight: 600 !important;
}

.qz-game-input::placeholder,
.qz-scene-nick-input::placeholder,
.qz-identity__nick::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

/* Character Selection Dock (Centerpiece Tray) */
.qz-roster-dock,
.qz-scene-roster {
  width: 100%;
  box-sizing: border-box;
  background: rgba(9, 13, 32, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 0.75rem 0.85rem;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.qz-roster-dock--locked {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.25rem;
}

/* Tactile 2.5D Casual-game Action Button */
.qz-game-action,
.qz-scene-action {
  width: 100%;
  margin-top: 0.25rem;
}

.qz-game-btn-start,
.qz-scene-btn-start {
  width: 100%;
  height: 3.35rem;
  border-radius: 15px;
  font-family: "Fredoka", "Baloo 2", sans-serif;
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffffff;
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-bottom: 4px solid #3730a3;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 6px 18px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  user-select: none;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    box-shadow 120ms ease;
}

.qz-game-btn-start:hover,
.qz-scene-btn-start:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 8px 22px rgba(0, 0, 0, 0.45);
}

.qz-game-btn-start:active,
.qz-scene-btn-start:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.3);
}

.qz-game-btn-start.is-loading,
.qz-scene-btn-start.qmf-btn--loading {
  opacity: 0.8;
  pointer-events: none;
}

/* Screen reader announcement without visual layout jump */
.qz-identity .qz-error {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ══════════════════════════════════════════════════════════════════
   9. PREFERS-REDUCED-MOTION SUPPORT
   ══════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
