:root {
  --page-bg: #efedf0;
  --card-bg: #f7f6f8;
  --field-bg: #ffffff;
  --text-color: #1f1f24;
  --muted-text: #6a6770;
  --accent-color: #500000;
  --accent-soft: #7a4d4d;
  --line-color: #c8c3cb;
  --answer-bg: #f1edf1;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: radial-gradient(circle at top, #f5f2f5 0%, var(--page-bg) 42%, #e9e6ec 100%);
  color: var(--text-color);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  max-width: 980px;
  padding: 28px 20px 40px;
  margin: auto;
  font-size: 18px;
  text-align: center;
}

body.embedded {
  max-width: none;
  padding: 14px;
  margin: 0;
  font-size: 16px;
  text-align: left;
}

body.embedded .top-nav {
  display: none;
}

h1 {
  color: var(--accent-color);
  font-size: clamp(1.7rem, 2.8vw, 2.2rem);
  margin-bottom: 6px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

h2 {
  margin: 12px 0;
  color: #302a35;
  font-size: 1.15rem;
}

p {
  color: var(--muted-text);
  line-height: 1.5;
}

.title,
.outputs,
.frontFooter,
.help,
form {
  background: var(--card-bg);
  border: 1px solid #d8d1dc;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(45, 22, 22, 0.06);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.title {
  margin-bottom: 18px;
}

form {
  text-align: left;
}

label {
  display: block;
  margin-top: 12px;
  margin-bottom: 6px;
  color: #2f2934;
  font-weight: 700;
  font-size: 0.96rem;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-color);
  border-radius: 9px;
  background: var(--field-bg);
  color: var(--text-color);
  font-size: 1rem;
}

input[type="number"]:focus,
input[type="text"]:focus {
  outline: 2px solid rgba(80, 0, 0, 0.18);
  border-color: var(--accent-soft);
}

form br {
  display: none;
}

.outputs {
  text-align: left;
}

.outputs > div[class^="output"] {
  margin-top: 10px;
  font-weight: 700;
}

#demoA,
#demoB,
#demoC {
  background-color: var(--answer-bg);
  font-weight: 800;
  padding: 12px;
  margin-top: 8px;
  border: 1px solid #d1c9d4;
  border-left: 4px solid var(--accent-color);
  border-radius: 8px;
}

