* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #161233;
  color: #f8fafc;
  font-family: 'Fredoka', 'Nunito', 'Trebuchet MS', system-ui, -apple-system, sans-serif;
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

/* Shared Tactile Buttons */
.big-pill-btn {
  border: 3px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, background 0.15s ease;
}

.big-pill-btn:hover {
  transform: translateY(-2px);
  background: rgba(30, 41, 59, 0.95);
}

.big-pill-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

/* Hub Overlay */
.hub-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 18px 16px;
  z-index: 10;
}

.hub-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.academy-logo-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #4c1d95, #1d4ed8);
  border: 3px solid #fbbf24;
  color: #ffffff;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.hub-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.star-counter-pill {
  background: rgba(251, 191, 36, 0.22);
  border: 3px solid #fbbf24;
  color: #fde047;
  font-size: 1.15rem;
  font-weight: 900;
  padding: 0.52rem 0.95rem;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.hub-tip-pill {
  align-self: center;
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 0.26rem 0.85rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 2px;
}

.hub-bottom-area {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: auto;
  pointer-events: none;
}

.hub-dock-controls {
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.dock-toggle-btn {
  pointer-events: auto;
  border: 2px solid rgba(251, 191, 36, 0.55);
  background: rgba(15, 23, 42, 0.82);
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 0.34rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.dock-toggle-btn:hover {
  transform: translateY(-2px);
  background: rgba(30, 41, 59, 0.94);
  border-color: #fde047;
}

.dock-toggle-btn.open {
  background: rgba(30, 41, 59, 0.92);
  border-color: rgba(255, 255, 255, 0.35);
}

.hub-dock {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.84);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 26px;
  padding: 10px 14px 10px;
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  max-height: 48vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: max-height 0.25s ease;
}

.hub-dock.expanded {
  max-height: 76vh;
}

.hub-filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  padding: 0.34rem 0.72rem;
  border-radius: 999px;
  cursor: pointer;
}

.filter-chip.active {
  background: #fbbf24;
  border-color: #fef08a;
  color: #0f172a;
}

.hub-cards-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 6px;
  scrollbar-width: thin;
}

.hub-dock.expanded .hub-cards-track {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  overflow-x: hidden;
  overflow-y: auto;
}

.game-card {
  flex: 0 0 205px;
  background: linear-gradient(160deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98));
  border: 3px solid var(--card-color, #6366f1);
  border-radius: 20px;
  padding: 10px 12px;
  color: #ffffff;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.14s ease;
}

.hub-dock.expanded .game-card {
  flex: initial;
}

.game-card:hover {
  transform: translateY(-4px) scale(1.02);
}

.game-card.filtered-out {
  filter: grayscale(1) brightness(0.42) contrast(0.88);
  opacity: 0.55;
  transform: scale(0.96);
  box-shadow: none;
}

.game-card.filtered-out:hover {
  filter: grayscale(0.5) brightness(0.7);
  opacity: 0.86;
  transform: translateY(-2px) scale(0.99);
}

