:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #171c23;
  --panel-2: #202733;
  --line: #344052;
  --text: #ecf2f8;
  --muted: #9dabbb;
  --accent: #46d19d;
  --warn: #f4b04a;
  --danger: #ef6262;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  min-height: 100vh;
}

.scene-panel {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: #11161c;
}

#quakeCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.wave-panel {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 3;
  display: grid;
  grid-template-columns: 92px minmax(260px, 1fr);
  gap: 10px;
  width: min(430px, calc(100% - 40px));
  height: 72px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: rgba(12, 17, 22, .82);
  backdrop-filter: blur(10px);
}

.magnitude-card {
  display: grid;
  place-content: center;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 7px;
  background: rgba(17, 23, 30, .9);
  text-align: center;
}

.magnitude-card span {
  color: var(--muted);
  font-size: 11px;
}

.magnitude-card strong {
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
}

.wave-svg {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 7px;
  background: rgba(5, 9, 12, .55);
}

.wave-svg line {
  stroke: rgba(70, 209, 157, .28);
  stroke-width: 1.4;
}

.wave-svg polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scene-panel.is-max-magnitude .wave-panel,
.scene-panel.is-max-magnitude .magnitude-card {
  border-color: rgba(239, 98, 98, .72);
  background: rgba(55, 13, 18, .84);
}

.scene-panel.is-max-magnitude .magnitude-card strong {
  color: #ff6b6b;
}

.scene-panel.is-max-magnitude .wave-svg polyline {
  stroke: #ff4545;
}

.scene-panel.is-max-magnitude .wave-svg line {
  stroke: rgba(255, 69, 69, .35);
}

.building-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.building-scene-controls {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.building-scene-control {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 7px;
  transform: translateY(-50%);
  pointer-events: auto;
}

.building-scene-control button {
  width: 86px;
  height: 28px;
  padding: 0 8px;
  border-color: rgba(255,255,255,.18);
  background: rgba(11, 16, 21, .78);
  color: #dce7f2;
  font-size: 11px;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.mitigation-mini {
  display: grid;
  width: 86px;
  gap: 6px;
  padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,.14);
}

.building-scene-control .mitigation-toggle {
  display: inline-grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 5px;
  text-align: left;
}

.state-icon {
  display: inline-grid;
  place-items: center;
  width: 13px;
  height: 13px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.state-icon::before {
  content: "+";
}

.building-scene-control button.is-active {
  border-color: rgba(70, 209, 157, .72);
  background: rgba(22, 71, 55, .86);
  color: #8ff0ca;
}

.building-scene-control button.is-active .state-icon::before {
  content: "✓";
}

.floor-stepper {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 60px;
  padding: 4px;
  border: 1px solid rgba(72, 165, 234, .36);
  border-radius: 8px;
  background: rgba(12, 19, 27, .82);
  backdrop-filter: blur(8px);
}

.floor-stepper span {
  color: #9bd4ff;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.building-scene-control .floor-arrow {
  position: relative;
  width: 34px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: #46a6ee;
  color: #dff1ff;
}

.building-scene-control .floor-arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.building-scene-control .floor-arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 11px;
  height: 8px;
  background: currentColor;
  transform: translateX(-50%);
}

.building-scene-control .floor-up::after {
  bottom: 4px;
}

.building-scene-control .floor-down::after {
  top: 4px;
}

.building-scene-control .floor-down::before {
  transform: translate(-50%, -50%) rotate(225deg);
}

.building-label {
  position: absolute;
  min-width: 96px;
  transform: translateX(-50%);
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 7px;
  background: rgba(10, 14, 18, .72);
  color: #eef6ff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .04em;
  backdrop-filter: blur(8px);
}

.health-label {
  position: absolute;
  min-width: 76px;
  transform: translate(-100%, -50%);
  padding: 5px 7px 6px;
  border: 1px solid rgba(70, 209, 157, .38);
  border-radius: 7px;
  background: rgba(8, 22, 17, .76);
  color: #8ff0ca;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  backdrop-filter: blur(8px);
  white-space: normal;
}

.health-label span {
  display: block;
  line-height: 1.25;
}

.health-label.is-warning {
  border-color: rgba(244, 176, 74, .55);
  background: rgba(45, 31, 12, .78);
  color: #ffd38a;
}

.health-label.is-danger {
  border-color: rgba(239, 98, 98, .62);
  background: rgba(45, 13, 18, .80);
  color: #ff9b9b;
}

.building-label span,
.building-label small {
  display: block;
  line-height: 1.2;
}

.building-label small {
  margin-top: 3px;
  color: #aeb9c9;
  font-size: 10px;
  font-weight: 700;
  text-transform: none;
}

.soil-badge {
  position: absolute;
  left: 18px;
  bottom: 92px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, auto);
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 36px);
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: rgba(10, 14, 18, .70);
  color: #dce7f2;
  font-size: 11px;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.soil-badge strong {
  color: #ffffff;
  font-size: 12px;
}

