/*
  LoreRim Alchemy Book - Alpha CSS
  Cleaned to remove duplicate overwritten declarations and consolidate repeated responsive blocks.
  Requires:
    assets/cover.png
    assets/book-frame.png
*/

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: Georgia, serif;
  background: radial-gradient(circle, #2b2118, #120d09);
}

/* ===== APP LAYOUT ===== */

.app {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 1.5vmin, 24px);
  overflow: hidden;
}

/* ===== BOOK SHELL ===== */

.book {
  position: relative;

  width: min(94vw, calc(92vh * 1.7));
  height: min(92vh, calc(94vw / 1.7));

  transition: width 0.35s ease, height 0.35s ease;
}

.book.closed {
  width: min(42vw, calc(86vh * 0.72));
  height: min(86vh, calc(42vw / 0.72));
}

/* ===== COVER ===== */

.book-cover {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  overflow: hidden;
  cursor: pointer;

  border: none;
  border-radius: 18px;
  background-image: url("../assets/cover.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  color: #f3dfb4;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.75);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.book-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, transparent 45%, rgba(0, 0, 0, 0.35) 100%),
    linear-gradient(to bottom, rgba(255, 180, 60, 0.08), rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.book-cover:hover {
  transform: scale(1.01);
  filter: brightness(1.08);
}

.cover-click-text {
  position: absolute;
  left: 50%;
  bottom: 34px;
  z-index: 2;
  transform: translateX(-50%);

  color: #d8b46a;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px #000;
  opacity: 0.85;
}

/* ===== BOOK INTERIOR ===== */

.book-inside {
  display: none;
  position: relative;
  width: 100%;
  height: 100%;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 2.1% 7.2% 2% 5.5%;
  border-radius: 18px;
  background: linear-gradient(90deg, #3a2415, #1c120c 50%, #3a2415);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  perspective: 1800px;
  overflow: hidden;
}


.book.open .book-cover {
  display: none;
}

.book.open .book-inside {
  display: grid;
}

/* ===== PAGES ===== */

.page {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  z-index: 10;
  display: flex;
  justify-content: center;
}

.book-frame-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: url("../assets/book-frame.png") center / cover no-repeat;
  pointer-events: none;
}

.left-page {
  border-radius: 14px 4px 4px 14px;
  transform: perspective(1400px) rotateY(0.6deg);
  transform-origin: right center;
  justify-content: flex-end;
}

.right-page {
  min-height: 0;
  overflow: hidden !important;
  border-radius: 4px 14px 14px 4px;
  transform: perspective(1400px) rotateY(-0.6deg);
  transform-origin: left center;
  justify-content: flex-start;
}

.page-inner {
  position: relative;
  z-index: 20;
  width: 98%;
  height: 100%;

  padding:
    clamp(1.2rem, 2.2vh, 2rem)
    clamp(1rem, 1.5vw, 1.75rem)
    clamp(0.8rem, 1.5vh, 1.5rem);

  overflow-y: auto;
}

.right-page .page-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden !important;
  background:
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.08),
      transparent 8%,
      transparent 92%,
      rgba(0, 0, 0, 0.08)
    ),
    #efe0b5;
  box-shadow:
    inset 10px 0 18px rgba(35, 18, 8, 0.12),
    inset 0 0 24px rgba(80, 48, 18, 0.18);
}

.left-page .page-inner {
  background:
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.08),
      transparent 8%,
      transparent 92%,
      rgba(0, 0, 0, 0.08)
    ),
    #ead6a6;
  box-shadow:
    inset -10px 0 18px rgba(35, 18, 8, 0.12),
    inset 0 0 24px rgba(80, 48, 18, 0.18);
}

.page h2 {
  margin-top: 0;
  font-size: clamp(1.4rem, 2.2vw, 2.2rem);
}

.page p {
  font-size: clamp(1rem, 1.25vw, 1.25rem);
  line-height: 1.5;
}

