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

html, body {
  height: 100%;
  background: #14141c;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  /* Cascade, in order of trust: 100vh (oldest fallback) → 100dvh (correct in
     theory, but not fully reliable inside an installed PWA's standalone mode
     across all Android/Chrome versions) → --app-height, a JS-measured value
     from visualViewport (js/app.js), which wins whenever JS has actually run.
     This is what stops the shell from ever being sized taller than the real
     visible screen, which is what was pushing #bottom-nav out of view. */
  max-width: 480px;
  margin: 0 auto;
  background: #1b1b26;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}

#app.has-ad-bar {
  padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px));
}

/* ---- Top bar ---- */
#top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #262635;
  border-bottom: 2px solid #3a3a4d;
}

#top-sprite,
#top-pet-icon {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  border-radius: 6px;
  background: #333;
}

#top-info { flex: 1; min-width: 0; }

#top-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#top-levels {
  font-size: 12px;
  color: #a9a9c2;
}

#combined-level { font-weight: 700; color: #f2d675; }

#top-stats {
  display: flex;
  flex-direction: row;
  align-items: center;
  font-size: 15px;
  gap: 10px;
  white-space: nowrap;
}

/* ---- Center panel ---- */
#center-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}

#center-panel h2 {
  margin-bottom: 12px;
}

.loading {
  text-align: center;
  color: #888;
  padding: 40px 0;
}

/* ---- Bottom nav ---- */
#bottom-nav {
  flex: 0 0 auto;
  display: flex;
  background: #262635;
  border-top: 2px solid #3a3a4d;
}

#bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  color: #ccc;
  font-size: 20px;
  padding: 4px 0;
  cursor: pointer;
}

#bottom-nav button img {
  width: 44px;
  height: 44px;
}

#bottom-nav button.active {
  color: #f2d675;
  background: #303044;
}