.soil-badge span {
  color: #aeb9c9;
}

.fixed-frequency {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 47px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 7px;
  background: rgba(7, 10, 13, .42);
}

.fixed-frequency span {
  color: #aeb9c9;
  font-size: 11px;
}

.fixed-frequency strong {
  color: #54dfb0;
  font-size: 14px;
}

.scene-actions {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  display: grid;
  grid-template-columns: 110px minmax(330px, 1fr);
  gap: 10px;
  align-items: stretch;
  width: min(820px, calc(100% - 90px));
}

.timer-box,
.amplitude-control {
  background: rgba(17, 23, 30, .86);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.timer-box {
  display: grid;
  place-content: center;
  gap: 3px;
  min-height: 48px;
}

.timer-box span,
.amplitude-control {
  color: var(--muted);
  font-size: 12px;
}

.timer-box strong {
  color: var(--text);
  font-size: 17px;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 10px;
  grid-column: 2;
}

.quick-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.amplitude-control {
  display: grid;
  grid-template-columns: 128px minmax(110px, 1fr) 58px;
  align-items: center;
  gap: 10px;
  margin: 0;
  min-height: 44px;
  padding: 8px 12px;
}

.amplitude-control.compact {
  grid-column: auto;
}

.amplitude-control input {
  width: 100%;
  height: 22px;
  cursor: pointer;
  accent-color: var(--accent);
}

.amplitude-control strong {
  color: var(--accent);
  font-size: 13px;
}

.hud {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  pointer-events: none;
}

.hud div,
.controls {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  backdrop-filter: blur(12px);
}

.hud div {
  border-radius: 8px;
  padding: 12px 14px;
}

.hud span,
label,
.readout p {
  color: var(--muted);
}

.hud span {
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
}

.hud strong {
  font-size: 18px;
}

.controls {
  overflow-y: auto;
  max-height: 100vh;
  padding: 22px;
}

header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
}

.brand-row h1 {
  margin: 0;
}

.language-toggle {
  width: auto;
  height: 34px;
  min-width: 48px;
  padding: 0 10px;
  border-color: rgba(70, 209, 157, .42);
  background: rgba(70, 209, 157, .12);
  color: #85f0c8;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
}

header p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.tool-link-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
  padding: 11px 12px;
  border: 1px solid rgba(92, 158, 255, .24);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(92, 158, 255, .10), rgba(70, 209, 157, .06));
}

.tool-link-card strong,
.tool-link-card span {
  display: block;
}

.tool-link-card strong {
  color: #ffffff;
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.tool-link-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tool-link-card a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(92, 158, 255, .40);
  border-radius: 7px;
  color: #dcecff;
  background: rgba(32, 39, 51, .70);
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.tool-link-card a:hover {
  border-color: rgba(70, 209, 157, .60);
  color: #8ff0ca;
}

.feedback-card {
  display: grid;
  gap: 10px;
  margin: 14px 0 2px;
  padding: 12px;
  border: 1px solid rgba(70, 209, 157, .22);
  border-radius: 8px;
  background: rgba(70, 209, 157, .06);
}

.feedback-card > div:first-child strong,
.feedback-card > div:first-child span {
  display: block;
}

.feedback-card > div:first-child strong {
  color: #ffffff;
  font-size: 14px;
}

.feedback-card > div:first-child span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.feedback-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.feedback-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px;
  border-color: rgba(255,255,255,.14);
  background: rgba(32, 39, 51, .72);
  font-size: 11px;
}

