:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(13, 18, 34, 0.92);
  --panel-solid: #121a2f;
  --text: #f3ead0;
  --muted: #b7ad92;
  --accent: #7ddea0;
  --accent-2: #f0c75e;
  --danger: #ff7b72;
  --border: rgba(240, 199, 94, 0.28);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-h: 64px;
  --filters-h: 52px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: calc(8px + var(--safe-top)) 12px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(180deg, rgba(8, 12, 24, 0.94), rgba(8, 12, 24, 0.72));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(240, 199, 94, 0.12);
  color: var(--text);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.filters {
  position: absolute;
  top: calc(var(--topbar-h) + var(--safe-top));
  left: 0;
  right: 0;
  z-index: 999;
  min-height: var(--filters-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(8, 12, 24, 0.78);
  border-bottom: 1px solid rgba(240, 199, 94, 0.15);
  flex-wrap: wrap;
}

.filter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid rgba(243, 234, 208, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
}

.chip.active {
  background: rgba(240, 199, 94, 0.22);
  border-color: var(--accent-2);
  color: #ffe7a1;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

#map {
  position: absolute;
  inset: 0;
  background: #071018;
  z-index: 1;
  touch-action: none;
}

.leaflet-container {
  background: #071018;
  font: inherit;
  outline: none;
}

.korok-marker {
  background: transparent !important;
  border: 0 !important;
}

.korok-icon {
  display: block;
  width: 28px;
  height: 28px;
  background: url("../assets/korok.png") center / contain no-repeat;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.85));
  transition: transform 0.12s ease;
}

.korok-icon.collected {
  filter: grayscale(1) brightness(0.55) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
  opacity: 0.75;
}

.korok-icon.selected {
  transform: scale(1.25);
  filter: drop-shadow(0 0 6px rgba(240, 199, 94, 0.9));
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  max-height: min(72dvh, 640px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 8px 16px calc(16px + var(--safe-bottom));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet[hidden] {
  display: none !important;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: rgba(243, 234, 208, 0.28);
  margin: 4px auto 10px;
}

.sheet-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.sheet h2 {
  margin: 0 28px 6px 0;
  font-size: 20px;
  color: var(--accent-2);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 12px 0;
}

.meta-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(243, 234, 208, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
}

.meta-item .label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.meta-item .value {
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.hint {
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(125, 222, 160, 0.08);
  border: 1px solid rgba(125, 222, 160, 0.28);
  line-height: 1.55;
  font-size: 14px;
}

.note {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(240, 199, 94, 0.1);
  border: 1px solid rgba(240, 199, 94, 0.3);
  font-size: 13px;
  line-height: 1.5;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.sheet-actions .btn.primary {
  background: linear-gradient(180deg, #8be0a8, #4fbf82);
  border-color: transparent;
  color: #062014;
}

.sheet-actions .btn.danger {
  background: rgba(255, 123, 114, 0.16);
  border-color: rgba(255, 123, 114, 0.45);
  color: #ffd2cf;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(243, 234, 208, 0.14);
}

.badge.on {
  background: rgba(125, 222, 160, 0.18);
  border-color: rgba(125, 222, 160, 0.45);
  color: #baf5d2;
}

.badge.off {
  color: var(--muted);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 2000;
  background: rgba(10, 14, 28, 0.94);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
}

.toast[hidden] {
  display: none !important;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  background: rgba(7, 12, 24, 0.72);
  color: var(--text);
  font-size: 14px;
}

@media (min-width: 900px) {
  .sheet {
    left: auto;
    right: 16px;
    bottom: 16px;
    width: min(420px, calc(100% - 32px));
    border-radius: 18px;
    max-height: min(70dvh, 720px);
    border-bottom: 1px solid var(--border);
  }

  .brand h1 {
    font-size: 18px;
  }

  .armor-panel {
    top: calc(var(--topbar-h) + var(--safe-top));
  }
}

/* Mode switch */
.mode-switch {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  flex-shrink: 0;
}

.mode-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
}

.mode-btn.is-active {
  background: rgba(240, 199, 94, 0.22);
  color: #ffe7a1;
}

.topbar {
  flex-wrap: wrap;
}

.filters[hidden] {
  display: none !important;
}

/* Armor mode */
.armor-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--topbar-h) + var(--safe-top));
  bottom: 0;
  z-index: 950;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(13, 18, 34, 0.98), rgba(8, 12, 24, 0.98));
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.armor-panel[hidden] {
  display: none !important;
}

body.mode-armor #map {
  visibility: hidden;
}

.armor-toolbar {
  padding: 10px 12px 6px;
  flex: 0 0 auto;
}

.armor-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  min-height: 44px;
  outline: none;
}

.armor-search::placeholder {
  color: var(--muted);
}

.armor-list {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 10px 16px;
}

.armor-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  appearance: none;
  border: none;
  border-bottom: 1px solid rgba(243, 234, 208, 0.12);
  background: transparent;
  color: var(--text);
  padding: 14px 10px;
  min-height: 56px;
}

.armor-item:active {
  background: rgba(240, 199, 94, 0.08);
}

.armor-item-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-2);
}

.armor-item-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.armor-empty {
  margin: 24px 12px;
  color: var(--muted);
  text-align: center;
}

.armor-desc {
  margin: 0 0 12px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
}

