body {
    font-family: Arial, sans-serif;
   }

.rarity {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 20px;
    text-indent: 0px;
}

.italic {
  font-style: italic;
}

.output-line {
  margin: 5px 0; /* Uniform vertical margin */
  line-height: 1.2; /* Optional: Adjust line height */
}

input[type="number"] {
    width: 50px;
}

.Common { color: black; }
.Uncommon { color: green; }
.Rare { color: blue; }
.Very.Rare { color: purple; }
.Legendary { color: orange; }

.input-container {
  display: flex;
  align-items: center;
  gap: 20px;
}

.input-container label {
  margin-right: 10px;
}

.item-result {
  background-color: #fff5e6; /* light parchment */
  border-left: 5px solid #8d4b00;
  padding: 0px 0px 0px 10px; /* top, right, bottom, left */
  margin-top: 10px;
  text-align: left;
}

.parchment-bg {
  background:
    #f4ecd8 url('https://cdn.pixabay.com/photo/2015/06/19/21/24/old-814651_960_720.jpg') center center / cover no-repeat;
  color: #2e2b20; /* Dark text for contrast */
  font-family: 'Georgia', serif;
  border: 1px solid #a68b5b;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

#placeholder-text {
  color: #3f29008f;
  font-style: italic;
  font-size: 2rem;
  text-align: center;
  padding: 0;
  min-height: inherit;

  display: flex;
  align-items: center;
  justify-content: center;
}

.add-button {
  font-size: 1.25rem;
  font-weight: bold;
}

/* Prevent generated item text from exceeding the screen */
#result,
.output-box,
.item-result,
.output-line {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.output-line,
.output-line span {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Tooltip trigger text */
.mastery-tooltip-container,
.property-tooltip-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
  cursor: help;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.mastery-tooltip-container {
  color: #065be4;
}

.property-tooltip-container {
  color: #3b82f6;
}

/* Shared tooltip styling */
.mastery-tooltip-container .tooltip-text,
.property-tooltip-container .tooltip-text {
  visibility: hidden;
  opacity: 0;

  position: absolute;
  z-index: 9999;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);

  width: max-content;
  max-width: min(600px, calc(100vw - 2rem));
  min-width: min(280px, calc(100vw - 2rem));

  background-color: #1f2937;
  color: #fff;
  text-align: left;
  border-radius: 8px;
  padding: 12px 16px;

  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;

  font-size: 0.875rem;
  line-height: 1.4;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s ease;
}

/* Desktop hover and keyboard focus */
.mastery-tooltip-container:hover .tooltip-text,
.property-tooltip-container:hover .tooltip-text,
.mastery-tooltip-container:focus .tooltip-text,
.property-tooltip-container:focus .tooltip-text,
.mastery-tooltip-container:focus-within .tooltip-text,
.property-tooltip-container:focus-within .tooltip-text,
.mastery-tooltip-container.tooltip-open .tooltip-text,
.property-tooltip-container.tooltip-open .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Phone layout: lock tooltip inside viewport */
@media (max-width: 640px) {
  .mastery-tooltip-container .tooltip-text,
  .property-tooltip-container .tooltip-text {
    position: fixed;

    left: var(--tooltip-left, 1rem);
    top: var(--tooltip-top, 1rem);
    right: auto;
    bottom: auto;

    width: min(22rem, calc(100vw - 2rem));
    min-width: 0;
    max-width: calc(100vw - 2rem);
    max-height: 45vh;

    transform: none;
    overflow-y: auto;
  }
}

.result-box {
  line-height: 1;
  text-indent: 2px;
  min-height: 610px;
}

/* iPad vertical / tablet portrait */
@media (max-width: 1100px) and (orientation: portrait) {
  .result-box {
    min-height: 700px;
  }
}

/* phones */
@media (max-width: 640px) {
  .result-box {
    min-height: 360px;
  }
}