.feedback-actions button:first-child {
  border-color: rgba(70, 209, 157, .42);
  color: #8ff0ca;
}

.feedback-actions button.is-liked {
  border-color: rgba(70, 209, 157, .7);
  background: rgba(70, 209, 157, .16);
  color: #ffffff;
}

.like-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: currentColor;
}

.like-icon .like-bolt {
  fill: #101820;
}

.feedback-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.metric-chip {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border: 1px solid rgba(70, 209, 157, .26);
  border-radius: 999px;
  color: #8ff0ca;
  background: rgba(70, 209, 157, .08);
  font-size: 11px;
  font-weight: 800;
}

.feedback-status {
  min-height: 16px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.comment-dialog {
  width: min(520px, 100%);
  max-height: min(82vh, 680px);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  background: #111821;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}

.comment-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.comment-body textarea {
  min-height: 120px;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

.comment-body button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #06110d;
}

.control-group,
.readout {
  border-top: 1px solid var(--line);
  padding-top: 17px;
  margin-top: 17px;
}

h2 {
  margin: 0 0 12px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cbd6e2;
}

.section-title {
  display: grid;
  grid-template-columns: 1fr repeat(3, auto);
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
}

.section-title h2 {
  margin: 0;
}

.copy-params-btn {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
  width: auto;
  height: 32px;
  padding: 0 8px;
  border-color: rgba(255,255,255,.18);
  background: rgba(32, 39, 51, .86);
  color: #eef6ff;
  font-size: 12px;
}

.copy-icon {
  position: relative;
  width: 17px;
  height: 20px;
  display: inline-block;
}

.copy-icon::before,
.copy-icon::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 2px;
  background: transparent;
}

.copy-icon::before {
  left: 0;
  top: 4px;
  opacity: .72;
}

.copy-icon::after {
  right: 0;
  top: 0;
  background:
    linear-gradient(135deg, transparent 0 58%, currentColor 59% 68%, transparent 69%) top right / 7px 7px no-repeat;
}

.report-icon {
  position: relative;
  width: 17px;
  height: 18px;
  display: inline-block;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.report-icon::before,
.report-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  height: 2px;
  background: currentColor;
}

.report-icon::before {
  top: 4px;
  box-shadow: 0 5px 0 currentColor;
}

.report-icon::after {
  bottom: 3px;
}

.help-icon {
  position: relative;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
}

.help-icon::before {
  content: "?";
  line-height: 1;
}

.report-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 5, 8, .68);
  backdrop-filter: blur(8px);
}

.report-modal[hidden] {
  display: none;
}

.report-dialog {
  width: min(760px, 100%);
  max-height: min(82vh, 720px);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  background: #111821;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: rgba(32, 39, 51, .72);
}

.report-header h2 {
  margin: 0;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-header button {
  width: auto;
  height: 32px;
  padding: 0 12px;
}

.modal-copy-btn {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 7px;
}

#reportContent {
  max-height: calc(min(82vh, 720px) - 62px);
  margin: 0;
  overflow: auto;
  padding: 16px;
  color: #dce7f2;
  font-size: 14px;
  line-height: 1.55;
}

#reportContent h3 {
  margin: 16px 0 8px;
  color: #f2f7ff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

#reportContent h3:first-child {
  margin-top: 0;
}

#reportContent p {
  margin: 6px 0;
  color: #dce7f2;
  max-width: 68ch;
}

#reportContent strong {
  color: #ffffff;
  font-weight: 900;
}

.report-section {
  margin: 0 0 18px;
}

.report-section:last-child {
  margin-bottom: 0;
}

.report-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(70, 209, 157, .28);
  border-radius: 7px;
  background: rgba(70, 209, 157, .08);
}

