/* ── Game page shell ──────────────────────────────────────────────── */

.game-page {
  background: #120d0a;
  overflow: hidden;
}

.game-page .site-nav {
  background: rgba(18, 13, 10, 0.88);
  border-bottom: 1px solid rgba(255, 186, 92, 0.14);
  position: fixed;
  transition: transform 0.25s ease;
  width: 100%;
}

/* B — Auto-hide nav on mobile when playing */
.game-page .site-nav {
  transition: transform 0.25s ease;
}

.game-page .site-nav.is-hidden {
  transform: translateY(-100%);
}

.game-page .site-main {
  min-height: 100vh;
  min-height: 100dvh;
}

.forge-game {
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 186, 92, 0.22), transparent 28rem),
    radial-gradient(circle at 82% 22%, rgba(129, 78, 255, 0.16), transparent 30rem),
    #120d0a;
  height: 100vh;
  height: 100dvh; /* shrinks as mobile browser chrome appears/hides */
  overflow: hidden;
  position: relative;
}

.forge-game__canvas {
  display: block;
  height: 100vh;
  height: 100dvh;
  image-rendering: pixelated;
  touch-action: none;
  width: 100vw;
  width: 100dvw;
  will-change: transform;
}

/* ── HUD container ────────────────────────────────────────────────── */

.forge-hud {
  color: #fff7e7;
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 12;
}

.forge-hud button {
  font: inherit;
}

/* ── Top bar: location | stats | daytime ────────────────────────── */

.forge-hud__top {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  left: 18px;
  position: absolute;
  right: 70px;
  top: 76px;
}

/* Shared glass panel base */
.forge-panel,
.forge-stats,
.forge-quickbar,
.forge-drawer,
.forge-location {
  backdrop-filter: blur(18px);
  background: rgba(20, 12, 8, 0.88);
  border: 1px solid rgba(255, 200, 120, 0.18);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 231, 180, 0.07);
}

/* ── Draggable panel system ──────────────────────────────────────── */

/* Grip icon shown in panel headers */
.forge-drag-grip {
  color: rgba(255, 255, 255, 0.3);
  cursor: grab;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
  padding: 0 3px;
  touch-action: none;
  user-select: none;
}

.forge-drag-grip:hover { color: rgba(255, 255, 255, 0.7); }
.forge-drag-grip:active { cursor: grabbing; }

/* Grip tab on the quickbar */
.forge-quickbar__grip {
  align-items: center;
  color: rgba(255, 255, 255, 0.3);
  cursor: grab;
  display: flex;
  flex-shrink: 0;
  font-size: 13px;
  padding: 0 4px;
  touch-action: none;
  user-select: none;
}

.forge-quickbar__grip:hover { color: rgba(255, 255, 255, 0.6); }
.forge-quickbar__grip:active { cursor: grabbing; }

/* Active drag state */
.is-dragging {
  cursor: grabbing !important;
  opacity: 0.82;
  transition: none !important;
  z-index: 999;
}

/* Snap-to-zone animation */
.is-snapping {
  transition: left 0.2s ease, top 0.2s ease !important;
}

/* ── Location badge (also the HUD-top drag handle) ──────────────── */

.forge-location {
  align-items: center;
  border-radius: 10px;
  color: #ffd891;
  cursor: grab;
  display: flex;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  gap: 7px;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  text-transform: uppercase;
  touch-action: none;
  white-space: nowrap;
}

.forge-location__icon {
  font-size: 16px;
}

.game-texture-icon {
  display: inline-block;
  flex: 0 0 auto;
  height: 1.55em;
  image-rendering: auto;
  object-fit: contain;
  vertical-align: -0.3em;
  width: 1.55em;
}

.game-emoji-icon {
  align-items: center;
  background-image: none;
  display: inline-flex;
  font-size: 1.2em;
  justify-content: center;
  line-height: 1;
}


/* ── Resource stats bar ───────────────────────────────────────────── */

/* C+D — HUD collapse toggle button */
.forge-hud__collapse {
  align-self: flex-start;
  flex-shrink: 0;
  margin-left: auto;
  transition: transform 0.22s ease;
}

.forge-hud__top.is-collapsed .forge-hud__collapse {
  transform: rotate(180deg);
}

.forge-stats {
  border-radius: 10px;
  display: flex;
  gap: 6px;
  max-height: 200px;
  overflow: hidden;
  padding: 8px;
  transform-origin: top center;
  transition: max-height 0.22s ease, opacity 0.18s, padding 0.18s, transform 0.22s ease;
}

/* C+D — Collapsed state hides resource stats, leaves location + daytime */
.forge-hud__top.is-collapsed .forge-stats {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.forge-hud__top.is-currency-transient.is-currency-hidden .forge-stats {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

.forge-hud__top.is-currency-transient.is-currency-visible .forge-stats {
  opacity: 1;
  transform: translateY(0);
}

.forge-stat {
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 62px;
  padding: 8px 10px;
  text-align: center;
}

.forge-stat__icon {
  font-size: 16px;
  line-height: 1;
}

.forge-stat__icon .game-texture-icon,
.forge-location__icon .game-texture-icon {
  height: 22px;
  width: 22px;
}

.forge-stat strong {
  color: #fff7e7;
  display: block;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.forge-stat em {
  color: #c9ae7d;
  display: block;
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ── Daytime chip ────────────────────────────────────────────────── */

.forge-daytime {
  align-self: center;
  background: rgba(20, 12, 8, 0.72);
  border: 1px solid rgba(255, 200, 120, 0.22);
  border-radius: 20px;
  color: #ffd891;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  white-space: nowrap;
}

/* ── Map modal ───────────────────────────────────────────────────── */
/* Fixed centered drawer (not draggable); goes fullscreen on mobile,   *
 * see the #minimapPanel.is-open override in the mobile media query.  */

@keyframes forge-map-modal-in {
  from { opacity: 0; transform: translate(-50%, -50%) translateY(6px); }
  to   { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
}

#minimapPanel {
  left: 50%;
  right: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 36px));
}

#minimapPanel.is-open {
  animation: forge-map-modal-in 0.16s ease both;
}

#minimapPanel .forge-drawer__content {
  align-items: center;
  display: flex;
  justify-content: center;
}

/* Shared collapse toggle button (used by quest panel) */
.forge-panel-toggle {
  background: none;
  border: none;
  color: #7a6850;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  padding: 2px 5px;
  pointer-events: auto;
  transition: color 0.12s;
}

.forge-panel-toggle:hover {
  color: #ffd891;
}

.forge-panel-toggle--close {
  align-items: center;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 200, 120, 0.14);
  border-radius: 50%;
  color: #d7c8aa;
  display: inline-flex;
  font-size: 16px;
  font-weight: 900;
  height: 26px;
  justify-content: center;
  line-height: 1;
  width: 26px;
}

.forge-panel-toggle--close:hover {
  background: rgba(255, 216, 145, 0.12);
  border-color: rgba(255, 216, 145, 0.32);
}

.forge-minimap {
  border-radius: 8px;
  display: block;
  height: auto;
  image-rendering: pixelated;
  max-width: 100%;
}

