html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

:root {
  --bg-dark: #1a101a;
  --bg-card: #2a1a2a;
  --bg-input: #120a12;
  --accent: #7a4a7a;
  --accent-glow: rgba(122, 74, 122, 0.45);
  --text-main: #d4c5d4;
  --text-muted: #8a7a8a;
  --border: #3a2a3a;
  --success-muted: #5a8a6a;
  --error-muted: #8b4a4a;
  --bubble-color: #7a4a7a;
  --accent-dark: #3a1a3a;
  --particle-green: #4ade80;
  --particle-glow: #22c55e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}

body {
  background: var(--bg-dark);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  padding: 20px 10px;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
}

.container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 25px 20px;
  max-width: 950px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  position: relative;
  overflow: visible;
  z-index: 10;
}

.header-flex {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: -70px;
  position: relative;
  min-height: 80px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1 1 auto;
  min-width: 200px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.logo-container {
  flex-shrink: 0;
  width: 270px;
  height: 310px;
  margin-top: -130px;
  transform-origin: top center;
  animation: swing 5s ease-in-out infinite;
  pointer-events: none;
  z-index: 9999;
  position: relative;
  filter: drop-shadow(0 0 14px var(--accent-glow));
}

.logo-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

@keyframes swing {
  0% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(3deg);
  }
  100% {
    transform: rotate(-3deg);
  }
}

.header-text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 200px;
}

h1 {
  color: var(--accent);
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.2;
  background: linear-gradient(135deg, #7a4a7a, #b080b0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  margin-top: 2px;
}

.section-block {
  margin-bottom: 20px;
}

.inventory-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  background: transparent;
  overflow: visible;
  z-index: 10;
}

.inventory-left {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.inventory-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  margin-top: 30px;
  gap: 8px;
  min-height: 34px;
}

.btn-reset-inv {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: 0.2s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-reset-inv:hover {
  background: var(--accent);
  color: #0a0408;
}

.candy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 6px;
  margin-bottom: 2px;
  grid-auto-rows: 130px;
}

.candy-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 5px 6px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: border-color 0.2s, opacity 0.2s;
  height: 100%;
  justify-content: center;
}

.candy-card.empty {
  opacity: 0.55;
  filter: grayscale(0.4);
}

.candy-card:hover {
  border-color: var(--accent);
}

.candy-img-container {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  cursor: pointer;
  transition: transform 0.1s;
  flex-shrink: 0;
  margin-top: auto;
}

.candy-img-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
  border-radius: 4px;
}

.candy-card:hover .candy-img-container img {
  transform: scale(1.25);
}

.candy-name {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 2px;
  line-height: 1.3;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-dark);
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
  margin-top: auto;
}

.qty-control button {
  background: transparent;
  border: none;
  color: var(--accent);
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 15px;
  font-weight: bold;
  border-radius: 4px;
}

.qty-control button:hover {
  background: rgba(122, 74, 122, 0.15);
}

.qty-control input {
  background: transparent;
  border: none;
  color: white;
  width: 28px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}

.btn-help,
.btn-section-info {
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
  padding: 0;
  width: 34px;
  height: 34px;
  overflow: visible;
}

.btn-help img,
.btn-section-info img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  display: block;
  position: relative;
  top: 3px;
}

.btn-help:hover,
.btn-section-info:hover {
  transform: scale(1.15);
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin: 0 auto 0 auto;
  max-width: 820px;
}

.grid-header {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  padding-bottom: 2px;
  border-bottom: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 26px;
}

.grid-cell {
  position: relative;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  width: 100%;
  aspect-ratio: 1/1;
  min-width: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s;
  user-select: none;
  overflow: visible;
}

.grid-cell:hover {
  border-color: var(--accent);
}

.grid-cell.has-selection {
  border-color: var(--accent);
  background: transparent;
}

