* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: #0c0f14; color: #e6e6e6; font-family: -apple-system, Segoe UI, sans-serif; overflow: hidden; }

/* Used by how-to-play.html/documentation.html, which are normal scrolling
   content pages rather than the fixed-viewport login/game screens.
   Overriding just <body> isn't enough — <html> also has overflow:hidden
   above, and that's the element that actually clips page scrolling. */
html.docs-page, body.docs-page { height: auto; overflow: auto; }

#site-header {
  position: fixed; top: 0; left: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; padding: 10px 20px;
}
#site-header .brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; }
#site-header .brand-logo { width: 34px; height: 34px; border-radius: 50%; display: block; }
#site-header .brand-name { font-weight: 700; letter-spacing: 0.05em; font-size: 1.05rem; text-shadow: 0 1px 6px rgba(0,0,0,0.7); }
#site-nav { display: flex; gap: 10px; }
#site-nav a {
  color: #cfd3d8; text-decoration: none; font-size: 0.85rem; padding: 6px 12px; border-radius: 6px;
  border: 1px solid transparent; text-shadow: 0 1px 6px rgba(0,0,0,0.7);
  white-space: nowrap;
}
#site-nav a:hover { color: #3ddc97; border-color: #2a3340; background: rgba(12, 15, 20, 0.7); }
#site-nav a.active { color: #3ddc97; border-color: #2a3340; background: rgba(12, 15, 20, 0.7); }
body.in-game #site-nav { display: none; }

#nav-toggle {
  display: none;
  background: none; border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
  color: #e6e6e6; font-size: 1.25rem; cursor: pointer;
  padding: 5px 10px; line-height: 1; flex-shrink: 0;
}
body.in-game #nav-toggle { display: none !important; }