.report-status span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 20px;
}

.report-list li {
  padding-left: 2px;
}

.report-sublist {
  display: grid;
  gap: 4px;
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.report-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(0,0,0,.16);
}

.report-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.35;
}

.report-table th,
.report-table td {
  padding: 10px 11px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-align: left;
  vertical-align: top;
}

.report-table th {
  color: #f6fbff;
  background: rgba(255,255,255,.05);
  font-size: 12px;
  font-weight: 900;
}

.report-table tr:last-child td {
  border-bottom: 0;
}

.report-table td {
  color: #e7eef6;
}

.report-table td span {
  color: var(--muted);
}

.report-winner {
  margin-top: 10px !important;
  padding: 9px 10px;
  border: 1px solid rgba(70, 209, 157, .24);
  border-radius: 7px;
  background: rgba(70, 209, 157, .07);
}

.winner-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin: 0 5px 0 2px;
  border-radius: 50%;
  background: #26df72;
  box-shadow: 0 0 0 3px rgba(38, 223, 114, .14);
  vertical-align: -1px;
}

.summary-tag {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 20px;
  margin-right: 8px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .05em;
}

.summary-ok {
  background: rgba(70, 209, 157, .16);
  color: #82f0c9;
}

.summary-warn {
  background: rgba(244, 176, 74, .16);
  color: #ffd38a;
}

.summary-info {
  background: rgba(125, 169, 255, .16);
  color: #b9ccff;
}

.modal-bullet {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.modal-bullet span {
  color: var(--accent);
  font-weight: 900;
}

.modal-spacer {
  height: 10px;
}

label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  font-size: 13px;
}

input,
select,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

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

output {
  justify-self: end;
  margin-top: -29px;
  color: var(--accent);
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.mitigation-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 4px;
}

.mitigation-options .check {
  min-height: 38px;
  margin: 0;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 7px;
  background: rgba(255,255,255,.035);
  color: #dbe5f0;
  font-size: 12px;
}

.building-card {
  padding: 12px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141a21;
}

.building-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.building-title strong {
  font-size: 14px;
}

.material-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 9px 0 2px;
  color: var(--muted);
  font-size: 11px;
}

.material-summary span {
  min-width: 0;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  background: rgba(255,255,255,.035);
}

.material-note {
  margin: 8px 0 0;
  color: #cbd6e2;
  font-size: 12px;
  line-height: 1.35;
}

.custom-material {
  display: none;
}

.building-card.is-custom .custom-material {
  display: block;
}

.swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.35);
}

.buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 9px;
  margin-top: 18px;
}

button {
  height: 42px;
  cursor: pointer;
  font-weight: 700;
}

.action-buttons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-icon {
  display: inline-block;
  flex: 0 0 auto;
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid currentColor;
}

.pause-icon {
  width: 12px;
  height: 13px;
  border-left: 4px solid currentColor;
  border-right: 4px solid currentColor;
}

.stop-icon {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: currentColor;
}

#startBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: #06110d;
}

#startBtn.is-inactive {
  background: #2a323f;
  border-color: #3d4859;
  color: #9dabbb;
}

#pauseBtn.is-active,
#resetBtn.is-active,
#stopReportBtn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #06110d;
}

button:hover {
  filter: brightness(1.08);
}

.readout p {
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.45;
}