/* ── Menu toggle button ──────────────────────────────────────────── */

.forge-menu-btn {
  background: rgba(20, 12, 8, 0.88);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 200, 120, 0.18);
  border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 231, 180, 0.07);
  color: #ffd891;
  cursor: pointer;
  font-size: 17px;
  min-height: 44px;
  min-width: 44px;
  padding: 9px 13px;
  pointer-events: auto;
  position: absolute;
  right: 18px;
  top: 76px;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s;
}

.forge-menu-btn:hover {
  background: rgba(255, 186, 92, 0.14);
  border-color: rgba(255, 186, 92, 0.4);
}

/* Quest count badge on the menu button — visible on touch devices where the overlay is hidden */
.forge-menu-btn[data-quest-badge]:not([data-quest-badge=""])::after {
  align-items: center;
  background: #ef4444;
  border: 1.5px solid rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  color: #fff;
  content: attr(data-quest-badge);
  display: flex;
  font-size: 9px;
  font-weight: 900;
  height: 16px;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  position: absolute;
  right: 3px;
  top: 3px;
  width: 16px;
}

/* ── Panel base ──────────────────────────────────────────────────── */

.forge-panel {
  border-radius: 10px;
  padding: 14px 16px;
}

.forge-panel h1 {
  font-size: 17px;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.forge-panel p {
  color: #d7c8aa;
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

/* ── Quest / order tracker ───────────────────────────────────────── */

.forge-quest {
  border-radius: 10px;
  bottom: 18px;
  left: 18px;
  max-width: min(500px, calc(100vw - 36px));
  min-width: 180px;
  padding: 10px 12px;
  pointer-events: auto;
  position: absolute;
}

/* Quest overlay is desktop-only — on touch devices quests are accessed via the menu */
@media (hover: none) and (pointer: coarse) {
  .forge-quest { display: none !important; }
}

.forge-quest__head {
  align-items: center;
  cursor: default;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
  user-select: none;
}

.forge-quest__body {
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.22s ease, opacity 0.18s;
  opacity: 1;
}

.forge-quest.is-collapsed .forge-quest__body {
  max-height: 0;
  opacity: 0;
}

.forge-quest.is-collapsed .forge-quest__head {
  margin-bottom: 0;
}

.forge-quest__head strong {
  color: #c9ae7d;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.forge-quest__head span {
  background: rgba(255, 186, 92, 0.14);
  border: 1px solid rgba(255, 186, 92, 0.38);
  border-radius: 999px;
  color: #ffd891;
  font-size: 12px;
  font-weight: 850;
  padding: 4px 10px;
}

.forge-quest p {
  color: #d7c8aa;
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

.forge-quest__controls {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #a09078 !important;
  font-size: 11px !important;
  margin-top: 10px !important;
  padding-top: 10px;
}

.forge-quest__controls kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: #d7c8aa;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
}

/* ── Quickbar ────────────────────────────────────────────────────── */

.forge-quickbar {
  border-radius: 10px;
  bottom: 18px;
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
  left: 50%;
  max-width: calc(100vw - 32px);
  overflow-x: auto;
  padding: 9px;
  pointer-events: auto;
  position: absolute;
  scrollbar-width: none;
  transform: translateX(-50%);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
  white-space: nowrap;
  width: min(620px, calc(100vw - 32px));
}

.forge-quickbar::-webkit-scrollbar {
  display: none;
}

.forge-quickbar.is-transient-hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.forge-quickbar.is-transient-visible {
  opacity: 1;
  visibility: visible;
}

.forge-slot {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 200, 120, 0.14);
  border-radius: 9px;
  color: #fff7e7;
  cursor: pointer;
  display: grid;
  flex: 0 0 60px;
  font-size: 22px;
  height: 60px;
  min-width: 0;
  place-items: center;
  position: relative;
  touch-action: manipulation;
  transition: background 0.1s, border-color 0.1s, transform 0.1s, box-shadow 0.1s;
}

.forge-slot__texture {
  height: 35px;
  width: 35px;
}

.forge-slot:hover {
  background: rgba(255, 186, 92, 0.1);
  border-color: rgba(255, 186, 92, 0.3);
}

.forge-slot.is-active {
  background: rgba(255, 186, 92, 0.18);
  border-color: rgba(255, 216, 145, 0.7);
  box-shadow: 0 0 14px rgba(255, 186, 92, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(-3px);
}

.forge-slot--hand {
  border-style: dashed;
  opacity: 0.65;
}

.forge-slot--hand.is-active {
  border-style: solid;
  opacity: 1;
}

.forge-slot small,
.forge-slot b {
  font-size: 10px;
  font-weight: 900;
  position: absolute;
}

.forge-slot small {
  color: #c9ae7d;
  left: 6px;
  top: 5px;
}

.forge-slot b {
  bottom: 5px;
  color: #ffd891;
  right: 6px;
}

.forge-quickbar__tabs {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
}

.forge-quickbar-tab {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 200, 120, 0.12);
  border-radius: 6px;
  color: #c9ae7d;
  cursor: pointer;
  font: 800 10px/1.2 inherit;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  text-transform: uppercase;
}

.forge-quickbar-tab:hover,
.forge-quickbar-tab.is-active {
  background: rgba(255, 186, 92, 0.16);
  border-color: rgba(255, 216, 145, 0.55);
  color: #fff1ce;
}

.forge-quickbar__slots {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  max-width: 100%;
  width: 100%;
}

.forge-quickbar__slots::-webkit-scrollbar {
  display: none;
}

.forge-slot--empty {
  border-style: dashed;
  opacity: 0.42;
}

.forge-slot--seed b {
  align-items: center;
  background: #3b2718;
  border: 1px solid rgba(255, 216, 145, 0.45);
  border-radius: 999px;
  display: flex;
  justify-content: center;
  min-height: 17px;
  min-width: 17px;
  padding: 0 4px;
}

/* The bar owns the tabs; only its slot row scrolls on narrow screens. */
.forge-quickbar {
  align-items: stretch;
  flex-direction: column;
  overflow: visible;
  white-space: normal;
}

/* ── Toast ───────────────────────────────────────────────────────── */

.forge-toast {
  background: rgba(18, 10, 7, 0.96);
  border: 1px solid rgba(255, 200, 120, 0.22);
  border-radius: 999px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 231, 180, 0.06);
  font-size: 13px;
  font-weight: 800;
  left: 50%;
  letter-spacing: 0.02em;
  max-width: min(720px, calc(100vw - 36px));
  opacity: 0;
  padding: 11px 18px;
  position: absolute;
  text-align: center;
  top: 148px;
  transform: translateX(-50%) translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.forge-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Drawers (inventory / shop) ──────────────────────────────────── */

@keyframes forge-panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.forge-drawer {
  border-radius: 10px;
  display: none;
  max-height: min(690px, calc(100vh - 150px));
  max-height: min(690px, calc(100dvh - 150px));
  overflow: auto;
  padding: 16px;
  pointer-events: auto;
  position: absolute;
  right: 18px;
  top: 154px;
  width: min(580px, calc(100vw - 36px));
}

.forge-drawer.is-open {
  animation: forge-panel-in 0.16s ease both;
  display: block;
  z-index: 4;
}

.forge-drawer__head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.forge-drawer h2 {
  color: #ffd891;
  font-size: 16px;
  letter-spacing: 0.06em;
  margin: 0;
  text-transform: uppercase;
}

.forge-close {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 200, 120, 0.16);
  border-radius: 999px;
  color: #fff7e7;
  cursor: pointer;
  font-size: 13px;
  min-height: 36px;
  min-width: 36px;
  padding: 6px 10px;
  touch-action: manipulation;
  transition: background 0.1s;
}

