/* Hyrule Sheikah Slate & Antique Gold Aesthetic */
:root {
  --slate-bg: rgba(11, 21, 36, 0.84);
  --slate-strong: rgba(9, 17, 30, 0.94);
  --gold: #e5b963;
  --gold-soft: rgba(229, 185, 99, 0.34);
  --cyan: #38e8ff;
  --cyan-soft: rgba(56, 232, 255, 0.32);
  --emerald: #34d399;
  --crimson: #fb7185;
  --text-main: #f8fafc;
  --text-muted: #9eb3cc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #0d1b2a;
  color: var(--text-main);
  user-select: none;
}

#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.hidden {
  display: none !important;
}

/* Signature Sheikah Slate Frame with Gold Filigree & Cyan Edge */
.sheikah-frame {
  background: linear-gradient(160deg, rgba(13, 27, 46, 0.88), rgba(8, 16, 29, 0.92));
  backdrop-filter: blur(14px);
  border: 1.5px solid var(--gold-soft);
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(56, 232, 255, 0.14),
    inset 0 1px 18px rgba(56, 232, 255, 0.08);
  border-radius: 14px;
}

/* Loading Splash */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: radial-gradient(circle at center, #132c47 0%, #07101d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.45s ease;
}

.loading-card {
  text-align: center;
  padding: 36px 46px;
  max-width: 540px;
}

.sheikah-eye-emblem {
  font-size: 38px;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 14px rgba(56, 232, 255, 0.75));
}

.loading-logo {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1.5px;
  background: linear-gradient(120deg, #fef08a, #38e8ff, #e5b963);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.loading-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.loading-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(56, 232, 255, 0.3);
}

.loading-fill {
  height: 100%;
  width: 25%;
  background: linear-gradient(90deg, #38e8ff, #fbbf24);
  border-radius: 99px;
  transition: width 0.3s ease;
}

/* Top HUD */
.hud-top {
  position: fixed;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 13px;
  flex-wrap: wrap;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.brand-icon {
  font-size: 25px;
  filter: drop-shadow(0 0 8px rgba(229, 185, 99, 0.6));
}

.brand-title {
  font-weight: 800;
  font-size: 15.5px;
  letter-spacing: 0.8px;
  color: #fef3c7;
}

.brand-sub {
  font-size: 11px;
  color: var(--cyan);
  font-weight: 600;
}

.hud-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.nav-btn {
  border: 1px solid rgba(229, 185, 99, 0.22);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  padding: 5.5px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-btn:hover {
  background: rgba(56, 232, 255, 0.16);
  border-color: var(--cyan);
  color: #fff;
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(56, 232, 255, 0.28), rgba(229, 185, 99, 0.24));
  border-color: var(--gold);
  color: #fef9c3;
  box-shadow: 0 0 12px rgba(56, 232, 255, 0.25);
}

.nav-btn.nav-boss {
  border-color: rgba(251, 113, 133, 0.45);
  color: #fecdd3;
}
.nav-btn.nav-boss:hover {
  background: rgba(239, 68, 68, 0.28);
  border-color: #fb7185;
}

.nav-btn.nav-compendium {
  border-color: rgba(251, 191, 36, 0.5);
  color: #fef08a;
  background: rgba(251, 191, 36, 0.12);
}
.nav-btn.nav-compendium:hover {
  background: rgba(251, 191, 36, 0.25);
}

.badge-due {
  background: #ef4444;
  color: #fff;
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 99px;
  font-weight: 700;
}

.badge-relic {
  background: rgba(251, 191, 36, 0.25);
  border: 1px solid rgba(251, 191, 36, 0.65);
  color: #fde047;
  font-size: 10.5px;
  padding: 0 6px;
  border-radius: 99px;
  font-weight: 800;
}

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

.search-box {
  position: relative;
}

#global-search {
  width: 190px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--gold-soft);
  background: rgba(7, 15, 28, 0.85);
  color: #fff;
  font-size: 12.5px;
  outline: none;
  user-select: text;
}

#global-search:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(56, 232, 255, 0.28);
}

.search-dropdown {
  position: absolute;
  top: 38px;
  right: 0;
  width: 350px;
  max-height: 410px;
  overflow-y: auto;
  background: var(--slate-strong);
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.72);
  z-index: 60;
}