.page-inner h2 {
  position: relative;
  margin-bottom: 18px;
  padding-bottom: 10px;
}

.page-inner h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    to right,
    rgba(90, 55, 24, 0.6),
    rgba(90, 55, 24, 0.3),
    rgba(90, 55, 24, 0.6)
  );
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* ===== PAGE TEXTURING ===== */

.page-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 25% 30%, rgba(0, 0, 0, 0.06), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(0, 0, 0, 0.05), transparent 60%),
    repeating-linear-gradient(
      0deg,
      rgba(60, 30, 10, 0.035),
      rgba(60, 30, 10, 0.035) 1px,
      transparent 1px,
      transparent 4px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(80, 50, 20, 0.02),
      rgba(80, 50, 20, 0.02) 2px,
      transparent 2px,
      transparent 6px
    );
}

.page-inner::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at top, rgba(65, 35, 12, 0.18), transparent 22%),
    radial-gradient(ellipse at bottom, rgba(65, 35, 12, 0.20), transparent 24%),
    linear-gradient(
      to right,
      rgba(70, 38, 14, 0.16),
      transparent 10%,
      transparent 90%,
      rgba(70, 38, 14, 0.16)
    );
}

.left-page .page-inner::after {
  background:
    radial-gradient(ellipse at top, rgba(65, 35, 12, 0.12), transparent 22%),
    radial-gradient(ellipse at bottom, rgba(65, 35, 12, 0.12), transparent 24%),
    linear-gradient(
      to right,
      rgba(70, 38, 14, 0.08),
      transparent 12%,
      transparent 82%,
      rgba(20, 10, 4, 0.10)
    );
}

.right-page .page-inner::after {
  background:
    radial-gradient(ellipse at top, rgba(65, 35, 12, 0.12), transparent 22%),
    radial-gradient(ellipse at bottom, rgba(65, 35, 12, 0.12), transparent 24%),
    linear-gradient(
      to right,
      rgba(20, 10, 4, 0.10),
      transparent 18%,
      transparent 88%,
      rgba(70, 38, 14, 0.08)
    );
}

/* ===== PAGE TURN OVERLAY ===== */

.page-flip-overlay {
  position: absolute;
  top: clamp(14px, 2vw, 34px);
  bottom: clamp(14px, 2vw, 34px);
  z-index: 200;
  width: calc((100% - (2 * clamp(14px, 2vw, 34px))) / 2);
  pointer-events: none;
  opacity: 0;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  background: linear-gradient(
    to right,
    rgba(255, 248, 220, 0.85),
    rgba(205, 175, 115, 0.95)
  );
  box-shadow:
    inset 0 0 35px rgba(80, 45, 15, 0.25),
    0 0 30px rgba(0, 0, 0, 0.35);
}

.page-flip-overlay.flip-next {
  right: clamp(14px, 2vw, 34px);
  transform-origin: left center;
  animation: flipNext 0.7s ease forwards;
}

.page-flip-overlay.flip-prev {
  left: clamp(14px, 2vw, 34px);
  transform-origin: right center;
  animation: flipPrev 0.7s ease forwards;
}

@keyframes flipNext {
  0% {
    opacity: 1;
    transform: rotateY(0deg);
  }

  45% {
    opacity: 1;
    box-shadow:
      inset 25px 0 45px rgba(0, 0, 0, 0.25),
      -12px 0 28px rgba(0, 0, 0, 0.35);
  }

  100% {
    opacity: 0;
    transform: rotateY(-180deg);
  }
}

@keyframes flipPrev {
  0% {
    opacity: 1;
    transform: rotateY(0deg);
  }

  45% {
    opacity: 1;
    box-shadow:
      inset -25px 0 45px rgba(0, 0, 0, 0.25),
      12px 0 28px rgba(0, 0, 0, 0.35);
  }

  100% {
    opacity: 0;
    transform: rotateY(180deg);
  }
}