.forge-close:hover {
  background: rgba(255, 186, 92, 0.14);
}

/* ── Inventory & shop items ──────────────────────────────────────── */

.forge-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.forge-item,
.forge-shop-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 12px;
}

.forge-item {
  min-height: 110px;
}

.forge-item__icon {
  font-size: 24px;
}

.forge-item__icon .game-texture-icon {
  height: 34px;
  width: 34px;
}

.forge-item__name,
.forge-shop-item h3 {
  font-size: 13px;
  font-weight: 850;
  margin: 5px 0;
}

.forge-item__meta,
.forge-shop-item p,
.forge-cost {
  color: #d7c8aa;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

#inventoryPanel.is-open {
  border-radius: 0;
  bottom: 0;
  left: 0;
  max-height: none;
  padding: clamp(16px, 2.5vw, 32px);
  right: 0;
  top: 0;
  width: auto;
  z-index: 40;
}

#inventoryPanel.is-open .forge-drawer__head {
  min-height: 44px;
}

#inventoryPanel.is-open .forge-drawer__content {
  height: calc(100% - 58px);
  overflow: auto;
}

.forge-inventory-page {
  display: grid;
  gap: 14px;
  grid-template-columns: 156px minmax(0, 1fr);
}

.forge-inventory-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.forge-inventory-tabs button {
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 200, 120, 0.11);
  border-radius: 8px;
  color: #d7c8aa;
  cursor: pointer;
  display: flex;
  font-size: 12px;
  font-weight: 850;
  justify-content: space-between;
  min-height: 36px;
  padding: 8px 10px;
  text-align: left;
}

.forge-inventory-tabs button:hover,
.forge-inventory-tabs button.is-active {
  background: linear-gradient(135deg, rgba(255, 216, 145, 0.18), rgba(125, 211, 252, 0.08));
  border-color: rgba(255, 216, 145, 0.34);
  color: #fff7e7;
}

.forge-inventory-tabs b {
  background: rgba(0, 0, 0, 0.24);
  border-radius: 999px;
  color: #ffd891;
  font-size: 11px;
  min-width: 24px;
  padding: 2px 7px;
  text-align: center;
}

.forge-inventory-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.forge-inventory-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.forge-inventory-summary div,
.forge-inventory-equipped,
.forge-inventory-empty {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.forge-inventory-summary div {
  min-width: 0;
  padding: 10px 12px;
}

.forge-inventory-summary span,
.forge-inventory-equipped__copy span {
  color: #b8a98d;
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.forge-inventory-summary strong {
  color: #fff7e7;
  display: block;
  font-size: 18px;
  line-height: 1.15;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forge-inventory-equipped {
  background:
    linear-gradient(135deg, rgba(255, 216, 145, 0.12), rgba(125, 211, 252, 0.055)),
    rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 216, 145, 0.22);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(120px, 0.34fr) minmax(0, 1fr);
  padding: 12px;
}

.forge-inventory-equipped__copy strong {
  color: #ffd891;
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.forge-inventory-slots {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.forge-inventory-slot {
  align-items: center;
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 200, 120, 0.12);
  border-radius: 8px;
  color: #fff7e7;
  cursor: pointer;
  display: grid;
  justify-items: center;
  min-width: 0;
  padding: 6px;
  position: relative;
}

.forge-inventory-slot:hover,
.forge-inventory-slot.is-active {
  background: rgba(255, 216, 145, 0.14);
  border-color: rgba(255, 216, 145, 0.48);
  box-shadow: inset 0 0 0 1px rgba(255, 216, 145, 0.18);
}

.forge-inventory-slot span {
  background: rgba(0, 0, 0, 0.42);
  border-radius: 999px;
  color: #ffd891;
  font-size: 10px;
  font-weight: 900;
  left: 5px;
  line-height: 1;
  padding: 3px 5px;
  position: absolute;
  top: 5px;
}

.forge-inventory-slot .game-texture-icon {
  height: 32px;
  width: 32px;
}

.forge-inventory-slot strong {
  color: #d7c8aa;
  display: block;
  font-size: 10px;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forge-inventory-items {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.forge-inventory-card {
  align-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.025));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  min-height: 86px;
  padding: 10px;
}

.forge-inventory-card--equipped {
  background: linear-gradient(135deg, rgba(255, 216, 145, 0.18), rgba(255, 255, 255, 0.04));
  border-color: rgba(255, 216, 145, 0.36);
  box-shadow: inset 3px 0 0 rgba(255, 216, 145, 0.72);
}

.forge-inventory-card--equipment {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.13), rgba(255, 255, 255, 0.035));
  border-color: rgba(125, 211, 252, 0.32);
  box-shadow: inset 3px 0 0 rgba(125, 211, 252, 0.62);
}

.forge-inventory-card--resources {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.12), rgba(255, 255, 255, 0.03));
  border-color: rgba(74, 222, 128, 0.22);
}

.forge-inventory-card--consumables {
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.13), rgba(255, 255, 255, 0.035));
  border-color: rgba(244, 114, 182, 0.26);
}

.forge-inventory-card--currency {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.16), rgba(255, 255, 255, 0.035));
  border-color: rgba(250, 204, 21, 0.32);
}

.forge-inventory-card.is-empty {
  opacity: 0.64;
}

.forge-inventory-card__icon {
  align-items: center;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 200, 120, 0.12);
  border-radius: 8px;
  display: flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.forge-inventory-card__icon .game-texture-icon {
  height: 34px;
  width: 34px;
}

.forge-inventory-card__body {
  min-width: 0;
}

.forge-inventory-card__top {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
}

