:root {
  color-scheme: light;
  font-family:
    ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #172033;
  --muted: #64748b;
  --surface: #ffffff;
  --line: #cbd5e1;
  --left-arc: #2563eb;
  --right-arc: #d94673;
  --possible: #087154;
  --possible-bg: #eafaf4;
  --degenerate: #9a5b06;
  --degenerate-bg: #fff7df;
  --impossible: #a6384d;
  --impossible-bg: #fff0f3;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 5%, rgb(37 99 235 / 7%), transparent 28rem),
    #f6f7fb;
  overscroll-behavior: none;
}

button,
svg {
  -webkit-tap-highlight-color: transparent;
}

.inequality-shell {
  width: min(100%, 1380px);
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.inequality-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--left-arc);
  font-size: clamp(0.82rem, 1.5vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  max-width: 1040px;
  margin: 0;
  font-size: clamp(1.65rem, 3.8vw, 3.3rem);
  line-height: 1.03;
  letter-spacing: -0.035em;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  font-weight: 650;
}

.local-note {
  flex: 0 0 auto;
  margin: 4px 0 0;
  padding: 9px 14px;
  border: 1px solid #b9e5d5;
  border-radius: 999px;
  color: #087154;
  background: #ecfdf5;
  font-size: clamp(0.74rem, 1.2vw, 0.9rem);
  font-weight: 750;
  white-space: nowrap;
}

.local-note span {
  margin-right: 5px;
  font-size: 0.7em;
}

.module-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.82fr);
  gap: clamp(14px, 2vw, 24px);
  align-items: stretch;
}

.construction-panel,
.control-panel {
  border: 1px solid rgb(203 213 225 / 82%);
  border-radius: 26px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 20px 60px rgb(30 41 59 / 9%);
}

.construction-panel {
  min-width: 0;
  padding: clamp(8px, 1.4vw, 16px);
}

.construction-board {
  display: block;
  width: 100%;
  max-height: min(68dvh, 760px);
  border-radius: 20px;
}

.board-background {
  fill: #f8fafc;
  stroke: #dbe4ef;
  stroke-width: 4;
}

.base-guide {
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 11;
}

.compass-arc {
  fill: none;
  stroke-linecap: round;
  stroke-width: 10;
}

.arc-left {
  stroke: var(--left-arc);
}

.arc-right {
  stroke: var(--right-arc);
}

.possible-triangle {
  fill: rgb(8 113 84 / 10%);
  stroke: #087154;
  stroke-linejoin: round;
  stroke-width: 9;
}

.mirror-triangle {
  fill: none;
  stroke: #7290a9;
  stroke-dasharray: 16 14;
  stroke-linejoin: round;
  stroke-width: 5;
  opacity: 0.55;
}

.degenerate-line {
  fill: none;
  stroke: #c07812;
  stroke-linecap: round;
  stroke-width: 17;
}

.base-point {
  fill: var(--ink);
  stroke: white;
  stroke-width: 7;
}

.intersection-point {
  fill: #087154;
  stroke: white;
  stroke-width: 7;
}

.intersection-point.mirror {
  fill: #7290a9;
  opacity: 0.72;
}

.tangent-point {
  fill: #c07812;
  stroke: white;
  stroke-width: 7;
}

.radius-label,
.base-label {
  paint-order: stroke;
  stroke: #f8fafc;
  stroke-linejoin: round;
  stroke-width: 10px;
  font-size: 32px;
  font-weight: 850;
  text-anchor: middle;
}

.radius-label.left {
  fill: var(--left-arc);
}

.radius-label.right {
  fill: var(--right-arc);
}

.base-label {
  fill: var(--ink);
}

.control-panel {
  display: flex;
  min-width: 0;
  padding: clamp(14px, 2vw, 22px);
  flex-direction: column;
  justify-content: center;
  gap: clamp(14px, 2.2vw, 24px);
}