/* ===== PAGE CORNER NAVIGATION ===== */

.nav-btn {
  position: absolute;
  top: 0;
  z-index: 250;
  width: clamp(44px, 4vw, 64px);
  height: clamp(44px, 4vw, 64px);
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  background: #e6cf9e;
  color: #2a1b10;
  font-family: Georgia, serif;
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
  opacity: 0.85;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.nav-btn.left {
  left: 0;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.nav-btn.right {
  right: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.nav-btn:hover:not(:disabled) {
  opacity: 1;
  filter: brightness(1.08);
}

.nav-btn span {
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.45);
}

.nav-btn.left span {
  transform: translate(-8px, -8px);
}

.nav-btn.right span {
  transform: translate(8px, -8px);
}

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

/* ===== SHARED INPUTS / DROPDOWNS ===== */

.custom-dropdown {
  position: relative;
  width: 80%;
  max-width: 420px;
  flex-shrink: 0;
}

.book-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(70, 45, 20, 0.5);
  border-radius: 10px 10px 0 0;
  background: rgba(255, 248, 220, 0.85);
  font-family: inherit;
  font-size: 1.05rem;
  text-align: center;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.book-input:hover,
.book-input:focus {
  background: rgba(255, 248, 220, 1);
}

.book-input:focus {
  outline: none;
  border-color: rgba(120, 75, 30, 0.7);
  box-shadow:
    0 0 6px rgba(95, 58, 26, 0.4),
    0 0 12px rgba(73, 107, 53, 0.25);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 9999;
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid rgba(70, 45, 20, 0.45);
  border-radius: 8px;
  background: #ead8aa;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.dropdown-menu.show {
  display: block;
}

.dropdown-option {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-bottom: 1px solid rgba(70, 45, 20, 0.18);
  background: transparent;
  color: #2a1b10;
  font-family: Georgia, serif;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}

.dropdown-option:hover {
  background: rgba(90, 55, 25, 0.16);
}

/* ===== Page 3 - Potion Builder ===== */

.potion-builder-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: visible;
}

.potion-builder-panel h2 {
  margin-top: 0;
  margin-bottom: clamp(10px, 1.5vh, 18px);
  padding-bottom: 10px;
  text-align: left;
  letter-spacing: 0;
  text-transform: none;
  border-bottom: 2px solid rgba(80, 45, 15, 0.45);
}

.potion-result-box {
  width: 100%;
  height: clamp(150px, 24vh, 260px);
  margin-bottom: clamp(0.45rem, 1vh, 0.75rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border: 1px solid rgba(70, 45, 20, 0.35);
  border-radius: 12px;
  background:
    radial-gradient(circle at center, rgba(0, 0, 0, 0.06), transparent 70%),
    rgba(255, 248, 220, 0.35);
  text-align: center;
  box-shadow:
    inset 0 0 25px rgba(80, 48, 18, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.15);
}

.potion-result-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.generated-potion-name {
  margin-bottom: 6px;
  font-size: clamp(22px, 1.8vw, 28px);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.shared-effects-box {
  min-height: clamp(20px, 3vh, 30px);
  margin-bottom: 8px;
  font-size: clamp(13px, 0.95vw, 15px);
}

.save-potion-btn {
  width: 100%;
  margin-top: 12px;
  padding: 0.6rem 0;
  border: none;
  border-top: 2px solid rgba(90, 55, 24, 0.4);
  border-radius: 0 0 10px 10px;
  background: #3a2415;
  color: #ead8b3;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
}

.save-potion-btn:hover {
  background: #4b2f1b;
  transform: translateY(-1px);
}

.potion-builder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  overflow: visible;
}

.potion-ingredient-stack {
  position: relative;
  isolation: isolate;
  width: clamp(420px, 78%, 620px);
  margin-top: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: visible !important;
  border: 2px solid rgba(90, 55, 24, 0.5);
  border-radius: 6px;
  background: rgba(255, 248, 220, 0.45);
  box-shadow:
    inset 0 0 20px rgba(90, 55, 24, 0.15),
    0 4px 10px rgba(0, 0, 0, 0.15);
}

.potion-ingredient-card {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: clamp(58px, 7vh, 78px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(6px, 0.7vw, 10px);
  overflow: visible !important;
  border: none;
  background: transparent;
  text-align: center;
  box-shadow: none;
}

.potion-ingredient-card + .potion-ingredient-card {
  border-top: 1px solid rgba(90, 55, 24, 0.35);
}

.potion-ingredient-card:focus-within {
  z-index: 1000;
}

.potion-ingredient-card label,
.potion-notes-card label {
  text-align: center;
  font-size: clamp(14px, 1vw, 17px);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(90, 55, 24, 0.35);
}

.potion-ingredient-card label {
  display: block;
  margin-bottom: clamp(5px, 0.8vh, 8px);
  padding-bottom: 4px;
}

.potion-ingredient-card .custom-dropdown {
  width: clamp(220px, 70%, 340px);
  max-width: 340px;
  margin: 0 auto;
  z-index: 2;
  overflow: visible;
}

.potion-ingredient-card:focus-within .custom-dropdown {
  z-index: 1001;
}

.potion-ingredient-card .book-input {
  width: 100%;
  margin: 0 auto;
}

.potion-ingredient-card .dropdown-menu {
  max-height: clamp(120px, 18vh, 180px);
  z-index: 1002;
}

.potion-notes-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(6px, 0.7vw, 10px);
  border-top: 1px solid rgba(90, 55, 24, 0.35);
}

.potion-notes-card label {
  margin-bottom: clamp(3px, 0.5vh, 6px);
  padding-bottom: 2px;
}

.potion-notes-input {
  width: clamp(220px, 70%, 340px);
  min-height: clamp(38px, 5vh, 58px);
  resize: vertical;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(70, 45, 20, 0.5);
  border-radius: 10px;
  background: rgba(255, 248, 220, 0.85);
  color: #2a1b10;
  font-family: inherit;
  font-size: 0.95rem;
  text-align: center;
}

/* ===== Page 4 - Potion Database ===== */

#leftPageContent,
#rightPageContent {
  height: 100%;
}

#rightPageContent {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.potion-database-panel {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex !important;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden !important;
}

