/* Reset & base --------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #0b0c10;
  color: #f4f4f4;
}

/* Layout --------------------------------------------------------------- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: .7rem;
}

h1,
h2 {
  margin-top: .2rem;
  margin-bottom: 0;
  font-weight: 600;
}

h1 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.1rem;
}

/* Form ----------------------------------------------------------------- */
form {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: .5rem;
  margin-top: .1rem;
  margin-bottom: .1rem;
  border-radius: 0.5rem;
  background: #151720;
  border: 1px solid #23253a;
  box-shadow: inset 0px 0px 5px 0px rgb(40, 40, 40);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.9rem;
}

input[type="text"],
input[type="number"] {
  padding: 0.5rem 0.6rem;
  border-radius: 0.45rem;
  border: 1px solid #3b3f5c;
  background: #0f111a;
  color: #f4f4f4;
  font-size: 1rem;
}

input:focus {
  outline: none;
  border-color: #5d7bff;
}

.floor-row {
  padding-top: .2rem;
  display: flex;
  flex-wrap: wrap;
}

.floor-label {
  flex: 1 1 0;
}

.seed-input-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 2.25rem;
}

/* Seed input stretches, buttons stay fixed size */
.seed-input-row #seed {
  flex: 1 1 auto;
  height: 100%;
}

/* Square, matching buttons with centered icons */
.clear-seed-btn,
.paste-seed-btn {
  margin-top: 0;
  width: 2rem;
  /* square */
  height: 2rem;
  /* square */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  /* icon size */
  line-height: 1;
  min-width: 0;
  /* don't inherit big min-width from button defaults */
}

/* Buttons -------------------------------------------------------------- */

button {
  padding: 0.6rem 0.9rem;
  border-radius: 0.45rem;
  border: none;
  background: #5d7bff;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: -1px 1px 1px 1px rgba(0, 0, 0, 0.45), inset 0 0px 3px 1px rgba(0, 0, 0, 0.45);
}

button:hover:not(:disabled) {
  opacity: 0.9;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

.button-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}


.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #23253a;
  background: #5d7bff;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  z-index: 1000;
}

/* Slightly smaller + tighter on very small screens */
@media (max-width: 480px) {
  .back-to-top {
    right: 2rem;
    bottom: 2rem;
    padding: 1rem 1rem;
    font-size: 1rem;
    min-width: 100px;
  }
}

/* Loading spinner ------------------------------------------------------ */

.loading {
  margin: 0.5rem 0 1rem;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #c0c4ff;
}

.loading::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  border: 2px solid #c0c4ff;
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

