:root {
  /* BRAND:VARS:START */
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e2e6ea;
  --text: #16211c;
  --muted: #5b6b63;
  --accent: #0f5226;
  --accent-hover: #0a3a1a;
  --accent-bright: #6eff00;
  /* BRAND:VARS:END */
  --good: #18960e;
  --good-bg: #eaf6e8;
  --warn: #d99a2b;
  --warn-bg: #fdf3e3;
  --bad: #c9463c;
  --bad-bg: #fbeae8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Inter, Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  background: var(--accent);
  color: #fff;
  padding: 20px 28px;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.header-logo {
  height: 34px;
  width: auto;
  border-radius: 4px;
  display: block;
}

.help-link {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
}

.help-link:hover {
  background: rgba(255, 255, 255, 0.22);
}

header h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.5px;
}

header .tagline {
  margin: 4px 0 0;
  color: var(--accent-bright);
  font-size: 14px;
  font-weight: 600;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.hidden {
  display: none;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 700px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

/* Setup screen */
#screen-setup {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.team-builder,
.project-builder {
  margin: 18px 0;
}

.role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.role-row .role-label small {
  color: var(--muted);
}

.range-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.range-header .role-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.range-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.range-track {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-endpoint {
  flex-shrink: 1;
  min-width: 0;
  width: 136px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.3;
  overflow-wrap: break-word;
  hyphens: auto;
}

.range-endpoint.high {
  text-align: right;
}

.complexity-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.complexity-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}

.complexity-range::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}

.complexity-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}

.complexity-range:hover::-webkit-slider-thumb,
.complexity-range:focus::-webkit-slider-thumb {
  background: var(--accent-hover);
}

.complexity-range:hover::-moz-range-thumb,
.complexity-range:focus::-moz-range-thumb {
  background: var(--accent-hover);
}

#project-summary-panel .hero-row {
  margin-bottom: 10px;
}

#project-summary-panel .hero-caption {
  font-size: 12.5px;
}

@media (max-width: 480px) {
  .range-endpoint {
    width: 72px;
  }
}

.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stepper button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 18px;
  cursor: pointer;
}

.stepper button:hover {
  background: #eaf1f6;
}

.stepper .count {
  min-width: 20px;
  text-align: center;
  font-weight: 600;
}

#setup-health-panel {
  margin-top: 18px;
  margin-bottom: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.stat-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bar-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.info-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: normal;
}

.info-icon:hover,
.info-icon:focus,
.info-icon.open {
  background: var(--accent-hover);
  color: #fff;
  outline: none;
}

.info-icon .tooltip {
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: #1c2b3a;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 6px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 20;
  text-transform: none;
}

.info-icon:hover .tooltip,
.info-icon:focus .tooltip,
.info-icon.open .tooltip {
  opacity: 1;
  visibility: visible;
}

.info-icon.tooltip-below .tooltip {
  bottom: auto;
  top: 130%;
}

@media (max-width: 480px) {
  .info-icon .tooltip {
    width: 180px;
  }
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
}

/* Team-Health-Check: hero number + multiplier gauges */