.potion-database-panel h2 {
  flex: 0 0 auto;
  margin-top: 0;
  margin-bottom: 0;
  padding-bottom: 10px;
  text-align: left;
}

.potion-database-controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.65rem;
  border: 1px solid rgba(70, 45, 20, 0.35);
  border-radius: 10px 10px 0 0;
  background: rgba(255, 248, 220, 0.35);
}

.potion-database-controls .book-input,
.database-filter-select {
  height: 36px;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(70, 45, 20, 0.5);
  border-radius: 8px;
  background: rgba(255, 248, 220, 0.85);
  color: #2a1b10;
  font-family: Georgia, serif;
  font-size: 0.95rem;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.database-filter-select {
  min-width: 120px;
  min-height: 38px;
  text-align: center;
  cursor: pointer;
}

.database-filter-select:focus,
.potion-database-controls .book-input:focus {
  outline: none;
  border-color: rgba(120, 75, 30, 0.7);
  background: rgba(255, 248, 220, 1);
}

.database-action-buttons {
  display: flex;
  gap: 0.35rem;
}

.database-action-buttons button {
  height: 36px;
  padding: 0 0.7rem;
  border: 1px solid rgba(70, 45, 20, 0.5);
  border-radius: 8px;
  background: rgba(255, 248, 220, 0.85);
  color: #2a1b10;
  font-family: Georgia, serif;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: all 0.15s ease;
}

.database-action-buttons button:hover {
  background: rgba(255, 248, 220, 1);
}

.database-action-buttons button:active {
  transform: translateY(1px);
}

.potion-database-list {
  flex: 1 1 auto;
  height: 0;
  min-height: 0;
  padding: 0.75rem 0.5rem 0.75rem 0.75rem;
  overflow-y: auto !important;
  overflow-x: hidden;
  border: 1px solid rgba(70, 45, 20, 0.35);
  border-top: none;
  border-radius: 0 0 10px 10px;
  background: rgba(255, 248, 220, 0.35);
}

.database-empty-state {
  height: 100%;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-style: italic;
  opacity: 0.75;
}

.saved-potion-card,
.potion-card {
  position: relative;
  padding: 0.75rem 2.5rem 0.75rem 2rem;
  margin-bottom: 0.65rem;
  border: 1px solid rgba(90, 63, 34, 0.45);
  border-left: 4px solid rgba(70, 90, 45, 0.75);
  border-radius: 10px;
  background: rgba(255, 248, 220, 0.45);
  box-shadow:
    inset 0 0 8px rgba(80, 48, 18, 0.12),
    0 2px 6px rgba(30, 20, 12, 0.18);
}

.saved-potion-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.saved-potion-card p {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

.saved-potion-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.saved-potion-header h3 {
  flex: 1;
  margin: 0;
}

.saved-potion-content h3 {
  padding-right: 1.8rem;
}

.potion-select-checkbox {
  position: absolute;
  top: 0.85rem;
  left: 0.6rem;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.favorite-potion-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: rgba(90, 63, 34, 0.5);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease, text-shadow 0.15s ease;
}

.favorite-potion-btn:hover {
  color: #b8860b;
  transform: scale(1.15);
}

.saved-potion-card.favorited {
  background: rgba(232, 205, 126, 0.25);
  border-color: rgba(216, 162, 29, 0.65);
  box-shadow:
    0 2px 6px rgba(30, 20, 12, 0.15),
    0 0 8px rgba(224, 184, 79, 0.25);
}

/* ===== Page 5 - Ingredient Lookup ===== */

.ingredient-lookup-panel {
  align-content: start;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(300px, 46%) auto;
  gap: 1.2rem;
}

.ingredient-lookup-panel h2 {
  margin-top: 0;
  margin-bottom: 18px;
  padding-bottom: 10px;
  text-align: left;
}

.ingredient-image-box {
  width: 100%;
  height: 100%;
  min-height: 300px;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(70, 45, 20, 0.35);
  border-radius: 12px;
  background:
    radial-gradient(circle at center, rgba(0, 0, 0, 0.06), transparent 70%),
    rgba(255, 248, 220, 0.35);
  font-style: italic;
  opacity: 0.9;
  box-shadow:
    inset 0 0 25px rgba(80, 48, 18, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.15);
}

.ingredient-image-box img {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.ingredient-search-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 1.2rem;
  padding: 0.6rem;
  border: 1px solid rgba(70, 45, 20, 0.35);
  border-radius: 12px;
  background: rgba(255, 248, 220, 0.55);
  box-shadow: inset 0 0 12px rgba(80, 48, 18, 0.15);
}

.ingredient-search-label {
  margin-bottom: 0.4rem;
  font-size: 1rem;
  font-weight: bold;
  text-align: center;
  opacity: 0.85;
}

.ingredient-result {
  width: 80%;
  max-width: 420px;
  padding: 0.75rem;
  overflow-y: auto;
  border: 1px solid rgba(70, 45, 20, 0.35);
  border-top: none;
  border-radius: 0 0 10px 10px;
  background: rgba(255, 248, 220, 0.35);
  text-align: center;
}

.ingredient-selected-name,
.ingredient-result h3 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.25rem, 1.7vw, 1.75rem);
  font-weight: bold;
  letter-spacing: 0.03em;
  text-align: center;
}