/* ---- Shared activity/panel building blocks ---- */
.card {
  background: #24243380;
  border: 1px solid #3a3a4d;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.card.locked { opacity: 0.45; }

.btn {
  display: inline-block;
  background: #4a4a6a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}

.btn-gray { background: #4a4a6a; color: #fff; }

.btn-orange { background: #f2a93c; color: #1b1b26; font-weight: 700; }

.btn-blue { background: #4a90c4; color: #fff; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.reward-table {
  border-collapse: collapse;
  margin: 8px auto 0;
}
.reward-table th, .reward-table td {
  border: 1px solid #3a3a4d;
  padding: 6px 10px;
}
.reward-table th { text-align: left; }
.reward-table th:last-child, .reward-table td:last-child { text-align: right; }

.exp-bar-outer {
  position: relative;
  background: #333;
  border-radius: 999px;
  height: 18px;
  overflow: hidden;
  margin-top: 6px;
}
.exp-bar-inner {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #f2a93c, #f2d675);
}

.exp-bar-gain {
  background: #4a90c4;
}
.exp-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  white-space: nowrap;
}

.skill-block .exp-bar-outer { height: 14px; }
.skill-block .exp-bar-label { font-size: 9px; }

.skill-list {
  display: grid;
  grid-template-columns: 28px 100px 1fr auto;
  align-items: center;
  gap: 8px 10px;
}

.skill-block {
  display: contents; /* each "block" just places its children into the grid's columns/rows */
}

.skill-icon { width: 28px; height: 28px; }
.skill-name { font-size: 13px; font-weight: 600; text-align: left; }
.skill-level { font-size: 12px; font-weight: 700; color: #f2d675; text-align: right; white-space: nowrap; }

details.card summary { cursor: pointer; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  transition: transform 0.15s;
}
details[open].card>summary::before {
  transform: rotate(90deg);
}
.nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}
.nav-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 90px;
  padding: 14px 8px;
  background: #24243380;
  border: 1px solid #3a3a4d;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
}
.nav-tile:active { background: #303044; }
.nav-tile-icon { width: 32px; height: 32px; }


.sprite-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sprite-option {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  border: 2px solid #3a3a4d;
  border-radius: 8px;
  cursor: pointer;
  background: #14141c;
}
.sprite-option.sprite-locked {
  opacity: 0.3;
  cursor: not-allowed;
  filter: grayscale(1);
}
.sprite-option.sprite-selected {
  border-color: #f2a93c;
}


.skill-tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.skill-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 120px;
  padding: 12px 8px;
  background: #4a4a6a;
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
}
.skill-tile span {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.skill-tile img { width: 32px; height: 32px; }


.spin-viewport {
  overflow: hidden;
  border: 2px solid #3a3a4d;
  border-radius: 8px;
  position: relative;
}
.spin-viewport::after {
  content: '';
  position: absolute;
  inset: 0;
  border-top: 2px solid #f2a93c;
  border-bottom: 2px solid #f2a93c;
  pointer-events: none;
}
.spin-reel {
  display: flex;
  flex-direction: column;
}
.spin-row {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 10px;
  box-sizing: border-box;
  border-bottom: 1px solid #2a2a3a;
}
.spin-row img { width: 36px; height: 36px; image-rendering: pixelated; }

.paperdoll {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 10px auto 0;
  aspect-ratio: 160 / 214;
}
.paperdoll-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.paperdoll-slot {
  position: absolute;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  background: rgba(20,20,28,0.5);
  border: 2px solid #3a3a4d;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  padding: 0;
}
.paperdoll-slot img { width: 32px; height: 32px; image-rendering: pixelated; }

.item-row img, .paperdoll-slot img, .reward-table img {
  transform: translateZ(0);
}
.item-row-locked {
  opacity: 0.3;
  filter: grayscale(1);
}

.stat-req-table {
  font-size: 11px;
  border-collapse: collapse;
  margin-top: 4px;
}
.stat-req-table td { padding: 1px 6px 1px 0; }
.stat-met { color: #7fd67f; }
.stat-unmet { color: #e57373; }
.stat-req-table th {
  color: #fff;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  padding: 1px 6px 1px 0;
}

.card p {
  margin: 8px 0;
}

.screen-intro {
  color: #999;
  font-size: 13px;
  margin: 4px 0 14px;
}

.leaderboard-me-row td {
  color: #f2d675;
  font-weight: 700;
}
#leaderboard-tabs {
  margin-bottom: 14px;
}

.elemental-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #1b1b26;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #1b1b26;
  border: 1px solid #3a3a4d;
  border-radius: 10px;
  padding: 16px;
  max-width: 340px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #2a2a3a;
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }

details.card > summary + .card {
  margin-top: 10px;
}

.process-info-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.process-info-table th, .process-info-table td {
  border: 1px solid #3a3a4d;
  padding: 8px;
  text-align: center;
}
.process-info-table img { width: 28px; height: 28px; image-rendering: pixelated; }

.process-quantity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.process-quantity-row input[type="range"] { flex: 1; }
.process-quantity-row input[type="number"] { width: 60px; padding: 6px; }

.conversion-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 10px 0;
}
.conversion-visual img { width: 40px; height: 40px; image-rendering: pixelated; }
.conversion-visual .conversion-count { text-align: center; font-size: 13px; color: #999; margin-top: 4px; }
.conversion-arrow { font-size: 20px; color: #f2a93c; }

.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.item-row-hidden {
  display: none !important;
}
.section-hidden { display: none; }

.qty-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 8px;
}

.qty-stepper input[type="number"] {
  width: 60px;
  padding: 8px 5px;
  text-align: center;
  font-size: 14px;
}

.qty-stepper-wide input[type="number"] {
  width: 85px;
}

.qty-stepper input[type="number"]::-webkit-inner-spin-button,
.qty-stepper input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-stepper input[type="number"] {
  -moz-appearance: textfield;
}

.qty-step-btn {
  width: 37px;
  height: 37px;
  font-size: 19px;
  font-weight: 700;
  padding: 0;
  line-height: 1;
}
.btn-small {
  padding: 7px 12px;
  font-size: 12px;
}

#stopwatch-mute-toggle {
  font-size: 18px;
  padding: 0;
}

.nav-dot {
  position: absolute;
  top: 2px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: #e54545;
  border-radius: 50%;
  border: 1px solid #1b1b26;
  z-index: 2;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #4a4a6a;
  border-radius: 999px;
  transition: background 0.15s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.toggle-switch input:checked+.toggle-slider {
  background: #f2a93c;
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(20px);
}

.filter-checkbox {
  width: 22px;
  height: 22px;
  cursor: pointer;
}

.inline-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #6fcf5f;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.nav-dot-green {
  background: #6fcf5f;
}

.world-map-viewport {
  width: 100%;
  height: 420px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  border: 2px solid #3a3a4d;
  border-radius: 8px;
  position: relative;
}

.world-map-image {
  display: block;
  width: 1024px;
  height: 1024px;
  image-rendering: pixelated;
}

.zone-oval {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
}

.zone-oval.zone-locked {
  background: rgba(0, 0, 0, 0.55);
  cursor: not-allowed;
}

#battle-log {
  max-height: 320px;
  overflow-y: auto;
}

#battle-log {
  display: flex;
  flex-direction: column;
}

.battle-line {
  padding: 6px 10px;
  margin: 2px 0;
  border-radius: 10px;
  max-width: 80%;
}

.battle-line-mine {
  align-self: flex-start;
  background: #24243380;
}

.battle-line-theirs {
  align-self: flex-end;
  background: #2a2a3a;
  text-align: right;
}

.hp-bar-outer {
  position: relative;
  background: #1a1a1a;
  border: 2px solid #000;
  border-radius: 999px;
  height: 16px;
  overflow: hidden;
  margin-top: 6px;
}

.hp-bar-inner {
  background: linear-gradient(90deg, #b33a3a, #e54545);
  height: 100%;
  transition: width 0.3s ease;
}

.quest-row-hidden {
  display: none !important;
}

.bestiary-entry-hidden {
  display: none !important;
}

.paperdoll-slot-equipped {
  background: #14141c;
}

details[data-collapse-key^="quest-tier-"] summary {
  margin-bottom: 10px;
}

.chronicle-nav-btn {
  height: 44px;
  width: 44px;
  font-size: 18px;
  padding: 0;
}

.chronicle-picker {
  height: 44px;
  font-size: 16px;
  padding: 0 10px;
  border-radius: 6px;
}

.achievement-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a3a;
  border: 2px solid #f2d675;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  text-align: center;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: toast-fade 4s ease forwards;
  max-width: min(340px, 90vw);
  box-sizing: border-box;
  word-wrap: break-word;
}

@keyframes toast-fade {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }

  10% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  85% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

#ad-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  height: 50px;
  max-height: 50px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #14141c;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 50;
  box-sizing: content-box;
}

#ad-bar ins.adsbygoogle,
#ad-bar iframe {
  max-height: 50px !important;
  max-width: 320px !important;
}