.hero-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.hero-number {
  font-size: 34px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero-caption {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.hero-caption-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tier-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.tier-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.tier-pill.good {
  background: var(--good-bg);
  color: var(--good);
}

.tier-pill.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.tier-pill.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.gauges {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 14px;
}

.gauge-legend {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.gauge-row {
  display: grid;
  grid-template-columns: 96px 1fr 44px 100px;
  align-items: center;
  gap: 8px;
}

.gauge-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text);
}

.gauge-track {
  position: relative;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.gauge-fill {
  position: absolute;
  inset: 0;
  width: var(--fill, 0%);
  border-radius: 4px 0 0 4px;
}

.gauge-fill.good {
  background: var(--good);
}

.gauge-fill.warn {
  background: var(--warn);
}

.gauge-fill.bad {
  background: var(--bad);
}

.gauge-ref {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: var(--ref, 83.3%);
  width: 2px;
  background: var(--muted);
  opacity: 0.55;
}

.gauge-value {
  font-size: 12.5px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.gauge-status {
  font-size: 11.5px;
}

.gauge-status.good {
  color: var(--good);
}

.gauge-status.warn {
  color: var(--warn);
}

.gauge-status.bad {
  color: var(--bad);
}

details.detail-toggle {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

details.detail-toggle summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-hover);
  list-style: none;
}

details.detail-toggle summary::-webkit-details-marker {
  display: none;
}

details.detail-toggle summary::before {
  content: '▸';
  display: inline-block;
  font-size: 10px;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

details.detail-toggle[open] summary::before {
  transform: rotate(90deg);
}

details.detail-toggle .stat-grid {
  margin-top: 10px;
}

.dashboard-detail-section {
  margin-top: 14px;
  padding: 12px 14px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.dashboard-detail-section:first-of-type {
  margin-top: 10px;
}

.dashboard-detail-section h4 {
  margin: 0 0 10px;
  padding-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

/* Stat cells default to the same shade as the section background — lift them
   back onto white so they don't blend into the now-tinted group box. */
.dashboard-detail-section .stat-cell {
  background: var(--card);
}

@media (max-width: 480px) {
  .gauge-row {
    grid-template-columns: 72px 1fr 40px;
    row-gap: 2px;
  }

  .gauge-status {
    grid-column: 2 / -1;
  }
}

button#btn-start,
button#btn-end-quarter,
button#btn-restart,
button#btn-modal-continue,
button#btn-lock-strategy {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

button#btn-start:disabled,
button#btn-end-quarter:disabled,
button#btn-lock-strategy:disabled {
  background: #a9b7c2;
  cursor: not-allowed;
}

button#btn-start:hover:not(:disabled),
button#btn-end-quarter:hover:not(:disabled),
button#btn-restart:hover,
button#btn-modal-continue:hover,
button#btn-lock-strategy:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* Play screen */
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.badge {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
}

.challenge-badge {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.challenge-foreshadow {
  background: var(--good-bg);
  border: 1px solid var(--good);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text);
}

.btn-postpone {
  display: block;
  background: #fff;
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 18px;
}

.btn-postpone:hover:not(:disabled) {
  background: var(--warn);
  color: #fff;
}

.btn-postpone:disabled {
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-postpone.hidden {
  display: none;
}

.strategy-intro,
.strategy-note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 0;
}

.strategy-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.strategy-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--bg);
}

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

.strategy-card.selected {
  border-color: var(--accent);
  border-width: 2px;
  background: #e9f4fa;
}

.strategy-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 4px;
}

.strategy-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.challenge-summary {
  font-size: 13px;
  color: var(--muted);
}

.challenge-summary.hidden {
  display: none;
}

.roster {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}

.roster-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.btn-fire {
  background: none;
  border: 1px solid var(--bad);
  color: var(--bad);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.btn-fire:hover {
  background: var(--bad);
  color: #fff;
}

.hire-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-hire {
  background: #fff;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.btn-hire:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
}

.btn-hire:disabled {
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.effects-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.effects-list li {
  font-size: 13px;
  padding: 6px 10px;
  background: #fff6e8;
  border: 1px solid var(--warn);
  border-radius: 6px;
  margin-bottom: 6px;
}

#tier-badge strong {
  color: var(--accent);
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--muted);
}

.bar-track {
  height: 8px;
  background: #e6edf3;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.bar-fill.good {
  background: var(--good);
}

.bar-fill.warn {
  background: var(--warn);
}

.bar-fill.bad {
  background: var(--bad);
}

.action-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.action-row.selected {
  border-color: var(--accent-bright);
  border-width: 2px;
  background: #e9f4fa;
}

.action-row.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.qty-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
}

.qty-btn:disabled {
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.qty-value {
  min-width: 18px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

.action-title {
  font-weight: 600;
  font-size: 14px;
}

.action-title .cost {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-left: 6px;
}

.action-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 480px;
  overflow-y: auto;
}

.log-block {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.log-quarter {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 4px;
}

.log-entry {
  font-size: 13px;
  color: var(--muted);
  margin-left: 4px;
}

/* End screen */
#screen-end {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
}

.end-conditions {
  list-style: none;
  padding: 0;
  margin: 18px 0;
  text-align: left;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.end-conditions li {
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.end-conditions li.met {
  color: var(--good);
}

.end-conditions li.unmet {
  color: var(--bad);
}

.end-dashboard-panel,
.end-history-panel {
  text-align: left;
  margin-top: 24px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 28, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal h2 {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 19px;
}

.modal-section {
  margin-bottom: 14px;
}

.modal-section.hidden {
  display: none;
}

.modal-section h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.modal-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.modal-section li {
  font-size: 13px;
  padding: 3px 0;
}

.modal-event {
  background: #e9f4fa;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
}

.modal-event h4 {
  color: var(--accent);
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
}

.modal-event p {
  font-size: 13px;
  margin: 0 0 8px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px 20px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
}

.footer-logo {
  height: 34px;
  width: auto;
}

.footer-impressum {
  max-width: 680px;
  margin: 0 auto;
  line-height: 1.6;
}

.footer-impressum a {
  color: var(--muted);
  text-decoration: none;
}

.footer-impressum a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Help page */
.help-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.help-toc h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.help-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 24px;
}

.help-toc li {
  margin-bottom: 6px;
  break-inside: avoid;
}

.help-toc a {
  color: var(--accent-hover);
  text-decoration: none;
  font-size: 13.5px;
}

.help-toc a:hover {
  text-decoration: underline;
}

.help-section h2 {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 19px;
  scroll-margin-top: 12px;
}

.help-section h3 {
  margin: 16px 0 6px;
  color: var(--accent);
  font-size: 14.5px;
}

.help-section p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.6;
}

.help-section ul,
.help-section ol {
  margin: 0 0 10px;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.6;
}

.help-section li {
  margin-bottom: 4px;
}

.help-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 14px;
  font-size: 13.5px;
}

.help-section th,
.help-section td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.help-section th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

@media (max-width: 600px) {
  .help-toc ul {
    columns: 1;
  }
}