.search-item {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.search-item:hover {
  background: rgba(56, 232, 255, 0.16);
}

.search-word {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.search-zh {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
}

.stat-pill {
  padding: 4.5px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(229, 185, 99, 0.24);
  font-size: 12px;
  font-weight: 700;
  color: #fef3c7;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--gold-soft);
  background: rgba(255, 255, 255, 0.07);
  color: #fef3c7;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(56, 232, 255, 0.22);
  border-color: var(--cyan);
}

/* Next Relic Tracker Pill */
.next-relic-pill {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.next-relic-pill:hover {
  transform: translateX(-50%) translateY(-1px);
  border-color: var(--cyan);
}

.next-relic-icon {
  font-size: 20px;
}

.next-relic-info {
  min-width: 175px;
}

.next-relic-title {
  font-size: 12px;
  font-weight: 700;
  color: #fef08a;
  margin-bottom: 3px;
}

.next-relic-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  overflow: hidden;
}

.next-relic-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38e8ff, #fbbf24);
  transition: width 0.35s ease;
}

.next-relic-pct {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--cyan);
}

/* Stamina Wheel */
.stamina-hud {
  position: fixed;
  bottom: 52px;
  right: 20px;
  z-index: 16;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #86efac;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

/* Left Panel */
.panel-left {
  position: fixed;
  top: 70px;
  left: 12px;
  bottom: 42px;
  width: 318px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}

.panel-left.collapsed {
  transform: translateX(-278px);
}

.panel-header {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(229, 185, 99, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-weight: 800;
  font-size: 14px;
  color: #fef3c7;
}

.collapse-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--gold-soft);
  color: #fef3c7;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  cursor: pointer;
}

.panel-body {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.filter-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--gold-soft);
  background: rgba(7, 15, 28, 0.85);
  color: #fff;
  font-size: 13px;
  outline: none;
  user-select: text;
}

.cefr-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid rgba(229, 185, 99, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: rgba(56, 232, 255, 0.22);
  border-color: var(--cyan);
  color: #fff;
}

.group-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(229, 185, 99, 0.2);
  cursor: pointer;
  transition: all 0.16s ease;
}

.group-card:hover {
  background: rgba(56, 232, 255, 0.14);
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.group-card.active {
  background: rgba(52, 211, 153, 0.16);
  border-color: var(--emerald);
}

.group-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.group-card-title {
  font-weight: 700;
  font-size: 13.5px;
  color: #f8fafc;
}

.group-card-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.mini-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  margin-top: 6px;
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38e8ff, #fbbf24);
}

.action-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary, .btn-success, .btn-warn, .btn-danger {
  flex: 1;
  padding: 8.5px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn-primary:hover, .btn-secondary:hover, .btn-success:hover, .btn-warn:hover, .btn-danger:hover {
  transform: translateY(-1px);
  opacity: 0.94;
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #38e8ff);
  color: #061424;
}

.btn-success {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #042818;
}

.btn-warn {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #2b1302;
}

.btn-danger {
  background: linear-gradient(135deg, #fb7185, #dc2626);
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fef3c7;
  border-color: var(--gold-soft);
}

.btn-locked {
  background: rgba(30, 41, 59, 0.85);
  color: #64748b;
  border: 1px solid rgba(100, 116, 139, 0.35);
  cursor: not-allowed;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  width: 100%;
}

/* Word List inside Group */
.word-pill-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 13px;
}

.word-row:hover {
  background: rgba(56, 232, 255, 0.16);
  border-color: rgba(56, 232, 255, 0.45);
}

.word-row.mastered {
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.08);
}

.cefr-tag {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  color: #091322;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Right Personalized Collectible Word Inspector Card */
.panel-right {
  position: fixed;
  top: 70px;
  right: 12px;
  width: 360px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  z-index: 18;
  padding: 16px;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--gold-soft);
  background: rgba(15, 23, 42, 0.8);
  color: #fef3c7;
  cursor: pointer;
  font-size: 13px;
  z-index: 5;
}

/* Personalized Per-Word Illustrated Banner */
.word-art-banner {
  position: relative;
  border-radius: 12px;
  border: 1.5px solid var(--gold-soft);
  overflow: hidden;
  min-height: 116px;
  margin-bottom: 12px;
}

.word-art-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.word-art-content {
  position: relative;
  z-index: 2;
  padding: 10px 14px 12px;
}

.word-art-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 26px;
}