.loading.hidden {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Tabs ----------------------------------------------------------------- */
.sticky-tabs-container {
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;

  position: sticky;
  top: 4.85rem;

  /* height of header + padding */
  z-index: 19;

  padding-top: .25rem;
  padding-bottom: .25rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  height: 3rem;
  padding: .3rem .5rem;
  border-radius: .75rem;
}

.tab-button {
  flex: 1 1 0;
  border-radius: .5rem;
  background: #111321;
  color: #c4c6ff;
  font-size: 0.9rem;
  box-shadow: inset 0px 0px 3px 1px rgb(31, 33, 70);
}

.tab-button.active {
  border-radius: .5rem;
  background: #5d7bff;
  border-color: #5d7bff;
  color: #fff;
  box-shadow: inset 0px 0px 3px 1px rgb(58, 61, 118);
}

/* Output Sections ------------------------------------------------------ */

.output-section {
  padding: 0.4rem;
  border-radius: 0.75rem;
  background: #151720;
  border: 1px solid #23253a;
  margin-bottom: 1rem;
  box-shadow: inset 0px 0px 5px 0px rgb(40, 40, 40);

}

.hidden {
  display: none;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  background: #0f111a;
  padding: 0 0.5rem;
  border-radius: 0.75rem;
  max-height: 60vh;
  overflow: auto;
}

/* Summary Table -------------------------------------------------------- */

.summary-category {
  margin-bottom: 0.3rem;
}

.summary-category h3 {
  margin: 0 0 0.35rem 0;
  font-size: 0.95rem;
}

.summary-category-header {
  margin: 0 0 0.2rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* hide default marker */
.summary-category-header::-webkit-details-marker {
  display: none;
}

/* arrow icon */
.summary-arrow::before {
  display: inline-block;
  font-size: 0.8rem;
}

/* closed: up/side arrow */
.summary-category:not([open]) .summary-arrow::before {
  content: "➕";
}

/* open: down arrow */
.summary-category[open] .summary-arrow::before {
  content: "➖";
}

.summary-category-body {
  margin-top: 0.1rem;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  background: #0f111a;
  border-radius: 0.5rem;
  overflow: hidden;
}

.summary-table th,
.summary-table td {
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid #23253a;
  vertical-align: top;
}

.summary-table tr:last-child td {
  border-bottom: none;
}

.summary-table thead {
  background: #171a2a;
}

.summary-table th {
  font-weight: 600;
}

.rune-col {
  width: 10%;
  white-space: nowrap;
}

.item-col {
  width: 40%;
}

.count-col {
  width: 6%;
  text-align: right;
}

.loc-col {
  width: 44%;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Floors view ---------------------------------------------------------- */

.prefloor-block h3 {
  margin: 0 0 0.25rem 0;
  font-size: 0.9rem;
}

.prefloor-block pre {
  max-height: 12rem;
}

.prefloor-label {
  margin: 0 0 0.35rem 0;
  font-size: 0.75rem;
}

.floor-box {
  margin-top: 0.2rem;
  padding-bottom: 2rem;
  padding: 0.6rem;
  border-radius: 0.5rem;
  background: #0f111a;
  border: 1px solid #23253a;
  box-shadow: inset 0px 0px 1px 1px rgb(23, 30, 47);
}

.floor-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
  gap: 0.2rem;
  font-size: 0.9rem;
}

.floor-feeling {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Pager --------------------------------------------------------------- */
.sticky-pager-container {
  position: sticky;
  bottom: 0;
  z-index: 19;
  background: #151720;
  padding-top: .25rem;
  padding-bottom: .25rem;
}


.pager {
  margin: .2rem 0rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  justify-content: center;
}

.pager-btn {
  padding-inline: 0.5rem;
  min-width: 2rem;
  box-shadow: inset 0px 0px 5px 0px rgb(23 48 50);
}

.pager-center {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-inline: 0.25rem;
}

.pager-center label {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}

#currentFloorInput {
  width: 3.2rem;
  padding: 0.25rem 0.4rem;
  font-size: 1rem;
}

.floor-range-label {
  font-size: 0.8rem;
  opacity: 0.85;
}

/* Recent seed chips ---------------------------------------------------- */

.chip-row {
  display: flex;
  flex-wrap: nowrap;
  /* 🔒 always one row */
  gap: 0.1rem;
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  height: 1rem;
  /* 🔒 row height ~1rem */
  align-items: center;
  /* center chips vertically in the row */
  overflow-x: auto;
  /* allow horizontal scroll on tiny screens */
}

.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.4rem;
  height: 0.9rem;
  border-radius: 999px;
  border: 1px solid #3b3f5c;
  background: #111321;
  color: #d0d2ff;
  font-size: 0.6rem;
  cursor: pointer;
  margin-top: 0 !important;
  white-space: nowrap;
}

.chip:hover {
  background: #222545;
}

/* Item css ------------------------------------------------------------ */
.enhancement-text {
  font-weight: 600;
  color: #5790f4;
}

.upgrade-text {
  font-weight: 600;
  color: #e8dd89;
}

.upgrade-text-1 {
  font-weight: 600;
  color: #e8dd89;
}

.upgrade-text-2 {
  font-weight: 600;
  color: #e8d43e;
}

.upgrade-text-3 {
  font-weight: 600;
  color: #5aca54;
}

.upgrade-text-4-plus {
  font-weight: 600;
  color: #187101;
}

.curse-text {
  font-weight: 600;
  color: #861111;
}

/* Pixel font for sidebar counts --------------------------------------- */
@font-face {
  font-family: "DungeonPixel";
  src: url("/assets/fonts/pixel_font.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Page layout with sidebars ------------------------------------------- */

.page-layout {
  display: grid;
  grid-template-columns: auto minmax(0, 640px) auto;
  align-items: flex-start;
}

.sidebar {
  position: sticky;
  top: 0.75rem;
  align-self: flex-start;
  padding-top: 0.5rem;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.sidebar-empty {
  opacity: 0.25;
}

.sidebar-left {
  justify-self: end;
}

.sidebar-right {
  justify-self: start;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hide sidebars on very small screens to keep content readable */
@media (max-width: 780px) {

  /* .page-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  } */
  .sidebar-left {
    max-width: 32px;
  }

  .sidebar-right {
    max-width: 32px;
  }

  .container {
    max-width: 100%;
    padding: 0.5rem 0.2rem;
  }
}

/* Sprite base classes -------------------------------------------------- */

.sprite {
  image-rendering: pixelated;
  background-repeat: no-repeat;
}

/* Composite item icons used in sidebars ------------------------------- */

.item-icon-wrapper {
  position: relative;
  width: 32px;
  /* unchanged */
  height: 32px;
  /* unchanged */
}

.item-icon-base {
  position: absolute;
  inset: 0;
}

/* overlay: still bottom-right */
.item-icon-overlay {
  position: absolute;
  right: 1px;
  bottom: 1px;
  pointer-events: none;
}

/* count: move to top-left */
.item-icon-count {
  position: absolute;
  left: -3px;
  top: -4px;
  right: auto;
  /* override any old right value */
  padding: 0 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-family: "DungeonPixel", ui-monospace, monospace;
  font-size: 0.75rem;
  line-height: 1;
}

/* 🔹 Pinned header (seed input always visible) */
.pinned-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 0.25rem 0;
}

.pinned-header>label {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #151720;
  border-radius: .5rem;
  border-bottom: 1px solid #23253a;
  padding: .5rem .75rem;
  box-shadow: inset 0px 0px 5px 0px rgb(40, 40, 40);
}

/* Square seed control buttons */
.seed-input-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 2.25rem;
}

.seed-input-row #seed {
  flex: 1;
  height: 100%;
}

.clear-seed-btn,
.paste-seed-btn {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  border-radius: 0.45rem;
}

.clear-seed-btn .button-content,
.paste-seed-btn .button-content {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}