/* ---- Content pages (how-to-play.html, documentation.html) ---- */
.docs-page main { max-width: 880px; margin: 0 auto; padding: 90px 24px 60px; }
.docs-page h1.page-title { font-size: 2.1rem; margin-bottom: 0.25rem; letter-spacing: 0.03em; }
.docs-page p.page-subtitle { opacity: 0.75; margin-bottom: 2.5rem; font-size: 1.05rem; }
.docs-page section { margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid #1c2430; }
.docs-page section:last-child { border-bottom: none; }
.docs-page h2 { font-size: 1.35rem; color: #3ddc97; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 10px; }
.docs-page h3 { font-size: 1.05rem; color: #e2a64a; margin: 1.25rem 0 0.5rem; }
.docs-page .section-icon {
  width: 26px; height: 26px; flex-shrink: 0; image-rendering: pixelated; font-size: 1.3rem; line-height: 1;
}
.docs-page p { line-height: 1.6; opacity: 0.92; margin: 0.5rem 0; }
.docs-page ul, .docs-page ol { line-height: 1.7; opacity: 0.92; padding-left: 1.4rem; }
.docs-page li { margin-bottom: 0.35rem; }
.docs-page code { background: #11151c; border: 1px solid #2a3340; border-radius: 4px; padding: 0.1rem 0.4rem; font-size: 0.9em; color: #6fb6e8; }
.docs-page .callout {
  background: rgba(61, 220, 151, 0.08); border: 1px solid rgba(61, 220, 151, 0.3); border-radius: 8px;
  padding: 0.9rem 1.1rem; margin: 1rem 0; font-size: 0.92rem;
}
.docs-page .callout.warn { background: rgba(214, 90, 90, 0.08); border-color: rgba(214, 90, 90, 0.35); }
.docs-page table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; font-size: 0.9rem; }
.docs-page th, .docs-page td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid #1c2430; }
.docs-page th { color: #9aa0a6; font-weight: 600; text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.04em; }
.docs-page .cta-row { display: flex; gap: 12px; margin-top: 2rem; flex-wrap: wrap; }
.docs-page .cta-row a {
  display: inline-block; padding: 0.7rem 1.4rem; border-radius: 8px; text-decoration: none; font-weight: 600;
  background: #3ddc97; color: #06140e;
}
.docs-page .cta-row a.secondary { background: transparent; color: #e6e6e6; border: 1px solid #2a3340; }

/* ---- Roadmap page: vertical timeline with scroll-in reveal ---- */
.roadmap-timeline { list-style: none; margin: 0; padding: 0 0 0 30px; position: relative; }
.roadmap-timeline::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(to bottom, #3ddc97, #e2a64a 28%, #2a3340 32%, #2a3340 100%);
}
.roadmap-phase { position: relative; margin-bottom: 2.25rem; opacity: 0; transform: translateY(22px); transition: opacity 0.6s ease, transform 0.6s ease; }
.roadmap-phase.is-visible { opacity: 1; transform: none; }
.roadmap-phase:last-child { margin-bottom: 0; }
.roadmap-dot {
  position: absolute; left: -30px; top: 6px; width: 12px; height: 12px; border-radius: 50%;
  background: #4a4f58; border: 3px solid #0c0f14; box-shadow: 0 0 0 2px #1c2430;
}
.roadmap-phase[data-status="shipped"] .roadmap-dot { background: #3ddc97; }
.roadmap-phase[data-status="progress"] .roadmap-dot {
  background: #e2a64a; animation: roadmap-pulse 2s ease-in-out infinite;
}
@keyframes roadmap-pulse {
  0%, 100% { box-shadow: 0 0 0 2px #1c2430, 0 0 0 0 rgba(226, 166, 74, 0.55); }
  50% { box-shadow: 0 0 0 2px #1c2430, 0 0 0 7px rgba(226, 166, 74, 0); }
}
.roadmap-card {
  background: rgba(17, 21, 28, 0.6); border: 1px solid #1c2430; border-radius: 10px; padding: 1.1rem 1.3rem;
  transition: border-color 0.2s, transform 0.2s;
}
.roadmap-card:hover { border-color: #2a3340; transform: translateX(2px); }
.roadmap-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 0.4rem; }
.roadmap-card__head h2 { margin: 0; font-size: 1.15rem; }
.roadmap-badge {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.25rem 0.6rem; border-radius: 999px; white-space: nowrap;
}
.roadmap-badge--shipped { background: rgba(61, 220, 151, 0.15); color: #3ddc97; border: 1px solid rgba(61, 220, 151, 0.4); }
.roadmap-badge--progress { background: rgba(226, 166, 74, 0.15); color: #e2a64a; border: 1px solid rgba(226, 166, 74, 0.4); }
.roadmap-badge--planned { background: rgba(154, 160, 166, 0.12); color: #9aa0a6; border: 1px solid rgba(154, 160, 166, 0.35); }

#login-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
  /* Static composited fallback (real map_001 tiles/buildings/frogs), shown
     instantly while the live animated version (#login-bg-container, a real
     PixiJS render of the same world — wandering frogs, extra buildings,
     slow camera drift, animated water) loads on top of it. Same "show the
     real gameplay behind a dark overlay" treatment Kintara.gg uses. */
  background-image: url('../art/backgrounds/login_bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 100;
}
#login-bg-container { position: absolute; inset: 0; z-index: 0; }
#login-bg-container canvas { display: block; width: 100%; height: 100%; }
#login-overlay {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(circle at center, rgba(10, 14, 20, 0.35) 0%, rgba(10, 14, 20, 0.88) 100%);
}
#login-screen h1, #login-screen p, #login-screen .wallet-buttons, #login-status, #contract-address, #login-logo { position: relative; z-index: 2; }
#login-logo {
  width: 120px; height: 120px; border-radius: 50%; display: block; margin: 0 auto 0.75rem;
  filter: drop-shadow(0 4px 18px rgba(0,0,0,0.6));
}
#login-screen h1 { font-size: 2.4rem; margin-bottom: 0.25rem; letter-spacing: 0.05em; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
#login-screen p { opacity: 0.85; margin-bottom: 1.5rem; text-shadow: 0 1px 6px rgba(0,0,0,0.6); }
#login-screen p.tagline {
  max-width: 480px; text-align: center; font-size: 1.05rem; opacity: 0.92; margin: 0.25rem 0 1.25rem;
}
#login-screen .wallet-buttons { display: flex; gap: 0.75rem; }
#login-screen button {
  padding: 0.75rem 1.5rem; font-size: 1rem; border-radius: 8px; border: none; cursor: pointer;
  background: #3ddc97; color: #06140e; font-weight: 600;
}
#login-screen button:hover { background: #34c587; }
#login-status { margin-top: 1rem; min-height: 1.4em; color: #ff8a8a; }
#login-screen.hidden { display: none; }

.wallet-deeplinks {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  margin-top: 0.5rem;
}
.mobile-wallet-hint {
  opacity: 0.75; font-size: 0.85rem; margin: 0 0 0.2rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}
.deeplink-btn {
  display: inline-block; padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 600;
  border-radius: 8px; text-decoration: none; text-align: center;
  background: #3ddc97; color: #06140e; min-width: 200px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.deeplink-btn:hover { background: #34c587; }
.deeplink-btn--solflare { background: #fc7227; color: #fff; }
.deeplink-btn--solflare:hover { background: #e56620; }

#contract-address {
  display: inline-block; margin-top: 1rem; padding: 0.4rem 0.9rem; border-radius: 999px;
  background: rgba(12, 15, 20, 0.7); border: 1px solid #2a3340; color: #9aa0a6;
  font-size: 0.8rem; font-family: monospace; text-decoration: none; text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  transition: color 0.15s, border-color 0.15s;
}
#contract-address:hover { color: #3ddc97; border-color: #3ddc97; }

#game-root { position: fixed; inset: 0; }
#pixi-container { position: absolute; inset: 0; }
/* Same fix as #login-bg-container canvas below: force the canvas to always
   visually fill its container via CSS, rather than relying entirely on
   PIXI's resizeTo:window JS to keep its inline pixel size in sync. When the
   OS resizes the browser window (e.g. a wallet extension popup opening
   alongside it), that JS-driven resize can lag or miss the event, leaving
   a stale dark gap where the canvas no longer matches the viewport. */
#pixi-container canvas { display: block; width: 100%; height: 100%; }

#fullscreen-btn {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 10;
  padding: 6px 14px; border-radius: 6px; border: 1px solid #2a3340; cursor: pointer;
  background: rgba(12, 15, 20, 0.85); color: #e6e6e6; font-size: 0.8rem;
}
#fullscreen-btn:hover { background: rgba(20, 26, 34, 0.95); }

#mute-btn {
  position: absolute; top: 10px; left: calc(50% + 130px); z-index: 10;
  padding: 6px 14px; border-radius: 6px; border: 1px solid #2a3340; cursor: pointer;
  background: rgba(12, 15, 20, 0.85); color: #e6e6e6; font-size: 0.8rem;
}
#mute-btn:hover { background: rgba(20, 26, 34, 0.95); }

#exit-btn {
  position: absolute; top: 10px; left: calc(50% + 230px); z-index: 10;
  padding: 6px 14px; border-radius: 6px; border: 1px solid #2a3340; cursor: pointer;
  background: rgba(12, 15, 20, 0.85); color: #e6e6e6; font-size: 0.8rem;
}
#exit-btn:hover { background: #d65a5a; color: #fff; border-color: #d65a5a; }

#hud { position: absolute; top: 44px; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 10px; pointer-events: none; }
#hud-left, #hud-right { pointer-events: auto; display: flex; flex-direction: column; gap: 10px; max-height: calc(100% - 20px); overflow-y: auto; }
.panel { background: rgba(12, 15, 20, 0.85); border: 1px solid #2a3340; border-radius: 8px; padding: 10px; min-width: 220px; }
.panel h3 { margin: 0 0 6px; font-size: 0.85rem; text-transform: uppercase; opacity: 0.6; }

.panel.collapsible .panel-header {
  display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none;
}
.panel.collapsible .panel-header h3 { margin: 0; }
.panel.collapsible .panel-body { margin-top: 6px; }
.panel.collapsible .collapse-btn {
  background: none; border: 1px solid #2a3340; border-radius: 4px; color: #e6e6e6; cursor: pointer;
  width: 20px; height: 20px; line-height: 1; font-size: 0.9rem; flex-shrink: 0;
}
.panel.collapsible.collapsed .panel-body { display: none; }
.panel.hidden-until-discovered { display: none; }

#status-bar {
  position: absolute; top: 10px; right: 10px; z-index: 10; display: flex; gap: 14px;
  padding: 6px 14px; font-size: 0.85rem; font-weight: 600;
}
#status-hp { color: #ff8a8a; }
#status-gold { color: #f0d060; }

#inventory-list, #marketplace-list, #recipe-list, #quest-list, #cosmetics-list, #arena-open-list, #arena-mine-list {
  list-style: none; margin: 0; padding: 0; max-height: 140px; overflow-y: auto; font-size: 0.85rem;
}
#inventory-list li, #marketplace-list li, #recipe-list li, #quest-list li, #cosmetics-list li, #arena-open-list li, #arena-mine-list li {
  padding: 4px 0; border-bottom: 1px solid #1c2430; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.item-icon {
  width: 22px; height: 22px; flex-shrink: 0; vertical-align: middle; image-rendering: pixelated;
}
.item-label-row { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.item-label-row span { overflow: hidden; text-overflow: ellipsis; }
.ingredient-icon {
  width: 16px; height: 16px; vertical-align: text-bottom; image-rendering: pixelated; margin: 0 1px;
}
#arena-create-form { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; }
#arena-create-form input { padding: 4px; border-radius: 4px; border: 1px solid #2a3340; background: #11151c; color: #fff; }
#arena-create-form button { padding: 6px; border-radius: 4px; border: none; background: #d65a5a; color: #fff; cursor: pointer; }
#cosmetics-list .cosmetic-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; border: 1px solid #000;
}
#cosmetics-list .cosmetic-actions { display: flex; gap: 4px; flex-shrink: 0; }
#quest-list li { flex-direction: column; align-items: flex-start; }
#quest-list .quest-desc { opacity: 0.7; font-size: 0.78rem; }
#quest-list .quest-actions { display: flex; gap: 6px; margin-top: 4px; }

#chat-panel { position: absolute; bottom: 0; left: 0; width: 320px; max-height: 220px; display: flex; flex-direction: column; padding: 10px; }
#chat-panel .panel-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#chat-log { flex: 1; overflow-y: auto; font-size: 0.85rem; margin-bottom: 6px; }
#chat-log div { margin-bottom: 2px; }
#chat-log .author { color: #3ddc97; font-weight: 600; }
#chat-form { display: flex; gap: 6px; }
#chat-input { flex: 1; padding: 6px; border-radius: 6px; border: 1px solid #2a3340; background: #11151c; color: #fff; }
#chat-form button { padding: 6px 10px; border-radius: 6px; border: none; background: #3ddc97; cursor: pointer; }

#sell-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; font-size: 0.8rem; }
#sell-form select, #sell-form input { padding: 4px; border-radius: 4px; border: 1px solid #2a3340; background: #11151c; color: #fff; }
#sell-form button { padding: 6px; border-radius: 4px; border: none; background: #3ddc97; cursor: pointer; }

.buy-btn, .equip-btn, .craft-btn, .quest-btn {
  padding: 2px 8px; border-radius: 4px; border: none; color: #fff; cursor: pointer; font-size: 0.75rem; flex-shrink: 0;
}
.buy-btn { background: #4a90e2; }
.equip-btn { background: #8a5fd6; }
.craft-btn { background: #3ddc97; color: #06140e; }
.quest-btn { background: #e2a64a; color: #1a1206; }
.quest-btn:disabled { background: #555; color: #999; cursor: not-allowed; }

.recipe-rarity-uncommon span { color: #3ddc97; }
.recipe-rarity-rare span { color: #4a90e2; }
.recipe-rarity-epic span { color: #b06fe0; }
.recipe-rarity-legendary span { color: #f0a830; font-weight: 600; }
.recipe-rarity-epic .craft-btn, .recipe-rarity-legendary .craft-btn { background: #f0a830; color: #1a1206; }

.cosmetic-rarity-uncommon .cosmetic-label { color: #3ddc97; }
.cosmetic-rarity-rare .cosmetic-label { color: #4a90e2; }
.cosmetic-rarity-epic .cosmetic-label { color: #b06fe0; }
.cosmetic-rarity-legendary .cosmetic-label { color: #f0a830; font-weight: 600; }
.cosmetic-buy-btn { background: #4a90e2; }
.cosmetic-equip-btn { background: #8a5fd6; }
.cosmetic-equip-btn.is-equipped { background: #3ddc97; color: #06140e; }

/* ---- Virtual D-pad (mobile only, hidden on desktop via media query) ---- */
#dpad {
  display: none; /* shown only inside the @media block below */
  position: absolute;
  bottom: 155px; /* sits above the chat panel (max-height: 140px + gap) */
  left: 16px;
  z-index: 20;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
}
.dpad-mid {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dpad-center {
  width: 52px;
  height: 52px;
}
.dpad-btn {
  width: 52px;
  height: 52px;
  background: rgba(12, 15, 20, 0.78);
  border: 1px solid #2a3340;
  border-radius: 10px;
  color: #e6e6e6;
  font-size: 1.1rem;
  cursor: pointer;
  /* Prevent browser scroll/zoom on touch — the game handles all touch input */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.dpad-btn:active { background: rgba(61, 220, 151, 0.22); border-color: #3ddc97; }

/* ---- Mobile layout ---- */
@media (max-width: 600px) {
  #dpad { display: flex; }

  /* Reposition the three top overlay buttons so they fit on a narrow screen.
     Desktop uses absolute pixel offsets from center; mobile pins them to
     left / right edges instead. */
  #fullscreen-btn {
    left: 8px;
    transform: none;
    padding: 5px 8px;
    font-size: 0.7rem;
  }
  #mute-btn {
    left: auto;
    right: 60px;
    padding: 5px 8px;
    font-size: 0.7rem;
  }
  #exit-btn {
    left: auto;
    right: 8px;
    padding: 5px 8px;
    font-size: 0.7rem;
  }

  /* Move the HP/Gold bar below the top buttons so they don't collide. */
  #status-bar {
    top: 40px;
    right: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  /* HUD: push it down to sit below the status bar. */
  #hud {
    top: 72px;
    padding: 4px;
  }

  /* Narrow panels so left + right columns don't overlap on small screens. */
  .panel {
    min-width: 0;
    width: 44vw;
    max-width: 200px;
    font-size: 0.78rem;
    padding: 8px;
  }

  /* Lists inside panels: reduce max-height so they don't eat the whole screen. */
  #inventory-list, #marketplace-list, #recipe-list, #quest-list,
  #cosmetics-list, #arena-open-list, #arena-mine-list {
    max-height: 100px;
  }

  /* Chat: span the full width at the bottom. */
  #chat-panel {
    width: 100%;
    max-height: 140px;
  }

  /* Login screen: scale down for narrow viewports. */
  #login-logo { width: 80px; height: 80px; }
  #login-screen h1 { font-size: 1.75rem; }
  #login-screen p.tagline { font-size: 0.88rem; max-width: 92vw; }

  /* Contract address: 44-char hex string would overflow without wrapping. */
  #contract-address {
    word-break: break-all;
    max-width: 90vw;
    text-align: center;
    border-radius: 8px;
    line-height: 1.5;
    font-size: 0.68rem;
    padding: 0.5rem 0.8rem;
  }

  /* Hamburger toggle: visible on mobile */
  #nav-toggle { display: block; }

  /* Nav collapses to a full-width dropdown below the header */
  #site-nav {
    display: none;
    position: fixed;
    top: 54px;
    left: 0; right: 0;
    flex-direction: column;
    gap: 4px;
    background: rgba(10, 13, 18, 0.97);
    border-bottom: 1px solid #2a3340;
    padding: 10px 16px 16px;
    z-index: 199;
  }
  #site-nav.open { display: flex; }
  #site-nav a { font-size: 0.95rem; padding: 10px 14px; white-space: normal; }
}
