/* Base styles */
:root {
  --bg: #0f0f16;
  --panel: #242828;
  --text: #f7fafc;
  --muted: #f7fafc;
  --accent: #ffd166; /* warm sunshine */
  --accent-2: #06d6a0; /* mint */
  --accent-3: #118ab2; /* blue pop */
  --btn: #262828;
  --btn-hover: #2e3030;
  --danger: #ef476f;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
  font-family: 'Bebas Neue', sans-serif;
  color: var(--text);
  background: #191b1b;
}

.site-header {
  padding: 16px 20px;
  background: transparent;
    text-align: center;
}
.site-header h1 { margin: 0; font-weight: 800; letter-spacing: 0.5px; color: #ce422b; text-shadow: 3px 3px 2px #000; font-size: 64px; }
.site-header p { margin: 6px 0 0; color: var(--muted); font-size: 20px; font-weight: 600; letter-spacing: 0.2px; font-family: 'Bebas Neue', sans-serif; text-shadow: 3px 3px 2px #000; }

/* Subtitles */
h2 { text-shadow: 3px 3px 12px #000; }

/* Paragraphs use Rubik */
p { font-family: 'Rubik', sans-serif; }

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 64px; }

.section { transition: opacity 300ms ease, transform 300ms ease; }

/* Section 1: Input */
.section-input {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 0;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
  position: relative;
}
.section-input h2 { margin-top: 0; color: #e6e6e6; font-weight: 600; text-align: center; }

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.item-card {
  background: #2f3333;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 0;
  padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
  gap: 10px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.item-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
.item-card .thumb { width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5)); }
.item-card .label { font-size: 14px; color: var(--muted); text-align: center; min-height: 34px; }

.qty-control { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 8px; width: 100%; }
.qty-btn {
  height: 40px; border-radius: 0; border: 1px solid rgba(255,255,255,0.08); background: var(--btn); color: var(--text);
  cursor: pointer; font-size: 18px; transition: background 180ms ease, transform 80ms ease, box-shadow 180ms ease; user-select: none;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}
.qty-btn:hover { background: var(--btn-hover); }
.qty-btn:active { transform: translateY(1px); }
.qty-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.qty-input {
  text-align: center; height: 40px; border-radius: 0; border: 1px solid rgba(255,255,255,0.16); background: #292c2c; color: var(--text);
  font-size: 16px; padding: 0 8px; outline: none; width: 100%;
}
.qty-input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,196,25,0.18); }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.qty-input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.btn.primary {
  display: inline-block; padding: 16px 28px; border-radius: 0; border: none;
  background: linear-gradient(180deg, #e24a31, #ce422b);
  color: #ffffff; cursor: pointer; font-weight: 900; font-size: 18px; font-family: 'Bebas Neue', sans-serif;
  box-shadow: none;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-2px); box-shadow: 0 14px 22px rgba(214,40,40,0.35); }
.btn.primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn.primary:active { transform: translateY(0); filter: brightness(1); }

/* Center the Calculate button */
#calculateBtn { display: block; margin: 8px auto 0 auto; }

/* Section 2: Output */
.section-output {
  margin-top: 40px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 0;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
}
.section-output h2 { text-align: center; }

.sulf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto;
  gap: 16px 24px;
  align-items: center;
}

/* Top center: Sulfur spans the middle column in first row */
.cell.sulfur {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.total-label { color: var(--muted); font-size: 16px; }
.total-value { font-size: 40px; font-weight: 900; color: var(--accent); }
.total-value.bump { animation: bump 260ms ease; }
@keyframes bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Bottom three cells */
.cell { 
  background: #343838;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 0;
  padding: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.cell:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
.cell.frags { grid-column: 1 / 2; grid-row: 2 / 3; }
.cell.charcoal { grid-column: 2 / 3; grid-row: 2 / 3; }
.cell.lowgrade { grid-column: 3 / 4; grid-row: 2 / 3; }

.res-label { color: var(--muted); font-size: 13px; }
.res-value { font-weight: 900; font-size: 20px; color: #fff; }
.res-value.bump { animation: bump 260ms ease; }
.qty-input.bump { animation: bump 260ms ease; }
.res-icon { width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35)); }
.res-icon-lg { width: 96px; height: 96px; }

@media (max-width: 700px) {
  .sulf-grid { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: auto; }
  .cell.sulfur { grid-column: 1 / -1; grid-row: auto; }
  .cell.frags, .cell.charcoal, .cell.lowgrade { grid-column: 1 / -1; grid-row: auto; }
}

/* Utilities */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Prevent double-tap zoom on interactive controls (mobile) */
button, .btn, .qty-btn, input[type="button"], input[type="submit"] { touch-action: manipulation; }

@media (max-width: 600px) {
  main { padding: 0 12px 84px; }
  .section-input { padding: 14px; }
  .item-card { padding: 12px; }
  .qty-control { grid-template-columns: 36px 1fr 36px; }
  .qty-btn { height: 36px; }
  .qty-input { height: 36px; font-size: 15px; }
  .btn.primary { width: 100%; max-width: 560px; font-size: 16px; padding: 14px 20px; border-radius: 0; }
  #calculateBtn { position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 50; }
  .total-value { font-size: 32px; }
}

.site-footer {
  margin: 32px 0 0;
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  width: 100%;
  background: linear-gradient(180deg, #121313, #0e0f0f);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.site-footer p { margin: 0; max-width: 1100px; width: 100%; overflow-wrap: anywhere; }

/* Side ad banners */
.ad-banner {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 320px;
  z-index: 100;
}
.ad-banner img {
  display: block;
  width: 100%;
  height: auto;
}
.ad-banner.left { left: calc(50% - (1100px / 2) - 320px - 24px); }
.ad-banner.right { left: calc(50% + (1100px / 2) + 24px); }

@media (max-width: 1800px) {
  .ad-banner { display: none; }
}

/* Modal: bookmark prompt */
.modal-overlay {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal-card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 0;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  text-align: center;
  position: relative;
}
.modal-card h3 {
  margin: 0 0 8px;
  color: #e6e6e6;
  font-weight: 600;
}
.modal-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-family: 'Rubik', sans-serif;
}
.modal-actions { margin-top: 16px; display: flex; justify-content: center; gap: 8px; }
.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 0;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--btn);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease;
}
.modal-close:hover { background: var(--btn-hover); }

/* Reset button in input section */
.reset-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 0;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--btn);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, transform 80ms ease;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}
.reset-btn:hover { background: var(--btn-hover); }
.reset-btn:active { transform: translateY(1px); }
.reset-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Slightly larger desktop modal */
#bookmarkOverlayDesktop .modal-card {
  max-width: 560px;
}

/* Make desktop modal more readable overall */
#bookmarkOverlayDesktop .modal-card {
  padding: 28px;
}
#bookmarkOverlayDesktop .modal-card h3 {
  font-size: 28px;
}
#bookmarkOverlayDesktop .modal-card p {
  font-size: 18px;
}
#bookmarkOverlayDesktop .modal-card .modal-actions {
  margin-top: 20px;
}
#bookmarkOverlayDesktop .modal-card .btn.primary {
  font-size: 20px;
  padding: 18px 28px;
}
#bookmarkOverlayDesktop .modal-card .modal-close {
  width: 36px;
  height: 36px;
  font-size: 24px;
  line-height: 32px;
}