.forge-inventory-card__top strong {
  color: #fff7e7;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forge-inventory-card__top span {
  color: #ffd891;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.forge-inventory-card p,
.forge-inventory-card small {
  color: #d7c8aa;
  display: block;
  font-size: 12px;
  line-height: 1.35;
  margin: 3px 0 0;
}

.forge-inventory-card small {
  color: #a99b82;
}

.forge-inventory-card__qty {
  background: rgba(255, 216, 145, 0.14);
  border: 1px solid rgba(255, 216, 145, 0.2);
  border-radius: 999px;
  color: #ffd891;
  font-size: 12px;
  min-width: 34px;
  padding: 5px 8px;
  text-align: center;
}

.forge-inventory-empty {
  color: #d7c8aa;
  font-size: 13px;
  grid-column: 1 / -1;
  padding: 18px;
  text-align: center;
}

.forge-cost__old {
  color: #9b8d72;
  margin-left: 4px;
  text-decoration: line-through;
}

.forge-mini {
  background: rgba(255, 216, 145, 0.14);
  border-radius: 999px;
  color: #ffd891;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  margin-right: 5px;
  margin-top: 8px;
  padding: 5px 8px;
}

.forge-shop-item {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  margin-bottom: 10px;
}

.forge-shop-item.is-locked {
  opacity: 0.58;
}

.forge-skill-rank {
  align-items: center;
  background: rgba(255, 216, 145, 0.1);
  border: 1px solid rgba(255, 216, 145, 0.18);
  border-radius: 8px;
  color: #ffd891;
  display: flex;
  flex-direction: column;
  font-size: 11px;
  font-weight: 850;
  gap: 2px;
  min-width: 68px;
  padding: 8px;
  text-align: center;
}

.forge-skill-rank strong {
  color: #fff7e7;
  font-size: 14px;
}

.forge-cost {
  color: #ffd891;
  font-weight: 850;
  margin-top: 7px;
}

.forge-rarity-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-left: 6px;
  opacity: 0.9;
  text-transform: capitalize;
  vertical-align: middle;
}

.forge-skill-icon {
  width: 18px;
  height: 18px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ── Craft panel: progress bar + multi-craft button ─────────────── */

.forge-craft-progress {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.forge-craft-progress__bar {
  background: rgba(255, 186, 92, 0.72);
  border-radius: 999px;
  flex: 1 1 auto;
  height: 4px;
  max-width: 80px;
  transition: width 0.2s ease;
}

.forge-craft-progress span {
  color: #c9ae7d;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 850;
}

.forge-craft-btns {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.forge-craft-max {
  border-radius: 7px;
  font-size: 11px;
  font-weight: 900;
  padding: 5px 10px;
  white-space: nowrap;
}

.forge-property-drawer {
  width: min(640px, calc(100vw - 36px));
}

.forge-property-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 10px;
}

.forge-property-summary div {
  background: rgba(255, 216, 145, 0.08);
  border: 1px solid rgba(255, 216, 145, 0.16);
  border-radius: 8px;
  padding: 9px;
}

.forge-property-summary strong {
  color: #fff7e7;
  display: block;
  font-size: 18px;
  line-height: 1;
}

.forge-property-summary span,
.forge-property-note,
.forge-property-legend {
  color: #d7c8aa;
  font-size: 12px;
}

.forge-property-note {
  margin-bottom: 12px;
}

.forge-property-grid {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(var(--property-cols), var(--property-cell, minmax(0, 1fr)));
  width: max-content;
  margin-bottom: 12px;
}

.forge-property-map-scroll {
  max-height: 54vh;
  overflow: auto;
  padding: 8px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px;
  background: rgba(0,0,0,.16);
}

.forge-property-map-canvas {
  display: block;
  width: max-content;
  max-width: none;
  image-rendering: pixelated;
  cursor: crosshair;
  outline: none;
}

.forge-property-map-canvas:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 216, 145, 0.55);
}

.forge-property-map-status {
  min-height: 18px;
  margin: -5px 0 10px;
  color: #d7c8aa;
  font-size: 12px;
}

.forge-property-cell {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  cursor: pointer;
  min-width: 0;
  padding: 0;
}

.forge-property-cell.is-unavailable { background: rgba(180,59,59,.2); border-color: rgba(220,80,80,.34); }
.forge-property-cell.is-starter { background: rgba(214,173,60,.3); border-color: rgba(235,199,92,.62); }
.forge-property-cell.is-ownable { background: rgba(57,168,102,.28); border-color: rgba(79,203,125,.58); }
.forge-property-cell.is-house { background: rgba(61,121,198,.3); border-color: rgba(90,151,226,.62); }

.forge-property-cell.is-owned {
  background: rgba(255, 216, 145, 0.22);
  border-color: rgba(255, 216, 145, 0.55);
  cursor: default;
}

.forge-property-cell.is-base {
  box-shadow: inset 0 0 0 2px rgba(255, 247, 231, 0.22);
}

.forge-property-cell.is-expandable:not(:disabled) {
  background: rgba(99, 179, 237, 0.22);
  border-color: rgba(99, 179, 237, 0.55);
}

.forge-property-cell.is-selected {
  background: rgba(74, 222, 128, 0.28);
  border-color: rgba(74, 222, 128, 0.72);
}

.forge-property-cell.is-expandable:not(:disabled):hover {
  filter: brightness(1.25);
}

.forge-property-cell:disabled {
  cursor: not-allowed;
  opacity: 0.78;
}

.forge-property-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.forge-property-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.forge-property-actions span {
  color: #fff7e7;
  font-size: 12px;
  font-weight: 850;
  margin-right: auto;
}

.forge-property-legend span {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.forge-property-legend i {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  display: inline-block;
  height: 12px;
  width: 12px;
}

.forge-property-legend i.is-owned {
  background: rgba(255, 216, 145, 0.28);
  border-color: rgba(255, 216, 145, 0.55);
}

.forge-property-legend i.is-expandable {
  background: rgba(99, 179, 237, 0.28);
  border-color: rgba(99, 179, 237, 0.55);
}

.forge-property-legend i.is-selected {
  background: rgba(74, 222, 128, 0.32);
  border-color: rgba(74, 222, 128, 0.72);
}

/* ── Primary button ──────────────────────────────────────────────── */

.forge-primary,
.forge-close,
.forge-mini {
  border: 0;
  cursor: pointer;
  font-weight: 850;
}

.forge-primary {
  background: linear-gradient(135deg, #ffd891 0%, #ff9f45 100%);
  border-radius: 9px;
  color: #271306;
  font-size: 14px;
  min-height: 44px;
  padding: 12px 20px;
  touch-action: manipulation;
  transition: filter 0.12s;
}

.forge-primary:hover {
  filter: brightness(1.1);
}

.forge-primary:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.5;
}

/* ── Game menu overlay ───────────────────────────────────────────── */

.forge-menu {
  align-items: center;
  backdrop-filter: blur(10px);
  background: rgba(6, 3, 1, 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  pointer-events: auto;
  position: absolute;
  z-index: 18;
}

.forge-menu[aria-hidden="true"] {
  display: none;
}

.forge-menu__panel {
  background:
    linear-gradient(160deg, #1e130d 0%, #2c1c12 100%);
  border: 1px solid rgba(255, 186, 92, 0.28);
  border-radius: 14px;
  box-shadow:
    0 40px 120px rgba(0, 0, 0, 0.8),
    0 0 48px rgba(255, 186, 92, 0.07),
    inset 0 1px 0 rgba(255, 231, 180, 0.08);
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  min-width: min(300px, calc(100vw - 32px));
  overflow-y: auto;
  padding: 28px 24px;
}

.forge-menu__title {
  color: #ffd891;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  text-align: center;
  text-transform: uppercase;
}

.forge-menu__btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 200, 120, 0.16);
  border-radius: 9px;
  color: #fff7e7;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  min-height: 44px;
  padding: 12px 16px;
  text-align: left;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s;
}

.forge-menu__btn:hover {
  background: rgba(255, 186, 92, 0.11);
  border-color: rgba(255, 186, 92, 0.38);
}

.forge-menu__btn--primary {
  background: rgba(255, 186, 92, 0.13);
  border-color: rgba(255, 186, 92, 0.42);
  color: #ffd891;
}

.forge-menu__btn--primary:hover {
  background: rgba(255, 186, 92, 0.22);
}

.forge-menu__btn--danger {
  border-color: rgba(248, 113, 113, 0.18);
  color: #f87171;
}

.forge-menu__btn--danger:hover {
  background: rgba(248, 113, 113, 0.09);
  border-color: rgba(248, 113, 113, 0.4);
}

.forge-menu__divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  margin: 2px 0;
}



