:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #607078;
  --line: #d9e2e0;
  --paper: #f7f4ef;
  --panel: #ffffff;
  --green: #16745f;
  --teal: #26a69a;
  --coral: #d75f4f;
  --gold: #d49c31;
  --blue: #346aa0;
  --shadow: 0 18px 45px rgba(23, 33, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: linear-gradient(180deg, #f7f4ef 0%, #edf4f2 52%, #f8faf8 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.score-hero {
  min-height: 52vh;
  padding: 20px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 80% 18%, rgba(212, 156, 49, 0.18), transparent 28%),
    linear-gradient(145deg, #ffffff 0%, #edf8f5 60%, #fff7ec 100%);
  box-shadow: var(--shadow);
}

.topbar,
.section-title,
.rescue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 10vw, 4.5rem);
  line-height: 0.92;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

.icon-button,
.text-button,
.reason-row button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 1.15rem;
}

.score-ring {
  position: relative;
  width: min(78vw, 330px);
  aspect-ratio: 1;
  margin: 14px auto 12px;
}

.score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg,
.ring-progress {
  fill: none;
  stroke-width: 13;
}

.ring-bg {
  stroke: rgba(22, 116, 95, 0.14);
}

.ring-progress {
  stroke: url("#scoreGradient");
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 603.19;
  stroke-dashoffset: 603.19;
  transition: stroke-dashoffset 500ms ease;
}

.score-copy {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.score-label,
.score-copy span:last-child,
.live-row span,
.metrics-grid span,
.summary-panel span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.score-copy strong {
  display: block;
  font-size: clamp(4.2rem, 19vw, 7rem);
  line-height: 0.95;
}

.live-row,
.metrics-grid,
.summary-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.live-row div,
.metrics-grid article,
.summary-panel div,
.message-panel,
.log-panel,
.rescue-panel {
  border: 1px solid rgba(217, 226, 224, 0.9);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 16px;
}

.live-row div {
  min-height: 74px;
  padding: 12px;
}

.live-row strong,
.metrics-grid strong,
.summary-panel strong {
  display: block;
  margin-top: 6px;
  font-size: 1.05rem;
}

.message-panel {
  margin: 16px 0;
  padding: 16px 18px;
}

.message-panel p,
.rescue-panel p {
  margin-bottom: 0;
  line-height: 1.65;
}

.action-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 12px;
  margin-bottom: 16px;
}

.primary-action,
.secondary-action,
.save-button {
  border: 0;
  border-radius: 18px;
  padding: 18px;
  color: #fff;
  text-align: left;
  cursor: pointer;
}

.primary-action {
  background: linear-gradient(135deg, var(--green), var(--teal));
}

.secondary-action {
  background: linear-gradient(135deg, #52636b, var(--coral));
}

.primary-action span,
.secondary-action span {
  display: block;
  opacity: 0.82;
  font-size: 0.86rem;
}

.primary-action strong,
.secondary-action strong {
  display: block;
  margin-top: 8px;
  font-size: 1.15rem;
}

.rescue-panel,
.log-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.rescue-head strong {
  color: var(--coral);
  font-size: 1.6rem;
}

.reason-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.reason-row button {
  min-height: 42px;
  border-radius: 12px;
}

.metrics-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
}

.metrics-grid article {
  min-height: 92px;
  padding: 14px 12px;
}

.metrics-grid strong {
  font-size: 1.55rem;
}

.slider-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.slider-list label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

input[type="range"] {
  accent-color: var(--green);
}

.summary-panel {
  margin-bottom: 20px;
}

.summary-panel div {
  padding: 14px 12px;
}

.settings {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(23, 33, 38, 0.35);
}

.settings-card {
  width: min(680px, 100%);
  padding: 18px;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.settings-card label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
}

.settings-card input {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.text-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
}

.save-button {
  width: 100%;
  margin-top: 18px;
  background: var(--green);
  text-align: center;
  font-weight: 800;
}

.hidden {
  display: none;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .score-hero {
    min-height: auto;
    padding: 18px 14px;
    border-radius: 22px;
  }

  .live-row,
  .action-grid,
  .metrics-grid,
  .summary-panel {
    grid-template-columns: 1fr 1fr;
  }

  .live-row div:first-child,
  .primary-action {
    grid-column: 1 / -1;
  }

  .reason-row {
    grid-template-columns: 1fr 1fr;
  }
}