.armor-pieces h3,
.armor-upgrade-block h3 {
  margin: 14px 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.armor-piece {
  padding: 12px 0;
  border-top: 1px solid rgba(243, 234, 208, 0.12);
}

.armor-piece header {
  margin-bottom: 6px;
}

.armor-def,
.armor-effect {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.armor-piece p {
  margin: 0 0 8px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.owned-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 12px 8px 0;
  font-size: 0.95rem;
  color: var(--accent);
  min-height: 40px;
  user-select: none;
}

.owned-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.locate-btn {
  margin: 4px 0 0;
  border-radius: 10px !important;
}

.armor-upgrades {
  margin: 0;
  padding-left: 1.1em;
  font-size: 0.9rem;
  line-height: 1.5;
}

.armor-upgrades li {
  margin-bottom: 6px;
}

.armor-note {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.armor-back-map {
  position: absolute;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 1100;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 44px;
  font-weight: 700;
  color: #062014;
  background: linear-gradient(180deg, #8be0a8, #4fbf82);
  box-shadow: var(--shadow);
}

.armor-back-map[hidden] {
  display: none !important;
}

.armor-pin {
  background: transparent !important;
  border: none !important;
}

.armor-pin-dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f0c75e;
  border: 2px solid #0b1020;
  box-shadow: 0 0 0 3px rgba(240, 199, 94, 0.35);
}

body.hide-koroks .leaflet-pane.leaflet-koroks-pane,
body.hide-koroks .korok-marker,
body.hide-koroks .korok-icon {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* --- Shrine icon (teal diamond) --- */
.shrine-marker {
  background: transparent !important;
  border: 0 !important;
}

.shrine-icon {
  display: block;
  width: 14px;
  height: 14px;
  background: #5ec4a0;
  border: 2px solid #0b1020;
  box-shadow: 0 0 0 2px rgba(94, 196, 160, 0.35);
  transform: rotate(45deg);
  border-radius: 2px;
}

/* --- Tower icon (blue square) --- */
.tower-marker {
  background: transparent !important;
  border: 0 !important;
}

.tower-icon {
  display: block;
  width: 16px;
  height: 16px;
  background: #6db4f0;
  border: 2px solid #0b1020;
  box-shadow: 0 0 0 2px rgba(109, 180, 240, 0.35);
  border-radius: 3px;
}


/* ===== Guide Panel ===== */
.guide-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--topbar-h) + var(--safe-top));
  bottom: 0;
  z-index: 950;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(13,18,34,0.98), rgba(8,12,24,0.98));
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.guide-panel[hidden] { display: none !important; }

body.mode-guide #map { visibility: hidden; }

.guide-toolbar {
  flex: 0 0 auto;
  padding: 10px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.28);
  align-self: flex-start;
}

.guide-tab {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 32px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.guide-tab.is-active {
  background: rgba(125,222,160,0.22);
  color: #b5f5d2;
}

.guide-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,0.35);
  color: var(--text);
  font-size: 1rem;
  padding: 10px 14px;
  min-height: 40px;
  outline: none;
}

.guide-search::placeholder { color: var(--muted); }

.guide-list {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 10px 24px;
}

.guide-empty {
  margin: 24px 12px;
  color: var(--muted);
  text-align: center;
}

/* Region group header (shrine guide) */
.guide-region-group { margin-bottom: 8px; }

.guide-region-header {
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(240,199,94,0.2);
  margin-bottom: 2px;
}

/* Card */
.guide-card {
  border-bottom: 1px solid rgba(243,234,208,0.1);
}

.guide-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 12px 8px;
  min-height: 52px;
  cursor: pointer;
}

.guide-card-header:active { background: rgba(255,255,255,0.04); }

.guide-order {
  flex: 0 0 28px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.shrine-cat-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.guide-card-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-card-title strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-card-title small {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-dlc {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(180,150,240,0.2);
  border: 1px solid rgba(180,150,240,0.4);
  color: #c4a0f5;
  vertical-align: middle;
}

.guide-diff {
  flex: 0 0 auto;
  font-size: 0.65rem;
  letter-spacing: -1px;
  color: var(--accent-2);
}

.guide-chevron {
  flex: 0 0 20px;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}

/* Card body */
.guide-card-body {
  padding: 0 10px 14px 36px;
}

.guide-card-body[hidden] { display: none !important; }

.shrine-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.shrine-cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  font-size: 0.75rem;
  font-weight: 700;
}

.shrine-region-label {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(243,234,208,0.15);
  background: rgba(255,255,255,0.04);
  font-size: 0.75rem;
  color: var(--muted);
}

.guide-summary {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.guide-how-to-find {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(109,180,240,0.08);
  border: 1px solid rgba(109,180,240,0.2);
  font-size: 0.85rem;
  color: #a8d6f5;
  line-height: 1.5;
}

/* Steps */
.guide-steps {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-step {
  display: flex;
  gap: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.step-num {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(125,222,160,0.15);
  border: 1px solid rgba(125,222,160,0.3);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

/* Tips */
.guide-tips {
  margin: 0 0 8px;
  padding: 8px 10px 8px 12px;
  border-radius: 10px;
  background: rgba(240,199,94,0.06);
  border: 1px solid rgba(240,199,94,0.2);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-tip {
  font-size: 0.83rem;
  color: #e8d48a;
  line-height: 1.5;
}

.guide-tip::before { content: "💡 "; }

/* Rewards / Chests */
.guide-rewards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.guide-reward-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(240,199,94,0.3);
  background: rgba(240,199,94,0.08);
  font-size: 0.78rem;
  color: #f0c75e;
}

.guide-locate-btn {
  margin-top: 4px;
  border-radius: 10px !important;
  font-size: 0.85rem;
}

/* Pin for shrine locate */
.shrine-locate-pin {
  background: transparent !important;
  border: none !important;
}

.shrine-locate-dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #7ddea0;
  border: 2px solid #0b1020;
  box-shadow: 0 0 0 3px rgba(125,222,160,0.4);
}

@media (min-width: 900px) {
  .guide-panel {
    top: calc(var(--topbar-h) + var(--safe-top));
  }
}