.grid-cell .selected-display {
  width: 60%;
  height: 60%;
  border-radius: 2px;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
  color: white;
  pointer-events: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.grid-cell.has-selection .selected-display {
  display: flex;
}

.grid-cell .selected-display img {
  width: 100%;
  height: 100%;
  border-radius: 2px;
  object-fit: cover;
}

.arrow-cell {
  font-size: 15px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: default;
  aspect-ratio: auto;
}

.hover-options {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  z-index: 150;
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  width: 160px;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.hover-option {
  width: 30px;
  height: 30px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
  cursor: pointer;
  margin: 0 auto;
  background: transparent;
}

.hover-option:hover {
  transform: scale(1.15);
  border-color: var(--accent);
}

.hover-option img {
  width: 100%;
  height: 100%;
  border-radius: 3px;
  object-fit: cover;
}

.hover-clear-btn {
  grid-column: 1 / -1;
  background: var(--bg-input);
  border: 1px solid var(--error-muted);
  color: var(--error-muted);
  padding: 4px 0;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  margin-top: 2px;
}

.hover-clear-btn:hover {
  background: var(--error-muted);
  color: #0a0408;
}

.btn-calculate {
  background: linear-gradient(145deg, var(--accent-dark), var(--accent));
  color: #d4c5d4;
  border: 1px solid var(--accent);
  padding: 14px 40px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: block;
  margin: 22px auto 18px;
  box-shadow: 0 0 12px rgba(122, 74, 122, 0.25), 0 4px 15px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s, box-shadow 0.2s;
  position: relative;
  overflow: visible;
  letter-spacing: 0.5px;
}

.btn-calculate:hover {
  transform: scale(1.02);
  box-shadow: 0 0 20px rgba(122, 74, 122, 0.4), 0 6px 20px rgba(0, 0, 0, 0.6);
}

.btn-calculate .btn-text {
  position: relative;
  z-index: 1;
}

.btn-calculate .glow-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 12px;
  border: 2px solid transparent;
  animation: glowPulse 3s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes glowPulse {
  0% {
    border-color: rgba(122, 74, 122, 0.05);
    box-shadow: 0 0 4px rgba(122, 74, 122, 0.1);
  }
  50% {
    border-color: rgba(122, 74, 122, 0.25);
    box-shadow: 0 0 12px rgba(122, 74, 122, 0.2);
  }
  100% {
    border-color: rgba(122, 74, 122, 0.05);
    box-shadow: 0 0 4px rgba(122, 74, 122, 0.1);
  }
}

#calc-spinner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  backdrop-filter: blur(2px);
}

#calc-spinner .spinner-box {
  background: var(--bg-card);
  padding: 30px 40px;
  border-radius: 16px;
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  max-width: 360px;
}

#calc-spinner .spinner {
  border: 4px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#calc-spinner .quote-text {
  color: var(--text-muted);
  font-style: italic;
  font-size: 15px;
  margin-top: 18px;
  padding: 0 10px;
  line-height: 1.5;
  min-height: 3.2em;
  border-top: 1px solid #2a1a2a;
  padding-top: 16px;
  transition: opacity 0.3s;
}

#calc-spinner .quote-text i {
  color: var(--accent);
  font-style: normal;
}

#result-panel {
  margin-top: 0;
  padding: 20px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: none;
}

.step-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 12px 16px;
  border: 1px solid #2a1a2a;
  transition: opacity 0.2s, border-color 0.2s;
  cursor: pointer;
  user-select: none;
}

.step-card.best-path {
  border-color: var(--success-muted);
  background: #0f1a13;
}

.step-card.done {
  opacity: 0.55;
  border-color: var(--success-muted);
  text-decoration: line-through;
  text-decoration-color: var(--success-muted);
}

.step-card.done .step-exchange,
.step-card.done .step-header {
  text-decoration: line-through;
  text-decoration-color: var(--success-muted);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.step-type {
  font-size: 12px;
  color: var(--text-muted);
  background: #2a1a2a;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.step-check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-muted);
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  font-size: 12px;
  color: transparent;
  transition: 0.1s;
  background: transparent;
  flex-shrink: 0;
}

.step-card.done .step-check {
  border-color: var(--success-muted);
  background: var(--success-muted);
  color: #0a0408;
}

.step-exchange {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.step-arrow {
  font-size: 20px;
  color: var(--accent);
}

.candy-icon {
  width: 30px;
  height: 30px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 13px;
  color: white;
  position: relative;
  vertical-align: middle;
}

.candy-icon img {
  width: 100%;
  height: 100%;
  border-radius: 3px;
  object-fit: cover;
}

.candy-icon .qty-badge {
  position: absolute;
  top: -7px;
  right: -10px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 0 4px;
  line-height: 15px;
  color: #f0f0f0;
  min-width: 17px;
  text-align: center;
}

.slot-info {
  margin-top: 15px;
  color: var(--text-muted);
  text-align: right;
  font-size: 13px;
}

.profit-box {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
}

.profit-box .profit-title {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.profit-box .profit-detail {
  color: #7a7a7a;
  font-size: 12px;
  line-height: 1.5;
}

.recipe-tip-box {
  background: #1a141a;
  border: 1px solid #2a1a2a;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
}

.recipe-tip-box .recipe-tip-title {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.recipe-tip-box .recipe-tip-detail {
  color: #8a7a8a;
  font-size: 12px;
  line-height: 1.5;
}

.legend-toggle {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-left: 8px;
}

.legend-box {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  display: none;
  line-height: 1.5;
}

.legend-box.visible {
  display: block;
}

#inventory-panel-wrapper {
  width: 100%;
  order: 2;
  overflow: hidden;
  transition: max-height 0.4s ease, margin 0.4s ease;
  max-height: 0;
  margin-top: 0;
}

#inventory-panel-wrapper.open {
  max-height: 800px;
  margin-top: 12px;
}

#drawer-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s, visibility 0.4s;
}

#inventory-panel-wrapper.open #drawer-panel {
  opacity: 1;
  visibility: visible;
}