.ingredient-stats-row,
.ingredient-effects-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.ingredient-stats-row {
  margin-bottom: 0.75rem;
}

.info-box,
.effect-box {
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.55rem;
  border-radius: 8px;
  background: rgba(90, 55, 25, 0.14);
  font-size: clamp(0.95rem, 1vw, 1.15rem);
  text-align: center;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.14);
}

.info-box strong {
  font-size: 0.85rem;
}

.info-box span {
  font-size: 1rem;
}

/* ===== Page 6 - Effect Lookup ===== */

.effect-lookup-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 0;
}

.effect-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin: 0;
  padding: 0.6rem 0.65rem;
  border: 1px solid rgba(70, 45, 20, 0.35);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: rgba(255, 248, 220, 0.35);
}

.effect-search-row .custom-dropdown {
  flex: 0 1 420px;
  margin-right: auto;
}

.effect-sort-controls {
  display: flex;
  flex-shrink: 0;
  margin-left: auto;
  overflow: hidden;
  border: 1px solid rgba(70, 45, 20, 0.45);
  border-radius: 8px;
}

.effect-sort-btn {
  padding: 0.4rem 0.6rem;
  border: none;
  border-right: 1px solid rgba(70, 45, 20, 0.3);
  background: rgba(255, 248, 220, 0.6);
  font-size: 0.8rem;
  cursor: pointer;
}