.footer {
  padding: 8px 0 0;
  font-size: 14px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

/* Top navigation */
.top-nav {
  background: var(--card-bg);
  border: 1px solid #d8d1dc;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(45, 22, 22, 0.06);
  padding: 10px 12px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-nav-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-item {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font: inherit;
  font-weight: 800;
  color: #2f2b34;
  background: linear-gradient(180deg, #e2dfe5 0%, #cec9d3 100%);
  border: 1px solid #c0bac8;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.nav-item img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.nav-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(42, 39, 46, 0.14);
}

.nav-item:focus-visible {
  outline: 3px solid rgba(80, 0, 0, 0.18);
  outline-offset: 2px;
}

.info-button {
  -webkit-appearance: none;
  appearance: none;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-color);
  color: #ffffff;
  font: inherit;
  font-weight: 900;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 22px rgba(18, 10, 10, 0.22);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.info-button:hover {
  background-color: #3e0000;
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(18, 10, 10, 0.26);
}

.info-button:focus-visible {
  outline: 3px solid rgba(80, 0, 0, 0.22);
  outline-offset: 2px;
}

.help {
  line-height: 1.5;
  background: #fffdfc;
  text-align: left;
}

.c1,
.c2,
.c3,
.nav-button,
.map-button {
  border-radius: 10px;
  font-weight: 700;
  border: none;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.c1 {
  color: #ffffff;
  background-color: var(--accent-color);
  font-size: 1.05rem;
  padding: 11px 24px;
  margin-top: 14px;
  cursor: pointer;
  min-width: 160px;
}

.c1:hover {
  background-color: #3e0000;
  transform: translateY(-1px);
}

.c2 {
  color: #ffffff;
  background: linear-gradient(180deg, #85828a 0%, #6b6870 100%);
  box-shadow: 0 8px 18px rgba(42, 39, 46, 0.22);
  font-size: 1.05rem;
  padding: 14px 24px;
  cursor: pointer;
  min-width: 138px;
  border: 1px solid #7c7882;
}

.c2:hover {
  background: linear-gradient(180deg, #6d6a72 0%, #595760 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(42, 39, 46, 0.28);
}

.c3 {
  color: #2f2b34;
  background: linear-gradient(180deg, #e2dfe5 0%, #cec9d3 100%);
  font-size: 1.05rem;
  padding: 14px 24px;
  min-width: 138px;
  border: 1px solid #c0bac8;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(42, 39, 46, 0.12);
}

.c3:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #d7d3db 0%, #c5bfcd 100%);
  box-shadow: 0 12px 22px rgba(42, 39, 46, 0.2);
}

.cButton {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.bt-mini-text {
  font-family: inherit;
  font-size: 1rem;
}

.cButton img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.partner-footer {
  background: var(--card-bg);
  border: 1px solid #d8d1dc;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(45, 22, 22, 0.06);
  padding: 28px 28px 24px;
  margin-bottom: 16px;
}

.partner-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 44px;
  flex-wrap: wrap;
}

.pdi-logo {
  max-width: 260px;
  width: 42%;
  height: auto;
  object-fit: contain;
}

.crew-logo {
  max-width: 320px;
  width: 48%;
  height: auto;
  object-fit: contain;
}

.frontFooter {
  padding: 20px 24px 22px;
}

.frontFooter a {
  color: var(--accent-color);
}

/* Homepage map */
.relative-container {
  position: relative;
  margin: auto;
  background: var(--card-bg);
  border: 1px solid #d8d1dc;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(45, 22, 22, 0.06);
  margin-bottom: 16px;
}

.relative-container > img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid #cfc8d2;
  border-radius: 10px;
}

.map-button {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  line-height: 1;
  font-size: 0.9rem;
  color: #ffffff;
  background-color: rgba(80, 0, 0, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 22px rgba(18, 10, 10, 0.22);
  cursor: pointer;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .map-button {
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
}

.map-button:hover {
  background-color: rgba(62, 0, 0, 0.95);
  transform: translate(-50%, -50%) translateY(-1px);
}

.map-button:focus-visible {
  outline: 3px solid rgba(80, 0, 0, 0.22);
  outline-offset: 2px;
}

.map-button img {
  height: 1.35em;
  width: auto;
  object-fit: contain;
}

/* Estimated button rectangles (adjust as needed) */
#btn-burner {
  top: 41.3%;
  left: 8%;
  width: 15%;
  height: 7%;
}

#btn-fanLaws {
  top: 11%;
  left: 33%;
  width: 15%;
  height: 7%;
}

#btn-pipeSize {
  top: 18.8%;
  left: 33%;
  width: 15%;
  height: 7%;
}

#btn-pipeLoss {
  top: 26.4%;
  left: 33%;
  width: 15%;
  height: 7%;
}

#btn-pressForce {
  top: 78%;
  left: 76%;
  width: 15%;
  height: 7%;
}

#btn-tieForce {
  top: 86.6%;
  left: 76%;
  width: 15%;
  height: 7%;
}

.bright {
  display: flex;
  justify-content: flex-end;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(15, 13, 16, 0.55);
}

.modal-content {
  background-color: #ffffff;
  margin: 5% auto;
  padding: 20px;
  border: 1px solid #d8d1dc;
  border-radius: 12px;
  width: min(92%, 800px);
  box-shadow: 0 15px 40px rgba(26, 17, 30, 0.22);
}

.modal-content iframe {
  width: 100%;
  height: min(72vh, 720px);
  border: 0;
  border-radius: 10px;
  background: #ffffff;
}

.modal-content h2 {
  margin-bottom: 20px;
  color: var(--accent-color);
}

.close {
  float: right;
  font-size: 28px;
  font-weight: 700;
  color: #8a8690;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  line-height: 1;
}

.close:hover {
  color: #2b2730;
}

.nav-button {
  color: #ffffff;
  background-color: var(--accent-color);
  font-size: 1rem;
  padding: 10px 20px;
  width: 150px;
  margin: 6px;
  cursor: pointer;
}

.nav-button:hover {
  background-color: #3e0000;
}

.nav-group {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

@media (max-width: 720px) {
  body {
    padding: 16px 12px 24px;
    font-size: 16px;
  }

  .title,
  .outputs,
  .frontFooter,
  .help,
  form {
    padding: 14px;
  }

  .c1,
  .c2,
  .c3 {
    width: 100%;
    margin: 0;
  }

  .footer {
    gap: 8px;
  }

  .partner-footer {
    padding: 18px 14px;
  }

  .partner-logos {
    gap: 18px;
  }

  .pdi-logo,
  .crew-logo {
    width: 100%;
    max-width: 290px;
  }
}

@media (max-width: 900px) {
  .relative-container {
    padding: 8px;
  }

  .map-button {
    font-size: clamp(0.48rem, 1.75vw, 0.74rem);
    gap: clamp(2px, 0.6vw, 4px);
    padding: 0 clamp(3px, 1vw, 6px);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .map-button:hover {
    transform: translate(-50%, -50%) translateY(-1px);
  }

  .map-button img {
    height: 1.1em;
  }

  #btn-burner,
  #btn-fanLaws,
  #btn-pipeSize,
  #btn-pipeLoss,
  #btn-pressForce,
  #btn-tieForce {
    width: 18.5%;
    height: 8.4%;
  }
}