/* ── Settings panel ──────────────────────────────────────────────── */

.forge-settings {
  max-height: min(78vh, 720px);
  overflow: auto;
  padding: 4px 2px 0 0;
  scrollbar-width: thin;
}

.forge-settings__head {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.forge-settings__head strong {
  color: #ffd891;
  flex: 1;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.forge-settings__back {
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 200, 120, 0.18);
  border-radius: 7px;
  color: #ffd891;
  cursor: pointer;
  display: flex;
  font-size: 16px;
  height: 32px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.12s, border-color 0.12s;
  width: 32px;
}

.forge-settings__back:hover {
  background: rgba(255, 186, 92, 0.14);
  border-color: rgba(255, 186, 92, 0.42);
}

.forge-settings__section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 200, 120, 0.10);
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 14px;
}

.forge-settings__section-label {
  color: #8a7455;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.forge-settings__section-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.forge-menu__mini-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 200, 120, 0.16);
  border-radius: 6px;
  color: #ffd891;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
}

.forge-order-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 216, 145, 0.16);
  border-radius: 7px;
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  padding: 10px;
}

.forge-order-card span {
  color: #a09070;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.forge-order-card b {
  color: #ffd891;
  font-size: 15px;
}

.forge-order-card p {
  color: #d7c8aa;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

.forge-settings__row {
  align-items: center;
  border-radius: 6px;
  color: #d7c8aa;
  cursor: pointer;
  display: flex;
  font-size: 13px;
  gap: 10px;
  margin: 0 -6px;
  padding: 7px 6px;
  transition: background 0.1s;
}

.forge-settings__row:hover {
  background: rgba(255, 186, 92, 0.07);
  color: #fff7e7;
}

.forge-settings__row span {
  flex: 1;
}

.forge-hotkeys {
  display: grid;
  gap: 6px;
}

.forge-hotkey {
  align-items: center;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: #fff7e7;
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 12px;
  justify-content: space-between;
  padding: 8px 9px;
  text-align: left;
}

.forge-hotkey:hover,
.forge-hotkey.is-capturing {
  background: rgba(255, 186, 92, 0.1);
  border-color: rgba(255, 186, 92, 0.38);
}

.forge-hotkey kbd,
.forge-hotkey-hint {
  color: #c9ae7d;
}

.forge-hotkey kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 900;
  min-width: 42px;
  padding: 2px 6px;
  text-align: center;
}

.forge-hotkey-hint {
  font-size: 11px;
  line-height: 1.35;
  margin: 8px 0 0;
}

.forge-settings__keys {
  display: none;
}

.forge-settings__row input[type="checkbox"] {
  accent-color: #ffd891;
  cursor: pointer;
  height: 15px;
  width: 15px;
}

.forge-settings__keys {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}

.forge-settings__keys td {
  color: #c9ae7d;
  padding: 3px 5px;
}

.forge-settings__keys td:first-child {
  text-align: right;
  white-space: nowrap;
}

.forge-settings__keys kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: #c9ae7d;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
}

.forge-dialog[aria-hidden="true"] {
  display: none;
}

.forge-dialog {
  align-items: flex-end;
  animation: forge-panel-in 0.18s ease both;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.56));
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 20px;
  pointer-events: auto;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 39;
}

.forge-dialog__panel {
  align-items: center;
  background:
    linear-gradient(145deg, rgba(28, 18, 11, 0.98), rgba(13, 18, 30, 0.98)),
    radial-gradient(circle at 20% 0%, rgba(255, 186, 92, 0.18), transparent 58%);
  border: 1px solid rgba(255, 216, 145, 0.2);
  border-radius: 12px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.72);
  display: grid;
  gap: 14px;
  grid-template-columns: 86px minmax(0, 1fr) minmax(160px, 220px);
  max-width: min(920px, calc(100vw - 32px));
  min-height: 138px;
  padding: 18px;
  position: relative;
  width: 100%;
}

.forge-dialog__close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  color: #d7c8aa;
  cursor: pointer;
  height: 30px;
  position: absolute;
  right: 12px;
  top: 12px;
  width: 30px;
}

.forge-dialog__portrait {
  align-items: center;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 216, 145, 0.14);
  border-radius: 9px;
  display: flex;
  height: 86px;
  justify-content: center;
  width: 86px;
}

.forge-dialog__portrait-icon {
  height: 72px;
  width: 72px;
}

.forge-dialog__portrait-fallback {
  align-items: center;
  background: radial-gradient(circle at 35% 28%, rgba(255, 216, 145, 0.24), rgba(115, 62, 28, 0.22));
  border: 1px solid rgba(255, 216, 145, 0.24);
  border-radius: 50%;
  color: #ffd891;
  display: flex;
  font-size: 24px;
  font-weight: 900;
  height: 68px;
  justify-content: center;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  width: 68px;
}

.forge-dialog__copy {
  min-width: 0;
  padding-right: 16px;
}

.forge-dialog__role {
  color: #c9ae7d;
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.forge-dialog__copy h2 {
  color: #ffd891;
  font-size: 22px;
  margin: 2px 0 7px;
}

.forge-dialog__copy p {
  color: #f2dfbd;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.forge-dialog__choices {
  display: grid;
  gap: 7px;
}

.forge-dialog__choice {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 200, 120, 0.16);
  border-radius: 8px;
  color: #fff7e7;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 11px;
  text-align: left;
  touch-action: manipulation;
}

.forge-dialog__choice:hover {
  background: rgba(255, 186, 92, 0.12);
  border-color: rgba(255, 186, 92, 0.4);
}

.forge-dialog__choice-cost {
  color: rgba(255, 247, 231, 0.6);
  font-size: 11px;
  font-weight: 600;
}

@media (max-width: 720px) {
  .forge-dialog {
    padding: 12px;
  }

  .forge-dialog__panel {
    align-items: stretch;
    grid-template-columns: 64px minmax(0, 1fr);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow: auto;
    padding: 14px;
  }

  .forge-dialog__portrait {
    height: 64px;
    width: 64px;
  }

  .forge-dialog__portrait-icon {
    height: 54px;
    width: 54px;
  }

  .forge-dialog__choices {
    grid-column: 1 / -1;
  }

  /* Enlarge close button to meet minimum 44px touch target */
  .forge-dialog__close {
    height: 44px;
    width: 44px;
  }

  /* Larger touch targets for dialog choices on mobile — minimum 44px height */
  .forge-dialog__choice {
    min-height: 44px;
    padding: 13px 11px;
  }
}