.art-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
}

.art-cat {
  font-size: 11.5px;
  font-weight: 700;
  color: #fef3c7;
}

.art-stars {
  margin-left: auto;
  color: #fbbf24;
  font-size: 13px;
  letter-spacing: 1px;
}

.word-art-center {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.art-emoji {
  font-size: 40px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}

.art-word {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  line-height: 1.12;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

.art-id {
  font-size: 10px;
  letter-spacing: 1.2px;
  color: rgba(254, 243, 199, 0.72);
  margin-top: 3px;
}

.card-ipa-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-ipa {
  color: var(--cyan);
  font-size: 13.5px;
}

.speak-btn {
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid var(--cyan-soft);
  background: rgba(56, 232, 255, 0.14);
  color: #e0f2fe;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
}

.speak-btn:hover {
  background: rgba(56, 232, 255, 0.28);
}

.card-zh {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-left: 3px solid var(--gold);
  font-size: 14px;
  line-height: 1.6;
  color: #f8fafc;
}

.card-hint {
  margin-top: 9px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(56, 232, 255, 0.10);
  border: 1px solid rgba(56, 232, 255, 0.3);
  font-size: 12.5px;
  line-height: 1.55;
  color: #e0f2fe;
}

.card-meta-row {
  margin-top: 9px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
}

.meta-badge {
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

/* Bottom Center Game Overlay (Arena / Boss / Forge / Korok) */
.game-overlay {
  position: fixed;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  width: min(710px, calc(100vw - 340px));
  z-index: 22;
  padding: 16px 20px;
}

.boss-bars {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(251, 113, 133, 0.42);
}

.boss-hp-wrap {
  flex: 1;
}

.boss-hp-bar {
  height: 10px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  margin-top: 4px;
}

.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f97316);
  transition: width 0.3s ease;
}

.hearts-display {
  font-size: 18px;
  letter-spacing: 2px;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.quiz-prompt {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 5px;
  color: #fef9c3;
}

.quiz-sub {
  text-align: center;
  font-size: 12.5px;
  color: var(--cyan);
  margin-bottom: 12px;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quiz-opt-btn {
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--gold-soft);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.14s ease;
}

.quiz-opt-btn:hover {
  background: rgba(56, 232, 255, 0.2);
  border-color: var(--cyan);
}

.quiz-opt-btn.correct {
  background: rgba(16, 185, 129, 0.42);
  border-color: #34d399;
}

.quiz-opt-btn.wrong {
  background: rgba(239, 68, 68, 0.38);
  border-color: #fb7185;
}

/* Word Forge Tray */
.forge-slots {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(7, 15, 28, 0.72);
  border: 1.5px dashed var(--cyan-soft);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.forge-pool {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.forge-chip {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--cyan-soft);
  background: rgba(56, 232, 255, 0.16);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.forge-chip small {
  font-size: 10px;
  color: #cbd5e1;
  font-weight: 500;
}

.forge-chip.used {
  opacity: 0.28;
  pointer-events: none;
}

.forge-chip.placed {
  background: rgba(251, 191, 36, 0.24);
  border-color: #fbbf24;
}

/* Modal & Hyrule Compendium Grid */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(3, 8, 18, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  position: relative;
  width: min(880px, 95vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
}

.compendium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.relic-card {
  position: relative;
  border-radius: 12px;
  padding: 13px;
  background: linear-gradient(160deg, rgba(20, 36, 58, 0.9), rgba(10, 19, 34, 0.95));
  border: 1.5px solid var(--gold-soft);
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.relic-card:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
}

.relic-card.locked {
  background: linear-gradient(160deg, rgba(15, 23, 38, 0.85), rgba(8, 12, 22, 0.95));
  border-color: rgba(100, 116, 139, 0.35);
}

.relic-card.equipped {
  border-color: #38e8ff;
  box-shadow: 0 0 18px rgba(56, 232, 255, 0.28);
}

.relic-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.relic-icon-box {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.relic-card.locked .relic-icon-box {
  filter: grayscale(1) brightness(0.45);
}

.relic-name {
  font-weight: 800;
  font-size: 14.5px;
  color: #fef3c7;
}

.relic-card.locked .relic-name {
  color: #94a3b8;
}

.relic-en {
  font-size: 11px;
  color: var(--text-muted);
}

.relic-desc {
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
  min-height: 36px;
}

.relic-req {
  font-size: 11.5px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.relic-card.locked .relic-req {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Unlock Ceremony Banner */
.unlock-ceremony {
  text-align: center;
  padding: 12px 6px;
}

.unlock-ceremony .big-icon {
  font-size: 68px;
  filter: drop-shadow(0 0 24px rgba(251, 191, 36, 0.85));
  animation: pulseGlow 1.6s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.cefr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.cefr-stat-box {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(229, 185, 99, 0.22);
}

.col-item {
  padding: 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(229, 185, 99, 0.2);
  margin-bottom: 10px;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 122px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  padding: 8px 18px;
  border-radius: 99px;
  background: linear-gradient(135deg, #34d399, #38e8ff);
  color: #041e26;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  animation: fadeUp 0.25s ease;
}

.toast.warn {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: #2b1302;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.controls-hint {
  position: fixed;
  bottom: 9px;
  left: 12px;
  z-index: 12;
  padding: 5px 13px;
  border-radius: 99px;
  background: rgba(9, 18, 32, 0.78);
  border: 1px solid var(--gold-soft);
  font-size: 11.5px;
  color: #e2e8f0;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-thumb {
  background: rgba(229, 185, 99, 0.35);
  border-radius: 99px;
}

/* Shared HUD geometry and input feedback */
:root {
  --hud-end: 72px;
  --floor: max(12px, env(safe-area-inset-bottom));
  --left: max(12px, env(safe-area-inset-left));
  --right: max(12px, env(safe-area-inset-right));
}
button { font-family: inherit; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
button:active:not(:disabled), .word-row:active, .group-card:active { filter: brightness(1.25); }
.hud-brand { border: 0; background: none; text-align: left; }
.hud-brand, .nav-btn, .cefr-tag, .chip, .speak-btn { flex-shrink: 0; }
#canvas-container canvas { display: block; touch-action: none; cursor: grab; }
#canvas-container canvas:active { cursor: grabbing; }
.compact, #touch-controls { display: none; }
.panel-left, .panel-right, .next-relic-pill { top: var(--hud-end); }
.panel-left.collapsed { transform: translateX(calc(-100% + 46px)); }
.panel-left.collapsed .panel-body, .panel-left.collapsed .panel-title { visibility: hidden; }
.panel-header { flex-shrink: 0; gap: 6px; }
.collapse-btn { flex: none; }
.panel-body > * { flex-shrink: 0; }
.panel-body, #modal-content, #word-card-content, .game-overlay, .search-dropdown {
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
}
.modal-card, .panel-right { display: flex; overflow: hidden; padding: 0; }
#modal-content, #word-card-content { width: 100%; overflow-y: auto; padding: 22px; }
#word-card-content { padding: 16px; }
#modal-content h2 { padding-right: 36px; }
.panel-right { max-height: calc(100% - var(--hud-end) - 45px); }
.quiz-options { grid-template-columns: repeat(2,minmax(0,1fr)); }
.quiz-header { gap: 8px; }
.quiz-header span:nth-child(2) { flex-shrink: 0; }
.game-overlay {
  max-height: calc(100% - var(--hud-end) - 55px);
  overflow-y: auto;
  width: min(710px, 94vw);
}
.toast-container { top: calc(var(--hud-end) + 48px); width: max-content; max-width: 92vw; text-align: center; }
.search-dropdown { max-height: min(410px, 60dvh); }
.search-item > div { min-width: 0; }
body:has(.game-overlay:not(.hidden)) :is(.panel-left, .next-relic-pill, .controls-hint, #btn-guide, #touch-hint, #touch-controls, .stamina-hud) { display: none; }
body:has(.game-overlay:not(.hidden)) .search-box,
body:has(.game-overlay:not(.hidden)) #canvas-container ~ #touch-controls { display: none; }
body:has(.game-overlay:not(.hidden)) .game-overlay { bottom: var(--floor); }
@media (max-width: 1540px) {
  .hud-nav { order: 3; width: 100%; justify-content: center; }
  .hud-top { padding: 6px 12px; gap: 5px; }
  .nav-btn { padding: 6px 9px; }
}
@media (max-width: 1100px) {
  .panel-left { width: 280px; }
  .panel-right { width: 310px; }
  .nav-btn { font-size: 12px; padding-inline: 7px; }
}
@media (max-width: 960px), (max-height: 540px), (pointer: coarse) {
  .compact { display: flex; }
  .hud-top {
    top: max(8px,env(safe-area-inset-top)); left: var(--left); right: var(--right);
    padding: 5px 7px; gap: 3px; flex-wrap: nowrap;
  }
  .hud-brand { gap: 5px; flex: 1; min-width: 0; }
  .hud-brand > div { min-width: 0; }
  .brand-icon { font-size: 22px; }
  .brand-title { font-size: 15px; }
  .brand-sub { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hud-right { gap: 4px; flex-wrap: nowrap; }
  .icon-btn { width: 40px; height: 42px; font-size: 16px; border-radius: 11px; }
  #btn-menu { font-size: 21px; }
  .icon-btn[aria-expanded=true] { background: #184962; border-color: var(--cyan); }
  .hud-right .stat-pill, .controls-hint, .hud-nav, .search-box, #scrim, .panel-left { display: none; }
  body[data-sheet]:not([data-sheet=""]) #scrim { display: block; position: fixed; inset: 0; z-index: 23; background: #04132659; }
  body[data-sheet=menu] .hud-nav, body[data-sheet=search] .search-box {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: min(440px,100%); border-radius: 15px; border: 1px solid var(--gold-soft);
    background: #0d2035fa; padding: 10px; box-shadow: 0 12px 32px #00132255;
    max-height: calc(100dvh - var(--hud-end) - var(--floor)); overflow-y: auto;
  }
  body[data-sheet=menu] .hud-nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .nav-btn { padding: 8px; min-height: 46px; font-size: 14px; }
  .nav-compendium { grid-column: span 2; }
  body[data-sheet=search] .search-box { display: flex; flex-direction: column; }
  .search-dropdown { position: static; width: 100%; border: 0; box-shadow: none; margin-top: 6px; max-height: 52dvh; }
  #global-search, .filter-input { width: 100%; font-size: 16px; padding: 11px; min-height: 44px; }
  .search-zh { max-width: 100%; }
  .search-item { min-height: 56px; }
  .next-relic-pill { max-width: calc(100% - 24px); padding: 8px 13px; min-height: 44px; color: white; }
  .next-relic-info { min-width: 0; }
  .next-relic-title { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
  #btn-guide {
    position: fixed; z-index: 17; bottom: calc(var(--floor) + 12px); left: 50%; transform: translateX(-50%);
    color: #fff2c6; border-color: var(--gold); font-weight: 700; font-size: 14px;
    align-items: center; justify-content: center; height: 48px; padding: 0 15px; gap: 6px;
  }
  #btn-guide::before { content: '⌃'; color: var(--cyan); font-size: 18px; transform: translateY(3px); }
  #touch-hint {
    position: fixed; left: 50%; bottom: calc(var(--floor) + 142px); transform: translateX(-50%); z-index: 12;
    white-space: nowrap; pointer-events: none; color: #fff; font-size: 12px; letter-spacing: .4px;
    background: #081d32c9; border-radius: 20px; padding: 7px 13px;
  }
  #canvas-container:not([data-mode=archipelago]) ~ #touch-hint { display: none; }
  #canvas-container:is([data-mode=archipelago],[data-mode=island]) ~ #touch-controls { display: block; }
  #touch-controls > * {
    position: fixed; z-index: 16; touch-action: none; -webkit-touch-callout: none;
    background: #0a213ac9; color: #fff6d8; border: 1.5px solid #ffe6aa; border-radius: 50%;
    box-shadow: 0 4px 16px #0d243747, inset 0 0 0 4px #0d203599, inset 0 0 0 5px #f5dd9f55;
    font-size: 14px; font-weight: 700; -webkit-tap-highlight-color: transparent;
  }
  #stick {
    width: clamp(90px,27vw,116px); aspect-ratio: 1; bottom: calc(var(--floor) + 15px);
    left: calc(var(--left) + 4px); display: grid; place-items: center; background: #09203885;
  }
  #stick span { width: 43%; aspect-ratio: 1; border-radius: 50%; border: 2px solid #fff8cf; background: radial-gradient(circle at 40% 30%, #528093, #17364c 70%); box-shadow: 0 3px 12px #00142488; }
  #jump { bottom: calc(var(--floor) + 72px); right: var(--right); width: 55px; height: 55px; }
  #interact { bottom: calc(var(--floor) + 6px); right: calc(var(--right) + 25px); width: 64px; height: 64px; background: #104059ef; border-color: #87f5ff; }
  .stamina-hud { bottom: calc(var(--floor) + 78px); right: calc(50% - 22px); }
  body[data-sheet=guide] .panel-left { display: flex; transform: none; }
  body[data-sheet=guide] .panel-body, body[data-sheet=guide] .panel-title { visibility: visible; }
  .panel-left, .panel-right, .game-overlay {
    left: var(--left); right: var(--right); top: auto; bottom: var(--floor); transform: none;
    z-index: 24; width: auto; max-height: min(74dvh,calc(100% - var(--hud-end) - var(--floor)));
    border-radius: 20px; background: linear-gradient(145deg,#10293ff7,#071424fa);
  }
  .panel-left { height: 70dvh; }
  .panel-header { padding: 7px 12px 7px 16px; }
  .panel-body { padding: 12px; }
  .panel-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .collapse-btn, .close-btn { width: 42px; height: 42px; border-radius: 12px; }
  .collapse-btn { font-size: 0; }
  .collapse-btn::after { content: '✕'; font-size: 15px; }
  .chip, .speak-btn { min-height: 40px; }
  .word-row, .action-row button, .panel-body > button, .forge-chip { min-height: 44px; }
  .word-row { gap: 6px; font-size: 14px; }
  .group-card { padding: 12px; }
  .group-card-meta { font-size: 12px; line-height: 1.5; }
  .action-row button { padding: 9px 6px; }
  .art-word { font-size: clamp(21px,6vw,26px); }
  .art-stars { white-space: nowrap; }
  .word-art-top-row { padding-right: 34px; }
  .modal-backdrop { padding: max(10px,env(safe-area-inset-top)) var(--right) var(--floor) var(--left); }
  .modal-card { max-height: 100%; }
  #modal-content, #word-card-content { padding: 14px; }
  #modal-content h2 { font-size: 19px; padding-right: 44px; min-height: 38px; }
  .cefr-grid { grid-template-columns: repeat(auto-fit,minmax(135px,1fr)); gap: 7px; }
  .cefr-stat-box { padding: 8px; }
  .cefr-stat-box > div { gap: 4px; }
  .game-overlay { z-index: 22; padding: 12px; max-height: calc(100% - var(--hud-end) - var(--floor)); }
  .quiz-opt-btn { padding: 10px; min-height: 56px; }
  .quiz-opt-btn strong { display: none; }
  .quiz-prompt { font-size: 19px; }
  .quiz-header { font-size: 12px; }
  .boss-bars { gap: 8px; padding: 6px; }
  .boss-hp-wrap > div { flex-wrap: wrap; }
  .hearts-display { font-size: 13px; letter-spacing: 0; }
  .forge-chip { padding: 7px 10px; }
  .toast-container { top: var(--hud-end); }
  .toast { border-radius: 14px; }
  body:has(.game-overlay:not(.hidden)) #btn-search { display: none; }
}
@media (max-width: 380px) {
  .brand-icon { display: none; }
  .icon-btn { width: 36px; }
  .hud-right { gap: 2px; }
  #btn-guide { font-size: 13px; padding-inline: 10px; }
  #interact { right: var(--right); }
  .quiz-header span:nth-child(2) { flex-shrink: 1; }
  .action-row button { font-size: 12px; }
}
@media (max-height: 540px), (min-width: 700px) and (orientation: landscape) and (pointer: coarse) {
  .panel-left, .panel-right { width: min(410px, 55vw); height: auto; max-height: calc(100% - var(--hud-end) - var(--floor)); top: var(--hud-end); }
  .panel-right { left: auto; }
  .next-relic-pill, #touch-hint { display: none; }
  #stick { width: 92px; }
  .game-overlay { width: min(52vw,540px); left: auto; }
  .quiz-opt-btn { padding: 7px; min-height: 44px; }
  .quiz-sub, .quiz-header, .boss-bars { margin-bottom: 5px; }
}
@media (max-height: 710px) {
  #touch-hint { display: none; }
}
@media (max-width: 540px) {
  .brand-sub { font-size: 10.5px; }
  .brand-icon { display: none; }
  .next-relic-title { font-size: 11.5px; }
  .panel-left, .panel-right, .game-overlay { width: auto; left: var(--left); right: var(--right); top: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