.sources {
  font-size: 12px;
}

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

  .scene-panel {
    min-height: 68svh;
  }

  .controls {
    max-height: none;
  }

  .scene-actions {
    left: 18px;
    width: auto;
  }

  .soil-badge {
    grid-template-columns: repeat(2, auto);
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .app {
    display: block;
    min-height: 100svh;
  }

  .scene-panel {
    min-height: 100svh;
    height: 100svh;
  }

  .controls {
    padding: 14px;
  }

  header h1 {
    font-size: 22px;
  }

  .brand-row {
    margin-bottom: 6px;
  }

  .language-toggle {
    height: 30px;
    min-width: 44px;
    padding: 0 8px;
    font-size: 11px;
  }

  header p {
    display: none;
  }

  .feedback-card {
    margin-top: 10px;
    padding: 10px;
  }

  .feedback-actions {
    grid-template-columns: 1fr;
  }

  .feedback-actions button {
    height: 32px;
  }

  .wave-panel {
    top: 8px;
    left: 8px;
    grid-template-columns: 62px minmax(0, 1fr);
    width: calc(100% - 16px);
    height: 50px;
    padding: 5px;
  }

  .magnitude-card strong {
    font-size: 19px;
  }

  .scene-actions {
    top: 62px;
    right: 8px;
    left: 8px;
    grid-template-columns: 1fr;
    gap: 6px;
    width: auto;
  }

  .timer-box {
    min-height: 34px;
  }

  .timer-box span,
  .amplitude-control {
    font-size: 9px;
  }

  .timer-box strong {
    font-size: 13px;
  }

  .action-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    grid-column: auto;
  }

  .action-buttons button {
    min-height: 34px;
    height: auto;
    padding: 0 6px;
    gap: 5px;
    font-size: 11px;
    line-height: 1.1;
    white-space: normal;
  }

  .quick-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-right: 0;
    padding-right: 0;
    overflow-x: visible;
  }

  .amplitude-control {
    flex: initial;
    grid-template-columns: 104px minmax(0, 1fr) 42px;
    min-height: 30px;
    padding: 5px 8px;
  }

  .amplitude-control input {
    min-width: 0;
    height: 18px;
  }

  .amplitude-control strong {
    font-size: 10px;
  }

  .hud {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .hud div {
    padding: 6px 7px;
  }

  .hud span {
    margin-bottom: 2px;
    font-size: 9px;
  }

  .hud strong {
    font-size: 12px;
  }

  .soil-badge {
    left: 8px;
    right: auto;
    bottom: 84px;
    grid-template-columns: repeat(4, max-content);
    max-width: calc(100% - 16px);
    padding: 6px 8px;
    font-size: 9px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .soil-badge::-webkit-scrollbar {
    display: none;
  }

  .soil-badge strong {
    font-size: 10px;
  }

  .building-scene-control {
    transform: translateY(-50%) scale(.76);
    transform-origin: center;
  }

  .building-label {
    max-width: 150px;
    padding: 4px 6px;
    transform: translateX(-50%) scale(.78);
    transform-origin: top center;
  }

  .building-label small {
    font-size: 9px;
  }

  .health-label {
    transform: translateX(-100%) scale(.78);
    transform-origin: top right;
  }

  .split,
  .buttons {
    grid-template-columns: 1fr;
  }

  .section-title {
    grid-template-columns: 1fr repeat(3, 32px);
    gap: 5px;
  }

  .copy-params-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
  }

  .copy-params-btn span:last-child {
    display: none;
  }

  .report-modal {
    padding: 10px;
  }

  .report-dialog {
    width: 100%;
    max-height: calc(100svh - 20px);
  }

  .report-header {
    padding: 10px 12px;
  }

  .report-header h2 {
    font-size: 13px;
  }

  .report-header button {
    height: 30px;
    padding: 0 9px;
    font-size: 12px;
  }

  #reportContent {
    max-height: calc(100svh - 66px);
    padding: 12px;
    font-size: 13px;
  }

  .control-group,
  .readout {
    margin-top: 10px;
    padding-top: 10px;
  }

  h2 {
    margin-bottom: 9px;
    font-size: 13px;
  }

  label {
    gap: 5px;
    margin: 8px 0;
    font-size: 11px;
  }

  input,
  select {
    height: 32px;
    font-size: 12px;
  }

  .building-card {
    padding: 9px;
    margin: 9px 0;
  }

  .building-title {
    margin-bottom: 4px;
  }

  .building-title strong {
    font-size: 13px;
  }

  .material-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    font-size: 9px;
  }

  .material-summary span {
    padding: 5px;
  }

  .material-note {
    display: none;
  }

  .mitigation-options {
    gap: 6px;
    margin: 8px 0 2px;
  }

  .mitigation-options .check {
    min-height: 32px;
    padding: 6px;
    font-size: 11px;
  }

  .fixed-frequency {
    min-height: 38px;
    padding: 6px 8px;
  }

  .fixed-frequency span {
    font-size: 10px;
  }

  .fixed-frequency strong {
    font-size: 12px;
  }

  .readout p {
    font-size: 11px;
  }

  .sources {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 980px) {
  body {
    overflow: hidden;
  }

  .app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 34vw);
    height: 100svh;
    min-height: 0;
    overflow: hidden;
  }

  .scene-panel {
    height: 100svh;
    min-height: 100svh;
  }

  .controls {
    max-height: 100svh;
    padding: 12px;
    overflow-y: auto;
  }

  header h1 {
    font-size: 20px;
  }

  header p {
    margin-bottom: 10px;
    font-size: 12px;
    line-height: 1.35;
  }

  .control-group,
  .readout {
    margin-top: 12px;
    padding-top: 12px;
  }

  .section-title {
    grid-template-columns: 1fr repeat(3, 30px);
    gap: 5px;
  }

  .copy-params-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    justify-content: center;
  }

  .copy-params-btn span:last-child {
    display: none;
  }

  .wave-panel {
    top: 8px;
    left: 8px;
    grid-template-columns: 64px minmax(120px, 1fr);
    gap: 6px;
    width: min(290px, calc(100% - 16px));
    height: 52px;
    padding: 5px;
  }

  .magnitude-card span {
    font-size: 9px;
  }

  .magnitude-card strong {
    font-size: 20px;
  }

  .scene-actions {
    top: 66px;
    right: 8px;
    left: 8px;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 6px;
    width: auto;
    min-width: 0;
  }

  .timer-box {
    min-height: 36px;
  }

  .timer-box span,
  .amplitude-control {
    font-size: 10px;
  }

  .timer-box strong {
    font-size: 14px;
  }

  .action-buttons {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .action-buttons button {
    height: 36px;
    min-height: 36px;
    padding: 0 6px;
    gap: 5px;
    font-size: 11px;
  }

  .quick-controls {
    display: grid;
    margin-right: 0;
    padding-right: 0;
    overflow-x: visible;
    gap: 6px;
  }

  .amplitude-control {
    flex: initial;
    grid-template-columns: 88px minmax(70px, 1fr) 42px;
    min-height: 36px;
    padding: 6px 8px;
  }

  .amplitude-control input {
    height: 18px;
  }

  .amplitude-control strong {
    font-size: 11px;
  }

  .soil-badge {
    right: 8px;
    bottom: 76px;
    grid-template-columns: repeat(2, auto);
    gap: 5px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .hud {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .hud div {
    padding: 7px 8px;
    border-radius: 7px;
  }

  .hud span {
    margin-bottom: 2px;
    font-size: 10px;
  }

  .hud strong {
    font-size: 13px;
  }

  .building-scene-control {
    gap: 6px;
  }

  .floor-stepper {
    width: 54px;
    padding: 3px;
  }

  .building-scene-control .floor-arrow {
    width: 28px;
    height: 18px;
  }

  .building-scene-control button {
    width: 78px;
    height: 24px;
    font-size: 10px;
  }

  .mitigation-mini {
    width: 78px;
  }

  .building-label {
    transform: translateX(-50%) scale(.86);
    transform-origin: top center;
  }

  .health-label {
    transform: translateX(-100%) scale(.86);
    transform-origin: top right;
  }

  .report-modal {
    padding: 8px;
  }

  .report-dialog {
    width: min(92vw, 760px);
    max-height: calc(100svh - 16px);
  }

  #reportContent {
    max-height: calc(100svh - 74px);
    padding: 12px;
  }
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 760px) {
  .app {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 250px);
  }

  .wave-panel {
    width: min(300px, calc(100% - 16px));
  }

  .action-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-controls {
    grid-template-columns: 1fr 1fr;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .soil-badge {
    display: none;
  }

  header p,
  .sources {
    display: none;
  }

  .building-card {
    padding: 10px;
  }

  .material-summary {
    grid-template-columns: 1fr;
  }
}
