/* LexiCube 3D — Responsive Glassmorphic UI & Dynamic Per-Tier Theming */
:root {
  --accent: #ff9f1c;
  --accent-2: #2ec4b6;
  --glass: rgba(15, 23, 42, 0.72);
  --glass-light: rgba(255, 255, 255, 0.14);
  --border: rgba(255, 255, 255, 0.22);
  --text: #f8fafc;
  --text-muted: #cbd5e1;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}

body[data-tier="tk"] {
  --accent: #ff9f1c;
  --accent-2: #2ec4b6;
  --glass: rgba(24, 34, 56, 0.76);
}
body[data-tier="sd"] {
  --accent: #00b4d8;
  --accent-2: #ff6b6b;
  --glass: rgba(11, 37, 69, 0.78);
}
body[data-tier="smp"] {
  --accent: #e9c46a;
  --accent-2: #f4a261;
  --glass: rgba(29, 34, 56, 0.82);
}
body[data-tier="sma"] {
  --accent: #00f5d4;
  --accent-2: #f15bb5;
  --glass: rgba(11, 16, 35, 0.82);
}
body[data-tier="mahasiswa"] {
  --accent: #c77dff;
  --accent-2: #ffd166;
  --glass: rgba(18, 11, 38, 0.84);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: var(--text);
  background: #0b1020;
  user-select: none;
}

#canvas-wrap {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: grab;
}
#canvas-wrap:active {
  cursor: grabbing;
}
#canvas-wrap.pointer-hover {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ===================================================
   WORLD MAP / MENU OVERLAY
   =================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(10, 14, 30, 0.42), rgba(7, 10, 24, 0.8));
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

.menu-shell {
  width: min(1120px, 100%);
  max-height: 94vh;
  overflow-y: auto;
  padding: 28px 30px;
  border-radius: 26px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.menu-header {
  text-align: center;
  margin-bottom: 24px;
}

.brand-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #fde68a;
  margin-bottom: 10px;
}

.brand-title {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.brand-title span {
  background: linear-gradient(135deg, #ffbe0b, #00f5d4, #c77dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-desc {
  max-width: 680px;
  margin: 10px auto 16px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.menu-top-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.stat-chip, .pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

.pill-btn {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.pill-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 980px) {
  .tier-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .tier-grid {
    grid-template-columns: 1fr;
  }
}

.tier-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  text-align: left;
  color: #fff;
  overflow: hidden;
}

.tier-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--card-accent, #00f5d4);
}

.tier-card:hover {
  transform: translateY(-5px);
  border-color: var(--card-accent, #00f5d4);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4);
  background: rgba(255, 255, 255, 0.12);
}

.tier-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tier-emoji {
  font-size: 32px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
}

.tier-cefr {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--card-accent);
}

.tier-code {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.tier-world {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--card-accent);
  margin-top: 2px;
}

.tier-sub {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
  margin: 8px 0 14px;
  flex: 1;
}

.tier-progress-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  margin-bottom: 8px;
}

.tier-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--card-accent);
  transition: width 0.3s ease;
}

.tier-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
}

.menu-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ===================================================
   IN-GAME HUD (UNOBTRUSIVE FLOATING OVERLAYS)
   =================================================== */
.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 18px;
}

.hud-top, .prompt-card, .hud-bottom {
  pointer-events: auto;
}

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

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-pill, .tier-pill, .mini-stat, .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.icon-pill, .icon-btn {
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.icon-pill:hover, .icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}
.icon-btn {
  width: 40px;
  padding: 0;
  justify-content: center;
  font-size: 15px;
}
.icon-btn.off {
  opacity: 0.45;
}

.tier-pill .sep {
  opacity: 0.45;
}
.stage-tag {
  margin-left: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: #0f172a;
  font-size: 12px;
  font-weight: 900;
}

/* Prompt Card */
.prompt-card {
  align-self: center;
  margin-top: 8px;
  margin-bottom: auto;
  width: min(820px, 100%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.prompt-emoji {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.prompt-body {
  flex: 1;
  min-width: 0;
}

.prompt-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.type-badge, .cefr-badge, .clue-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.type-badge {
  background: var(--accent);
  color: #0f172a;
}
.cefr-badge {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.clue-pill {
  background: rgba(255, 209, 102, 0.18);
  border: 1px solid rgba(255, 209, 102, 0.45);
  color: #fde68a;
}

.prompt-text {
  font-size: clamp(14.5px, 2vw, 18.5px);
  font-weight: 700;
  line-height: 1.35;
  color: #ffffff;
}

.prompt-sub {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.35;
  color: #cbd5e1;
}

.speak-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 15px;
  border-radius: 14px;
  border: 1px solid var(--accent);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease;
}
.speak-btn:hover {
  background: var(--accent);
  color: #0f172a;
  transform: scale(1.03);
}

/* Bottom Dock */
.hud-bottom {
  align-self: center;
  width: min(860px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stage-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: var(--glass);
  color: #cbd5e1;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.stage-dot:hover {
  transform: scale(1.12);
}
.stage-dot.solved {
  background: rgba(16, 185, 129, 0.85);
  border-color: #a7f3d0;
  color: #fff;
}
.stage-dot.active {
  background: var(--accent);
  border-color: #fff;
  color: #0f172a;
  transform: scale(1.16);
}

.dock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.dock-status {
  font-size: 13.5px;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.02em;
  flex: 1;
  min-width: 180px;
}

.dock-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  transition: transform 0.14s ease, background 0.14s ease;
}
.action-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.22);
}
.action-btn.hint {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #0f172a;
  border-color: #fef08a;
}

/* ===================================================
   MODALS & TOAST
   =================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 10, 24, 0.65);
  backdrop-filter: blur(7px);
}

.modal-card {
  width: min(490px, 100%);
  padding: 26px 26px 24px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: popIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.88) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-stars {
  font-size: 38px;
  letter-spacing: 6px;
  margin-bottom: 6px;
}

.trophy-icon {
  font-size: 58px;
  margin-bottom: 6px;
}

.modal-title {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 12px;
  color: #fff;
}

.solved-answer-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(52, 211, 153, 0.55);
  margin-bottom: 14px;
  max-width: 100%;
}

.solved-answer {
  font-size: 18px;
  font-weight: 900;
  color: #6ee7b7;
  line-height: 1.35;
}

.mini-speak-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
}
.mini-speak-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal-explain {
  font-size: 14.5px;
  line-height: 1.55;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.modal-rewards {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.reward-chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

.reward-chip.streak {
  background: rgba(249, 115, 22, 0.2);
  border-color: rgba(251, 146, 60, 0.5);
  color: #fed7aa;
}

.primary-cta {
  width: 100%;
  padding: 13px 20px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0f172a;
  font-size: 15.5px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
}
.primary-cta:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.modal-btn-row {
  display: flex;
  gap: 10px;
}
.modal-btn-row .primary-cta {
  flex: 1;
}

.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
  font-size: 13.5px;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

@media (max-width: 680px) {
  .prompt-card {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 10px;
  }
  .prompt-emoji {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  .speak-btn {
    width: 100%;
    justify-content: center;
    padding: 8px;
  }
  .dock-bar {
    padding: 8px 10px;
  }
}