/* ── Start screen ────────────────────────────────────────────────── */

.forge-start {
  background:
    linear-gradient(145deg, rgba(26, 16, 10, 0.98) 0%, rgba(50, 32, 18, 0.94) 100%),
    radial-gradient(circle at 50% 0%, rgba(255, 186, 92, 0.18), transparent 68%);
  border: 1px solid rgba(255, 200, 120, 0.2);
  border-radius: 14px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 231, 180, 0.07);
  left: 50%;
  max-width: min(580px, calc(100vw - 36px));
  padding: 32px 28px;
  pointer-events: auto;
  position: absolute;
  text-align: center;
  top: 52%;
  transform: translate(-50%, -50%);
}

.forge-start.is-hidden {
  display: none;
}

.forge-start__badge {
  background: rgba(255, 186, 92, 0.12);
  border: 1px solid rgba(255, 186, 92, 0.3);
  border-radius: 999px;
  color: #c9ae7d;
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  padding: 4px 12px;
  text-transform: uppercase;
}

.forge-start h2 {
  font-size: clamp(36px, 7vw, 64px);
  letter-spacing: -0.04em;
  line-height: 0.92;
  margin: 0 0 14px;
}

.forge-start p {
  color: #d7c8aa;
  font-size: 14px;
  line-height: 1.6;
  margin: 0 auto 24px;
  max-width: 440px;
}

/* ── Responsive: tablet ──────────────────────────────────────────── */

@media (max-width: 920px) {
  .forge-hud__top {
    top: 100px;
    right: 18px;
  }

  .forge-stats {
    gap: 5px;
  }

  .forge-stat {
    min-width: 52px;
    padding: 7px 8px;
  }

  .forge-quickbar {
    bottom: 148px;
  }
}

/* ── Nav-gone: HUD slides up after mobile nav hides during play ──── */
/* Body class fnp-nav-gone is added by JS when the nav slides off.  */
/* Transition matches site-nav transform 0.25s so they move together. */

@media (max-width: 640px) {
  .fnp-nav-gone .forge-hud__top {
    top: 18px;
  }
  .fnp-nav-gone .forge-menu-btn {
    top: 18px;
  }
  .fnp-nav-gone .forge-drawer {
    max-height: calc(100dvh - 176px); /* 100px top + 76px quickbar clearance */
    top: 100px;
  }
  .fnp-nav-gone .forge-toast {
    top: 90px;
  }
}

/* ── Responsive: mobile ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .game-page .site-nav {
    position: fixed;
  }

  .forge-hud__top {
    gap: 8px;
    left: 10px;
    right: 10px;
    top: 52px;
    transition: top 0.25s ease;
  }

  .forge-location {
    font-size: 11px;
    padding: 8px 10px;
  }

  .forge-stat {
    min-width: 46px;
    padding: 6px 6px;
  }

  .forge-stat strong {
    font-size: 14px;
  }

  /* Allow horizontal scroll through stats on small screens instead of clipping */
  .forge-stats {
    -webkit-mask-image: linear-gradient(to right, transparent 0, black 8px, black calc(100% - 8px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, black 8px, black calc(100% - 8px), transparent 100%);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .forge-stats::-webkit-scrollbar {
    display: none;
  }

  .forge-hud__top {
    right: 10px;   /* full width on mobile */
  }

  .forge-menu-btn {
    top: 136px;
    transition: top 0.25s ease;
  }

  .forge-quest {
    bottom: 118px;
    left: 10px;
    max-width: calc(100vw - 20px);
  }

  .forge-quest__controls {
    display: none;
  }

  /* Keep all nine quick slots visible in one row without entering the
   * joystick capture zone at the bottom-left. */
  .forge-quickbar {
    bottom: 12px;
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    max-width: calc(100vw - 20px);
    overflow: visible;
    width: calc(100vw - 20px);
  }

  .forge-quickbar::-webkit-scrollbar {
    display: none;
  }

  /* E — Slim quickbar: 46px instead of 52px, tighter padding */
  .forge-quickbar {
    padding: 6px;
  }

  .forge-slot {
    aspect-ratio: 1;
    height: auto;
    width: 100%;
  }

  /* Drag grip is useless on mobile (quickbar is fixed-position and scrollable) */
  .forge-quickbar__grip {
    display: none;
  }

  /* Drawer: use full width and cap height so it doesn't run under the quickbar */
  .forge-drawer {
    left: 10px;
    max-height: calc(100vh - 230px);
    max-height: calc(100dvh - 230px); /* 154px top + 76px quickbar clearance */
    right: 10px;
    top: 154px;
    transition: top 0.25s ease;
    width: auto;
  }

  #inventoryPanel.is-open {
    border-radius: 0;
    bottom: 0;
    left: 0;
    max-height: none;
    right: 0;
    top: 0;
    width: auto;
  }

  #inventoryPanel.is-open .forge-drawer__head {
    min-height: 58px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }

  #inventoryPanel.is-open .forge-drawer__content {
    max-height: calc(100dvh - 58px);
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
  }

  /* Map: fullscreen on mobile instead of a centered modal */
  #minimapPanel.is-open {
    animation: none;
    border-radius: 0;
    bottom: 0;
    left: 0;
    max-height: none;
    right: 0;
    top: 0;
    transform: none;
    width: auto;
  }

  #minimapPanel.is-open .forge-drawer__head {
    min-height: 58px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }

  #minimapPanel.is-open .forge-drawer__content {
    max-height: calc(100dvh - 58px);
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
  }

  .forge-inventory-page {
    grid-template-columns: 1fr;
  }

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

  .forge-inventory-tabs::-webkit-scrollbar {
    display: none;
  }

  .forge-inventory-tabs button {
    flex: 0 0 auto;
    gap: 8px;
    min-height: 34px;
  }

  .forge-inventory-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .forge-inventory-equipped {
    grid-template-columns: 1fr;
  }

  .forge-inventory-slots {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .forge-inventory-items {
    grid-template-columns: 1fr;
  }
}

/* ── Very narrow screens (≤380px — e.g. iPhone SE) ──────────────── */

@media (max-width: 380px) {
  .forge-quickbar {
    gap: 3px;
  }

  .forge-slot {
    flex: 0 0 44px;
    font-size: 18px;
    height: 44px;
  }
}

/* ── Safe-area insets (notched phones) ───────────────────────────── */