.side-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.side-card {
  min-width: 0;
  margin: 0;
  padding: 12px 8px 10px;
  border: 2px solid #dbe4ef;
  border-radius: 18px;
  background: #f8fafc;
  text-align: center;
}

.side-name {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.8rem, 1.2vw, 1rem);
  font-weight: 800;
}

.side-value {
  margin: 2px 0 8px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.15rem, 4vw, 3.45rem);
  font-weight: 900;
  line-height: 1;
}

.stepper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.stepper button {
  min-width: 0;
  min-height: 62px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  color: white;
  background: var(--ink);
  font: inherit;
  font-size: 2rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.stepper button:active {
  transform: scale(0.97);
}

.stepper button:focus-visible,
.reset-button:focus-visible {
  outline: 4px solid rgb(37 99 235 / 28%);
  outline-offset: 3px;
}

.stepper button:disabled {
  color: #94a3b8;
  background: #e2e8f0;
  cursor: not-allowed;
}

.result-panel {
  overflow: hidden;
  border: 2px solid #dbe4ef;
  border-radius: 22px;
  background: white;
}

.inequality-equation {
  margin: 0;
  padding: clamp(13px, 2vw, 21px);
  color: white;
  background: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2rem, 5vw, 4.15rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.08;
  text-align: center;
}

.triangle-status {
  padding: clamp(13px, 1.8vw, 19px);
  color: var(--possible);
  background: var(--possible-bg);
  text-align: center;
}

.triangle-status[data-state="degenerate"] {
  color: var(--degenerate);
  background: var(--degenerate-bg);
}

.triangle-status[data-state="impossible"] {
  color: var(--impossible);
  background: var(--impossible-bg);
}

.status-title {
  margin: 0;
  font-size: clamp(1.35rem, 2.7vw, 2.15rem);
  font-weight: 900;
  line-height: 1.08;
}

.status-detail {
  margin: 5px 0 0;
  font-size: clamp(0.92rem, 1.5vw, 1.12rem);
  font-weight: 700;
  line-height: 1.25;
}

.reset-button {
  min-height: 58px;
  padding: 0 20px;
  border: 2px solid #cbd5e1;
  border-radius: 15px;
  color: var(--ink);
  background: white;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.rule {
  max-width: 1120px;
  margin: clamp(15px, 2vw, 24px) auto 0;
  padding: 12px 18px;
  border-left: 7px solid var(--left-arc);
  color: var(--ink);
  font-size: clamp(1.05rem, 2.1vw, 1.55rem);
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

noscript {
  display: block;
  margin-top: 12px;
  color: var(--impossible);
  font-weight: 700;
}

@media (max-width: 900px) {
  .inequality-header {
    display: block;
  }

  .local-note {
    display: inline-block;
    margin-top: 10px;
  }

  .module-layout {
    grid-template-columns: 1fr;
  }

  .construction-board {
    max-height: min(55dvh, 660px);
  }
}

@media (max-width: 520px) {
  .inequality-shell {
    padding-inline: 10px;
  }

  .construction-panel,
  .control-panel {
    border-radius: 20px;
  }

  .control-panel {
    padding: 11px;
  }

  .side-inputs {
    gap: 6px;
  }

  .side-card {
    padding-inline: 5px;
    border-radius: 14px;
  }

  .stepper {
    gap: 4px;
  }

  .stepper button {
    min-height: 56px;
  }
}

@media (orientation: landscape) and (max-height: 850px) and (min-width: 901px) {
  .inequality-shell {
    padding-block: 10px;
  }

  .inequality-header {
    margin-bottom: 9px;
  }

  .subtitle {
    display: inline;
    margin-left: 8px;
  }

  .construction-board {
    max-height: 69dvh;
  }

  .control-panel {
    padding-block: 12px;
    gap: 11px;
  }

  .stepper button {
    min-height: 58px;
  }

  .rule {
    margin-top: 10px;
    padding-block: 8px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .stepper button,
  .reset-button {
    transition:
      background-color 140ms ease,
      border-color 140ms ease,
      transform 80ms ease;
  }
}
