@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700&display=swap');

:root{
  --row-h: 56px;
  --row-gap: 6px;
  --sticky-h: 60px;
}

*,
*::before,
*::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #121212;
  color: #e0e0e0;
}
img { max-width: 100%; height: auto; }

#splash-screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
#splash-logo {
  width: 100%;
  max-width: 560px;
  margin-bottom: 24px;
}
#splash-screen h1.app-title {
  font-size: clamp(1rem, 4vw, 1.2rem);
  color: #FFD700;
  font-weight: 200;
  letter-spacing: 2px;
  text-shadow: 1px 1px 4px #b8860b;
  margin: 0;
}

header {
  text-align: center;
  padding: 15px 5px 10px;
  background-color: #000;
}
#main-logo {
  display: block;
  margin: 0 auto 14px;
  width: 100%;
  max-width: 400px;
}
.app-title {
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 300;
  color: #FFD700;
  margin: 0;
  letter-spacing: 2px;
  text-shadow: 1px 1px 3px #b8860b;
}

main#calculator {
  max-width: 1833px;
  margin: 0 auto 32px;
  padding: 0 8px;
}

section {
  background-color: #1e1e1e;
  border-radius: 16px;
  padding: 20px;
  margin: 20px 0;
  border: 2px solid #333;
  box-shadow: 0 7px 20px rgba(255, 215, 0, 0.07);
  position: relative;
  padding-bottom: calc(var(--sticky-h) + 12px);
}

section h2 {
  font-size: clamp(1.4rem, 4.2vw, 2.4rem);
  font-weight: 200;
  margin: 0 0 20px 0;
  letter-spacing: 1px;
}
.gold-section h2 {
  font-family: 'Garamond', serif;
  font-weight: 500;
  color: #FFD700;
  text-shadow: 0 1.5px 4px rgba(255, 215, 0, 0.3);
}
.silver-section h2 {
  font-family: 'Garamond', serif;
  font-weight: 500;
  color: #C0C0C0;
  text-shadow: 0 1.5px 4px rgba(192, 192, 192, 0.3);
}
.platinum-section h2 {
  font-family: 'Garamond', serif;
  font-weight: 500;
  color: #E5E4E2;
  text-shadow: 0 1.5px 4px rgba(229, 228, 226, 0.3);
}
.palladium-section h2 {
  font-family: 'Garamond', serif;
  font-weight: 500;
  color: #CED0DD;
  text-shadow: 0 1.5px 4px rgba(206, 208, 221, 0.3);
}

.live-rate {
  font-size: clamp(1rem, 3.2vw, 1.4rem);
  font-weight: 300;
  white-space: nowrap;
  margin-bottom: 18px;
  color: #C0C0C0;
  letter-spacing: 0.5px;
}

.row {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.9fr 1.6fr 1.6fr;
  gap: var(--row-gap);
  align-items: center;
  margin-bottom: 14px;
  min-height: var(--row-h);
}

.row input.weight,
.row input.assay,
.row input.buying,
.row .pure-au,
.row .price {
  width: 100%;
  max-width: none;
  padding: 8px 8px;
  border-radius: 10px;
  font-size: clamp(13px, 2.8vw, 15px);
  line-height: 1.2;
}

input.weight,
input.assay,
input.buying {
  border: 2px solid #555;
  background-color: #222;
  color: #fff;
}
input::placeholder { opacity: 0.8; font-size: 0.85em; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield;}
input[type="number"]:focus {
  outline: none;
  border-color: #FFD700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.pure-au,
.price {
  font-weight: 500;
  text-align: center;
  color: #C0C0C0;
  background-color: #1a1a1a;
  user-select: none;
  padding: 8px;
  font-size: clamp(10px, 2vw, 14px);
  display: block;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  max-width: 100%;
}

.silver-pure { color: #C0C0C0; }
.silver-price-text { color: #C0C0C0; }

.section-total {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  height: var(--sticky-h);
  margin-top: 0;
  text-align: center;
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  font-weight: 700;
  color: #00ffc3;
  background-color: #262626;
  padding: 12px;
  border-radius: 0 0 16px 16px;
  box-shadow: inset 0 0 13px #00ffc37e;
  user-select: none;
  z-index: 10;
}

.gold-section .total-offset{
  height: calc(2 * var(--row-h) + var(--row-gap));
  pointer-events: none;
}

footer {
  text-align: center;
  padding: 16px;
  color: #888;
  background-color: #000;
}

@media (max-width: 360px) {
  .row { gap: 4px; }
  section { padding: 16px; }
}