.inventory-btn-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  height: 100%;
  position: relative;
  overflow: visible;
}

.inventory-btn-card:hover {
  border-color: var(--accent);
  background: #1a0a1a;
}

.inventory-btn-card .btn-image-container {
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  margin-top: auto;
}

.inventory-btn-card .btn-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  filter: drop-shadow(0 0 18px rgba(34, 197, 94, 0.7));
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 1;
}

.inventory-btn-card:hover .btn-image-container img {
  transform: scale(1.25);
}

.inventory-btn-card .btn-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 1px;
  font-weight: 600;
}

.slot-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent);
  color: #0a0408;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: normal;
  z-index: 5;
  line-height: 1.3;
}

.particle {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 7px;
  height: 7px;
  background: var(--particle-green);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 0) scale(0.3);
  animation: bubbleRise var(--duration) ease-out infinite;
  animation-delay: var(--delay);
  box-shadow: 0 0 14px var(--particle-glow), 0 0 28px rgba(34, 197, 94, 0.6);
  z-index: 0;
}

@keyframes bubbleRise {
  0% {
    transform: translate(-50%, 0) scale(0.4);
    opacity: 0.7;
  }
  25% {
    transform: translate(calc(-50% + var(--x)), -22px) scale(1.1);
    opacity: 1;
  }
  50% {
    transform: translate(calc(-50% + var(--x) * 1.5), -48px) scale(0.9);
    opacity: 0.8;
  }
  75% {
    transform: translate(calc(-50% + var(--x) * 0.5), -68px) scale(0.5);
    opacity: 0.4;
  }
  100% {
    transform: translate(calc(-50% + var(--x) * 2), -90px) scale(0.1);
    opacity: 0;
  }
}

.inventory-btn-mobile {
  display: none;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
  font-size: 14px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, background 0.2s;
  margin-top: 8px;
  order: 1;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.inventory-btn-mobile:hover {
  background: #1a0a1a;
  transform: scale(1.04);
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.3);
}

.inventory-btn-mobile .mobile-btn-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.5));
}

.inventory-btn-mobile .mobile-btn-label {
  flex: 1;
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(10, 48px);
  gap: 4px;
  width: 100%;
  justify-content: center;
  margin: 0 auto;
}

.inv-slot {
  width: 48px;
  height: 48px;
  background: #0a0408;
  border: 1px solid var(--border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inv-slot.filled {
  border-color: var(--accent);
  background: #1a0a1a;
}

.inv-slot.empty {
  opacity: 0.5;
  border-color: #2a1a2a;
}

.inv-slot .slot-content {
  width: 82%;
  height: 82%;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  font-size: 11px;
}

.inv-slot .slot-content img {
  width: 100%;
  height: 100%;
  border-radius: 2px;
  object-fit: cover;
}

#help-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 25px;
  z-index: 10000;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  display: none;
}

#help-modal h3 {
  color: var(--accent);
  margin-bottom: 12px;
}

#help-modal p {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 14px;
  margin-bottom: 8px;
}

#help-modal .close-help {
  display: block;
  margin: 15px auto 0;
  background: var(--accent);
  border: none;
  color: #0a0408;
  padding: 6px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

#max-slots-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}

#max-slots-container label {
  color: var(--text-muted);
}

#max-slots-container input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  width: 50px;
  text-align: center;
  font-weight: bold;
  font-size: 13px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.4;
}

.annotation {
  color: var(--text-muted);
  font-weight: normal;
  font-size: 13px;
}

.recipes-header-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 8px;
}

.recipes-header-wrapper .section-title {
  margin-bottom: 0;
}

.btn-clear-all {
  background: transparent;
  border: 1px solid var(--error-muted);
  color: var(--error-muted);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: 0.2s;
  line-height: 1.4;
}

.btn-clear-all:hover {
  background: var(--error-muted);
  color: #0a0408;
}

.target-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.target-header-row .section-title {
  margin-bottom: 0;
}

.footer {
  text-align: center;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 10px;
  max-width: 950px;
  width: 100%;
}

.status-success {
  color: var(--success-muted);
  font-weight: 600;
}

.status-error {
  color: var(--error-muted);
  font-weight: 600;
}

.status-neutral {
  color: var(--text-muted);
}

.status-info {
  color: var(--accent);
}