@supports (bottom: env(safe-area-inset-bottom)) {
  .forge-quickbar {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Touch controls (virtual joystick + interact button) ─────────── */

.forge-touch-controls {
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 14;
}

/* Zone covers the bottom-left area where the left thumb rests */
.forge-joystick-zone {
  bottom: 82px;
  height: 200px;
  left: 0;
  pointer-events: auto;
  position: absolute;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  width: 170px;
}

.forge-joystick-zone__ring {
  background:
    radial-gradient(circle, rgba(255, 216, 145, 0.12) 0 34%, transparent 35%),
    radial-gradient(circle, transparent 0 55%, rgba(255, 216, 145, 0.12) 56% 64%, transparent 65%);
  border: 1px solid rgba(255, 216, 145, 0.2);
  border-radius: 50%;
  bottom: 16px;
  height: 132px;
  left: 18px;
  opacity: 0.72;
  position: absolute;
  transition: opacity 0.2s ease, transform 0.2s ease;
  width: 132px;
}

.forge-joystick-zone__hint {
  background: rgba(20, 12, 8, 0.64);
  border: 1px solid rgba(255, 216, 145, 0.18);
  border-radius: 999px;
  bottom: 70px;
  color: rgba(255, 247, 231, 0.82);
  font-size: 11px;
  font-weight: 900;
  left: 56px;
  letter-spacing: 0.08em;
  padding: 4px 9px;
  position: absolute;
  text-transform: uppercase;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.forge-joystick-zone.is-active .forge-joystick-zone__ring {
  opacity: 1;
  transform: scale(1.06);
}

.forge-joystick-zone.is-active .forge-joystick-zone__hint {
  opacity: 0;
  transform: translateY(6px);
}

/* Base appears at the first touch point (opacity toggled by JS) */
.forge-joystick-base {
  background: rgba(255, 216, 145, 0.1);
  border: 2px solid rgba(255, 216, 145, 0.28);
  border-radius: 50%;
  height: 110px;
  left: 0;
  opacity: 0;
  position: absolute;
  top: 0;
  transform: translate(-50%, -50%);
  transition: opacity 0.1s;
  width: 110px;
}

.forge-touch-controls.is-static-joystick .forge-joystick-base {
  left: 50%;
  opacity: 0.78;
  top: 58%;
}

.forge-touch-controls.is-static-joystick .forge-joystick-zone__ring {
  opacity: 0.95;
}

.forge-touch-controls.is-touch-area-hidden .forge-joystick-zone__ring,
.forge-touch-controls.is-touch-area-hidden .forge-joystick-zone__hint {
  opacity: 0;
}

.forge-joystick-knob {
  background: rgba(255, 159, 69, 0.72);
  border: 2px solid rgba(255, 216, 145, 0.82);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  height: 44px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
}

/* Circular interact button, right side above quickbar */
.forge-touch-interact {
  align-items: center;
  background: rgba(255, 159, 69, 0.82);
  border: 2px solid rgba(255, 216, 145, 0.5);
  border-radius: 50%;
  bottom: 90px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: #fff7e7;
  cursor: pointer;
  display: flex;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 900;
  height: 64px;
  justify-content: center;
  line-height: 1;
  pointer-events: auto;
  position: absolute;
  right: 12px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 64px;
}

.forge-touch-interact:active {
  background: rgba(255, 186, 92, 0.95);
  transform: scale(0.9);
}

/* Contextual label: smaller text + brighter border so the button reads as actionable */
.forge-touch-interact.is-labeled {
  border-color: rgba(255, 216, 145, 0.9);
  box-shadow: 0 4px 20px rgba(255, 200, 80, 0.35);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* Map toggle button — thumb-reachable shortcut to open/collapse the minimap */
.forge-touch-map {
  align-items: center;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 200, 120, 0.22);
  border-radius: 50%;
  bottom: 166px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  color: #c9ae7d;
  cursor: pointer;
  display: flex;
  font-size: 1.1rem;
  height: 44px;
  justify-content: center;
  pointer-events: auto;
  position: absolute;
  right: 20px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 44px;
}

.forge-touch-map:active {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  transform: scale(0.9);
}

/* ── Quick panel shortcut buttons (Inventory / Skills) on touch ──── */
.forge-touch-quick {
  align-items: center;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 200, 120, 0.18);
  border-radius: 50%;
  bottom: 166px;   /* default; overridden per-modifier below */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  color: #c9ae7d;
  cursor: pointer;
  display: flex;
  font-size: 0.9rem;
  font-weight: 900;
  height: 40px;
  justify-content: center;
  pointer-events: auto;
  position: absolute;
  right: 72px;     /* left of the E/map column */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 40px;
}

.forge-touch-quick--inv    { bottom: 90px; }
.forge-touch-quick--skills { bottom: 138px; }

.forge-touch-quick:active {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  transform: scale(0.9);
}

@supports (bottom: env(safe-area-inset-bottom)) {
  .forge-joystick-zone {
    bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  }

  .forge-touch-interact {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }

  .forge-touch-map {
    bottom: calc(166px + env(safe-area-inset-bottom, 0px));
  }

  .forge-touch-quick--inv {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }

  .forge-touch-quick--skills {
    bottom: calc(138px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Portrait lock overlay ─────────────────────────────────────────── */

.forge-rotate-overlay {
  align-items: center;
  background: var(--bg);
  display: none;
  flex-direction: column;
  gap: 20px;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  text-align: center;
  z-index: 9999;
}

.forge-rotate-overlay__icon {
  animation: rotate-hint 2s ease-in-out infinite;
  font-size: 3.5rem;
}

.forge-rotate-overlay__text {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0;
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  50%       { transform: rotate(90deg); }
}

/* Only block portrait on narrow phones — tablets (≥768px) have enough width to play */
@media (orientation: portrait) and (hover: none) and (pointer: coarse) and (max-width: 767px) {
  .game-page .forge-rotate-overlay {
    display: flex;
  }
}

/* ── Landscape phones ------------------------------------------------------
   Rotation leaves very little vertical room. Keep the play field dominant,
   hide the global nav, and reserve separate lanes for HUD, controls, quickbar,
   and NPC dialog content. */

@media (orientation: landscape) and (hover: none) and (pointer: coarse) and (max-height: 560px) {
  .game-page .site-nav {
    transform: translateY(-100%);
  }

  .forge-game,
  .forge-game__canvas {
    height: 100dvh;
    min-height: 100svh;
  }

  .forge-hud__top {
    align-items: center;
    gap: 6px;
    left: calc(10px + env(safe-area-inset-left, 0px));
    min-width: 0;
    right: calc(58px + env(safe-area-inset-right, 0px));
    top: max(8px, env(safe-area-inset-top, 0px));
  }

  .forge-stats {
    flex: 1 1 auto;
    gap: 4px;
    max-width: min(560px, calc(100vw - 190px));
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px;
    scrollbar-width: none;
  }

  .forge-stats::-webkit-scrollbar {
    display: none;
  }

  .forge-stat {
    flex: 0 0 42px;
    min-width: 42px;
    padding: 4px;
  }

  .forge-stat em {
    display: none;
  }

  .forge-stat__icon .game-texture-icon {
    height: 17px;
    width: 17px;
  }

  .forge-stat strong {
    font-size: 12px;
  }

  .forge-daytime {
    font-size: 10px;
    letter-spacing: 0.02em;
    padding: 3px 7px;
  }

  .forge-menu-btn {
    min-height: 40px;
    min-width: 40px;
    padding: 7px 10px;
    right: max(10px, env(safe-area-inset-right, 0px));
    top: max(8px, env(safe-area-inset-top, 0px));
  }

  .forge-quest {
    bottom: 84px;
    left: 10px;
    max-width: calc(55vw - 20px);
  }

  .forge-quickbar {
    bottom: max(4px, env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    max-width: min(62vw, 520px);
    overflow: visible;
    padding: 5px;
    width: min(62vw, 520px);
  }

  .forge-slot {
    aspect-ratio: 1;
    font-size: 16px;
    height: auto;
    width: 100%;
  }

  .forge-slot__texture {
    height: 26px;
    width: 26px;
  }

  .forge-slot small,
  .forge-slot b {
    font-size: 8px;
  }

  .forge-joystick-zone {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    height: 132px;
    width: 132px;
  }

  .forge-joystick-zone__ring {
    bottom: 10px;
    height: 104px;
    left: 14px;
    width: 104px;
  }

  .forge-joystick-zone__hint {
    bottom: 55px;
    font-size: 9px;
    left: 43px;
    padding: 3px 7px;
  }

  .forge-joystick-base {
    height: 82px;
    width: 82px;
  }

  .forge-joystick-knob {
    height: 34px;
    width: 34px;
  }

  .forge-touch-interact {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    font-size: 1.1rem;
    height: 48px;
    right: max(12px, env(safe-area-inset-right, 0px));
    width: 48px;
  }

  .forge-touch-interact.is-labeled {
    font-size: 0.7rem;
  }

  /* Map button must sit above the (56px+56px=112px) interact button with a gap */
  .forge-touch-map {
    bottom: calc(118px + env(safe-area-inset-bottom, 0px));
    height: 36px;
    right: max(19px, calc(env(safe-area-inset-right, 0px) + 7px));
    width: 36px;
  }

  /* Quick panel buttons in landscape: smaller, sit at same level as interact / map */
  .forge-touch-quick {
    font-size: 0.8rem;
    height: 34px;
    right: max(70px, calc(env(safe-area-inset-right, 0px) + 58px));
    width: 34px;
  }

  .forge-touch-quick--inv {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .forge-touch-quick--skills {
    bottom: calc(106px + env(safe-area-inset-bottom, 0px));
  }

  .forge-dialog {
    align-items: stretch;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.04) 0%, rgba(0, 0, 0, 0.42) 45%, rgba(0, 0, 0, 0.72) 100%);
    justify-content: flex-end;
    padding:
      max(8px, env(safe-area-inset-top, 0px))
      max(8px, env(safe-area-inset-right, 0px))
      max(8px, env(safe-area-inset-bottom, 0px))
      max(8px, env(safe-area-inset-left, 0px));
  }

  .forge-dialog__panel {
    align-content: start;
    align-items: start;
    gap: 8px 10px;
    grid-template-columns: 46px minmax(0, 1fr);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 132px);
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 10px 46px 10px 10px;
    width: min(640px, calc(100vw - 152px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  }

  .forge-dialog__portrait {
    height: 46px;
    width: 46px;
  }

  .forge-dialog__portrait-icon {
    height: 38px;
    width: 38px;
  }

  .forge-dialog__copy {
    min-width: 0;
    padding-right: 0;
  }

  .forge-dialog__role {
    font-size: 9px;
    letter-spacing: 0.08em;
  }

  .forge-dialog__copy h2 {
    font-size: 16px;
    margin: 1px 0 4px;
  }

  .forge-dialog__copy p {
    font-size: 12px;
    line-height: 1.35;
  }

  .forge-dialog__choices {
    align-content: start;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    grid-column: 1 / -1;
    max-height: min(32dvh, 118px);
    overflow-y: auto;
    padding-right: 2px;
  }

  .forge-dialog__choice {
    border-radius: 7px;
    flex: 1 1 142px;
    font-size: 11px;
    min-height: 34px;
    padding: 7px 9px;
  }

  .forge-dialog__close {
    height: 36px;
    right: 8px;
    top: 8px;
    width: 36px;
  }
}

@supports (bottom: env(safe-area-inset-bottom)) {
  @media (orientation: landscape) and (hover: none) and (pointer: coarse) and (max-height: 560px) {
    .forge-quickbar {
      bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    }
  }
}

/* Drawer on landscape phones: start below the compact HUD, leave quickbar clearance.
   Quickbar top edge ≈ 62px from bottom in this layout; top is 118px.
   Max safe height = dvh - 118 (top) - 70 (bottom clearance) = dvh - 188. */
@media (orientation: landscape) and (hover: none) and (pointer: coarse) and (max-height: 560px) {
  .forge-drawer {
    max-height: calc(100vh - 126px);
    max-height: calc(100dvh - 126px);
    top: max(56px, calc(env(safe-area-inset-top, 0px) + 48px));
  }

  .forge-drawer__head {
    margin-bottom: 8px;
  }

  .forge-drawer h2 {
    font-size: 14px;
  }

  .forge-grid {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }

  .forge-item,
  .forge-shop-item {
    padding: 9px;
  }
}

/* ── Forge & Pray — Agreement & Login Gate Modals (moved from site.css) ── */
.fnp-modal {
  align-items: center;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 1100;
}

.fnp-modal__panel {
  background: #1a1410;
  border: 1px solid rgba(255, 216, 145, 0.18);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  max-width: 440px;
  padding: 40px 36px 32px;
  text-align: center;
  width: 100%;
}

.fnp-modal__icon {
  font-size: 40px;
  margin-bottom: 14px;
}

.fnp-modal__title {
  color: #ffd891;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 12px;
}

.fnp-modal__body {
  color: rgba(255, 255, 255, 0.70);
  font-size: 14px;
  line-height: 1.65;
  margin: 0 0 16px;
}

.fnp-modal__body a {
  color: #ffd891;
}

.fnp-modal__note {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 24px;
  padding: 10px 14px;
}

.fnp-modal__note a {
  color: #ffd891;
}

.fnp-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.fnp-modal__dismiss {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.32);
  cursor: pointer;
  display: block;
  font-size: 13px;
  margin: 14px auto 0;
  padding: 4px;
  text-decoration: underline;
}

.fnp-modal__dismiss:hover {
  color: rgba(255, 255, 255, 0.54);
}

.fnp-modal__footer-links {
  color: rgba(255, 255, 255, 0.35);
  font-size: 13px;
  margin: 16px 0 0;
}

.fnp-modal__footer-links a {
  color: #ffd891;
}

/* Ghost button used in modals */
.forge-btn-ghost {
  align-items: center;
  background: transparent;
  border: 1px solid rgba(255, 216, 145, 0.35);
  border-radius: 8px;
  color: #ffd891;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
  padding: 10px 22px;
  text-decoration: none;
  transition: background 0.15s;
}

.forge-btn-ghost:hover {
  background: rgba(255, 216, 145, 0.08);
}

/* Demo badge shown next to location label in HUD */
.fnp-demo-badge {
  background: rgba(226, 75, 74, 0.18);
  border: 1px solid rgba(226, 75, 74, 0.40);
  border-radius: 99px;
  color: #e24b4a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  text-transform: uppercase;
}

/* "Create a free account" note on the start screen */
.forge-start__note {
  color: rgba(255, 255, 255, 0.40);
  font-size: 13px;
  margin-top: 12px;
}

.forge-start__note a {
  color: #ffd891;
}