.effect-sort-btn:last-child {
  border-right: none;
}

.effect-sort-btn:hover {
  background: rgba(90, 55, 25, 0.18);
}

.effect-sort-btn.active {
  background: rgba(90, 55, 25, 0.35);
  color: #2a1b10;
  font-weight: bold;
}

.effect-result {
  width: 100%;
  min-height: 0;
  margin-top: 0;
  padding-top: 0.5rem;
  overflow-y: auto;
  border: 1px solid rgba(70, 45, 20, 0.35);
  border-top: 1px solid rgba(70, 45, 20, 0.2);
  border-radius: 0 0 10px 10px;
  background: rgba(255, 248, 220, 0.35);
}

.effect-result.empty {
  opacity: 0.85;
}

.effect-result-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.effect-result-row {
  display: grid;
  grid-template-columns: 1.5fr 0.8fr 0.8fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: rgba(90, 55, 25, 0.12);
  text-align: center;
}

.effect-result-row span:first-child {
  text-align: left;
}

.effect-result-row.header-row {
  margin-bottom: 0.3rem;
  padding: 0.35rem 0.5rem;
  background: rgba(90, 55, 25, 0.22);
  font-weight: bold;
}

.effect-result-list p {
  text-align: center;
  font-style: italic;
  opacity: 0.75;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 800px), (max-height: 650px) {

  .book {
    width: 96vw;
    height: 88vh;
  }

  .book-inside {
    grid-template-columns: 1fr;
    padding: 3% 8% 7% 8%;
  }

  .left-page {
    display: none;
  }

  .right-page {
    display: flex;
    border-radius: 14px;
    transform: none;
  }

  .page-inner {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
  }

  .database-action-buttons {
    justify-content: center;
  }

  .potion-ingredient-stack {
    width: 100%;
  }

  .potion-ingredient-card .custom-dropdown,
  .potion-notes-input {
    width: 92%;
  }
}


/* ===== RESPONSIVE BOOK CONTENT ===== */