.lang-selector {
  display: inline-flex;
  vertical-align: middle;
  gap: 4px;
}

.lang-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
  transition: 0.2s;
}

.lang-btn:hover {
  background: var(--accent);
  color: #0a0408;
}

.lang-btn.active {
  background: var(--accent);
  color: #0a0408;
}

@media (max-width: 950px) {
  .container {
    padding: 20px 15px;
  }
  .logo-container {
    width: 220px;
    height: 260px;
    margin-top: -100px;
  }
  .candy-grid {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    grid-auto-rows: 120px;
  }
  .candy-card {
    padding: 6px 4px 5px 4px;
  }
  .candy-img-container {
    width: 42px;
    height: 42px;
  }
  .candy-name {
    font-size: 12px;
  }
  .qty-control button {
    width: 20px;
    height: 20px;
    font-size: 14px;
  }
  .qty-control input {
    width: 26px;
    font-size: 14px;
  }
}

@media (max-width: 850px) {
  .container {
    padding: 15px 10px;
  }
  .header-flex {
    margin-bottom: 10px;
  }
  .header-left {
    flex-direction: column;
    align-items: center;
    gap: 5px;
  }
  .logo-container {
    width: 240px;
    height: 200px;
    margin-top: -70px;
    order: 0;
  }
  .header-text {
    align-items: center;
    text-align: center;
    margin-top: -10px;
    order: 1;
  }
  h1 {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
  }
  .candy-grid {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    grid-auto-rows: 115px;
  }
  .candy-card {
    padding: 5px 3px 4px 3px;
  }
  .candy-img-container {
    width: 38px;
    height: 38px;
  }
  .candy-name {
    font-size: 11px;
  }
  .qty-control button {
    width: 18px;
    height: 18px;
    font-size: 13px;
  }
  .qty-control input {
    width: 24px;
    font-size: 13px;
  }
  .recipe-grid {
    max-width: 100%;
    gap: 2px;
  }
  .grid-cell {
    min-width: 22px;
  }
  .grid-header {
    font-size: 11px;
  }
  .candy-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }
  .candy-icon .qty-badge {
    font-size: 10px;
    line-height: 13px;
    top: -5px;
    right: -7px;
  }
  .section-block {
    margin-bottom: 12px;
  }
  .hover-option {
    width: 26px;
    height: 26px;
  }
  .hover-options {
    width: 140px;
  }
  .inventory-btn-card {
    display: none;
  }
  .inventory-btn-mobile {
    display: flex;
  }
  .inv-grid {
    grid-template-columns: repeat(10, 40px);
  }
  .inv-slot {
    width: 40px;
    height: 40px;
  }
  .inventory-btn-mobile .mobile-btn-icon {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 10px 5px;
  }
  .logo-container {
    width: 200px;
    height: 170px;
    margin-top: -60px;
  }
  .header-text {
    margin-top: -10px;
  }
  .candy-grid {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 4px;
    grid-auto-rows: 105px;
  }
  .candy-card {
    padding: 4px 2px 3px 2px;
  }
  .candy-img-container {
    width: 32px;
    height: 32px;
  }
  .candy-name {
    font-size: 10px;
  }
  .qty-control button {
    width: 16px;
    height: 16px;
    font-size: 12px;
  }
  .qty-control input {
    width: 22px;
    font-size: 12px;
  }
  .grid-cell {
    min-width: 18px;
  }
  .hover-options {
    width: 120px;
    padding: 3px;
  }
  .hover-option {
    width: 24px;
    height: 24px;
  }
  .candy-icon {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
  .inv-grid {
    grid-template-columns: repeat(10, 34px);
    gap: 2px;
  }
  .inv-slot {
    width: 34px;
    height: 34px;
  }
  .inventory-btn-mobile .mobile-btn-icon {
    width: 24px;
    height: 24px;
  }
}

@media (min-width: 2000px) {
  .container {
    max-width: 1100px;
    padding: 40px 50px;
  }
  h1 {
    font-size: 3rem;
  }
  .candy-grid {
    grid-auto-rows: 150px;
  }
  .candy-card {
    padding: 20px 16px 18px 16px;
  }
  .candy-img-container {
    width: 70px;
    height: 70px;
  }
  .candy-name {
    font-size: 16px;
  }
  .qty-control button {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
  .qty-control input {
    width: 34px;
    font-size: 18px;
  }
  .recipe-grid {
    max-width: 1000px;
  }
  .grid-cell {
    min-width: 50px;
  }
  .hover-option {
    width: 38px;
    height: 38px;
  }
  .inventory-btn-card .btn-image-container {
    width: 85px;
    height: 85px;
  }
  .candy-icon {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
  .logo-container {
    width: 320px;
    height: 360px;
    margin-top: -150px;
  }
}