.nearby-prompt-pill {
  pointer-events: auto;
  align-self: center;
  margin-bottom: 2px;
  cursor: pointer;
  background: linear-gradient(135deg, #16a34a, #0284c7);
  border: 3px solid #fde047;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 900;
  padding: 0.55rem 1.35rem;
  border-radius: 999px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
  animation: popIn 0.2s ease;
}

.game-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.game-card-cat {
  font-size: 0.72rem;
  font-weight: 900;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.game-card-cat.math {
  background: rgba(249, 115, 22, 0.3);
  color: #fed7aa;
}

.game-card-cat.reading {
  background: rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
}

.game-card-title {
  font-size: 1.05rem;
  font-weight: 900;
}

.game-card-sub {
  font-size: 0.75rem;
  color: #cbd5e1;
  line-height: 1.22;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-card-footer {
  margin-top: 4px;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fde047;
}

/* In-Game HUD */
.game-hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 18px 18px;
  z-index: 15;
}

.hud-top {
  position: relative;
  z-index: 20;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-btn {
  background: #dc2626;
  border-color: #fca5a5;
  font-size: 1.15rem;
}

.repeat-btn {
  background: #2563eb;
  border-color: #93c5fd;
  font-size: 1.15rem;
}

.hud-center-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.2);
  padding: 6px 18px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.game-badge-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #e2e8f0;
}

.round-stars {
  display: flex;
  gap: 6px;
  font-size: 1.45rem;
}

.star-pip {
  opacity: 0.45;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.star-pip.earned {
  opacity: 1;
  transform: scale(1.12);
}

.hud-prompt-wrap {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.hud-prompt-card {
  pointer-events: auto;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.86);
  border: 3px solid #fbbf24;
  color: #ffffff;
  font-size: clamp(1.15rem, 2.5vw, 1.75rem);
  font-weight: 900;
  padding: 0.65rem 1.6rem;
  border-radius: 999px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
}

.hud-toast {
  position: relative;
  z-index: 22;
  align-self: center;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-size: 1.3rem;
  font-weight: 900;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: popIn 0.2s ease;
}

.hud-toast.success {
  background: #16a34a;
  border: 3px solid #86efac;
  color: #ffffff;
}

.hud-toast.hint {
  background: #d97706;
  border: 3px solid #fde68a;
  color: #ffffff;
}

.hud-choices {
  pointer-events: auto;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: auto;
}

.hud-choices.empty {
  display: none;
}

.hud-choice-btn {
  min-width: 112px;
  padding: 0.75rem 1.35rem;
  border-radius: 22px;
  border: 4px solid rgba(255, 255, 255, 0.45);
  background: var(--choice-color, #6366f1);
  color: #ffffff;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.42);
  transition: transform 0.12s ease;
}

.hud-choice-btn:hover {
  transform: translateY(-4px) scale(1.05);
}

.hud-choice-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.42);
}

.choice-main {
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1.05;
}

.choice-sub {
  font-size: 0.85rem;
  font-weight: 800;
  opacity: 0.95;
}

/* Modals (Stickers, Settings, Victory) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 22, 0.76);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 30;
}

.modal-card {
  background: linear-gradient(160deg, #1e1b4b, #0f172a);
  border: 4px solid #fbbf24;
  border-radius: 28px;
  padding: 22px 24px;
  width: min(720px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.65rem;
}

.modal-subtitle {
  color: #cbd5e1;
  margin: 8px 0 16px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.sticker-card {
  border-radius: 20px;
  padding: 14px 10px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 41, 59, 0.75);
  color: #ffffff;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.sticker-card.unlocked {
  border-color: var(--accent, #fbbf24);
  background: rgba(49, 46, 129, 0.75);
}

.sticker-card.locked {
  opacity: 0.6;
}

.sticker-emoji {
  font-size: 2.7rem;
}

.sticker-name {
  font-size: 0.95rem;
  font-weight: 900;
}

.sticker-game {
  font-size: 0.75rem;
  color: #94a3b8;
}

.victory-modal {
  text-align: center;
  width: min(520px, 100%);
}

.victory-trophy {
  font-size: 4.5rem;
  animation: popIn 0.35s ease;
}

.victory-sticker-box {
  margin: 14px auto;
  padding: 14px;
  background: rgba(251, 191, 36, 0.14);
  border: 2px dashed #fbbf24;
  border-radius: 20px;
}

.unlocked-emoji {
  font-size: 3.2rem;
  margin-bottom: 4px;
}

.victory-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.huge-action-btn {
  border: 3px solid #fef08a;
  background: #16a34a;
  color: #ffffff;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 900;
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
}

.more-games-btn {
  background: #2563eb;
}

.settings-section {
  margin-top: 18px;
}

.settings-label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
  color: #fde047;
}

.difficulty-pills,
.row-switches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.diff-btn,
.toggle-btn {
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: #1e293b;
  color: #ffffff;
  font-family: inherit;
  font-weight: 800;
  padding: 0.65rem 1rem;
  border-radius: 14px;
  cursor: pointer;
}

.diff-btn.active {
  background: #10b981;
  border-color: #6ee7b7;
}

.danger-pill-btn {
  border: 2px solid #fca5a5;
  background: #991b1b;
  color: #ffffff;
  font-family: inherit;
  font-weight: 800;
  padding: 0.6rem 1.1rem;
  border-radius: 14px;
  cursor: pointer;
}

.dev-tip {
  font-size: 0.9rem;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.7);
  padding: 10px 12px;
  border-radius: 12px;
}

.webgl-fallback {
  max-width: 500px;
  margin: 12vh auto;
  padding: 24px;
  background: #1e293b;
  border-radius: 20px;
  text-align: center;
}

/* Split-Screen Overlay */
.split-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

.split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 6px;
  margin-left: -3px;
  background: linear-gradient(180deg, #fbbf24, #38bdf8, #ef4444, #fbbf24);
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.75);
}

.split-side {
  position: absolute;
  top: 132px;
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.split-side.left {
  left: 0;
}

.split-side.right {
  right: 0;
}

.split-player-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.95rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.split-player-badge.p1 {
  background: rgba(30, 58, 138, 0.88);
  border: 3px solid #60a5fa;
  color: #ffffff;
}

.split-player-badge.p2 {
  background: rgba(127, 29, 29, 0.88);
  border: 3px solid #f87171;
  color: #ffffff;
}

.split-keys {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 2px 9px;
  border-radius: 8px;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: #fde047;
}

.split-score {
  color: #fde047;
  font-size: 1.05rem;
}

.split-sub {
  background: rgba(15, 23, 42, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.22);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #f8fafc;
}

.split-sub:empty {
  display: none;
}

@keyframes popIn {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .hub-tip-pill {
    display: none;
  }
  .game-card {
    flex: 0 0 172px;
  }
  .hud-choice-btn {
    min-width: 86px;
    padding: 0.6rem 0.95rem;
  }
  .choice-main {
    font-size: 1.55rem;
  }
}