@media (max-width: 1100px), (max-height: 760px) {
  .book-inside {
    padding: 2.8% 5.2% 7% 5.2%;
  }

  .page-inner {
    padding:
      clamp(0.8rem, 1.8vh, 1.4rem)
      clamp(0.65rem, 1.4vw, 1.1rem)
      clamp(0.65rem, 1.4vh, 1rem);
  }

  .page h2 {
    font-size: clamp(1.15rem, 2.1vw, 1.6rem);
    margin-bottom: 10px;
    padding-bottom: 7px;
  }

  .page p,
  .dropdown-option,
  .book-input {
    font-size: clamp(0.75rem, 1.35vw, 0.95rem);
  }

  .custom-dropdown {
    width: 100%;
    max-width: none;
  }

  .ingredient-lookup-panel {
    grid-template-rows: auto minmax(180px, 42%) auto;
    gap: 0.65rem;
  }

  .ingredient-image-box {
    min-height: 180px;
  }

  .ingredient-search-card {
    margin-top: 0.4rem;
    padding: 0.45rem;
  }

  .ingredient-result {
    width: 100%;
    max-width: none;
  }

  .effect-search-row {
    gap: 0.35rem;
    padding: 0.45rem;
  }

  .effect-search-row .custom-dropdown {
    flex: 1 1 auto;
    min-width: 0;
  }

  .effect-sort-btn {
    padding: 0.35rem 0.45rem;
    font-size: 0.7rem;
  }

  .effect-result-row {
    grid-template-columns: 1.2fr 0.75fr 0.75fr;
    gap: 0.25rem;
    padding: 0.35rem;
    font-size: 0.78rem;
  }
}

/* ===== CRAMPED SCREEN: FIT CONTENT INSIDE PAGES ===== */

@media (max-width: 1100px), (max-height: 750px) {
  .page-inner {
    overflow-x: hidden !important;
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }

  .potion-builder-panel,
  .potion-database-panel,
  .ingredient-lookup-panel,
  .effect-lookup-panel {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .potion-result-box,
  .potion-ingredient-stack,
  .potion-database-controls,
  .potion-database-list,
  .ingredient-image-box,
  .ingredient-search-card,
  .ingredient-result,
  .effect-search-row,
  .effect-result {
    width: 100%;
    max-width: 100%;
  }

  .potion-ingredient-stack {
    min-width: 0;
  }

  .potion-ingredient-card .custom-dropdown,
  .potion-notes-input {
    width: 88%;
    max-width: 100%;
  }

  .database-action-buttons button,
  .database-filter-select {
    height: 30px;
    font-size: 0.72rem;
    padding: 0 0.45rem;
  }

  .saved-potion-card,
  .potion-card {
    padding: 0.55rem 1.8rem 0.55rem 1.7rem;
  }

  .saved-potion-card h3 {
    font-size: 0.85rem;
  }

  .saved-potion-card p {
    font-size: 0.72rem;
  }

  .potion-result-box {
    padding: 0.65rem;
  }

  .save-potion-btn {
    padding: 0.45rem 0;
    font-size: 0.78rem;
  }

  .book-inside {
    padding-bottom: 2%;
    padding-top: 2%;
  }

  .page-inner {
    height: 104%;
  }

  .potion-result-box {
    height: auto;
    min-height: 135px;
    justify-content: flex-start;
    gap: 0.45rem;
  }

  .potion-result-text {
    flex: 0 0 auto;
    min-height: 0;
  }

  .generated-potion-name {
    font-size: clamp(1rem, 1.7vw, 1.25rem);
    line-height: 1.05;
    max-width: 95%;
    overflow-wrap: break-word;
  }

  .shared-effects-box {
    font-size: 0.72rem;
    line-height: 1.15;
    margin-bottom: 0.2rem;
  }

  .save-potion-btn {
    position: relative;
    margin-top: 0.25rem;
    flex-shrink: 0;
  }

  .potion-database-controls {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
  }

  .potion-database-controls input,
  .potion-database-controls select {
    flex: 1 1 100%;
    min-width: 0;
  }

  .database-action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
  }

  .database-action-buttons button {
    flex: 1 1 auto;
    min-width: 70px;
    font-size: 0.7rem;
    padding: 4px 6px;
  }

  .effect-search-row {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .effect-search-row .custom-dropdown {
    flex: 1 1 100%;
  }

  .effect-sort-btn {
    flex: 1 1 auto;
    font-size: 0.7rem;
    padding: 4px 5px;
  }
}
