:root {
  color-scheme: light;
  --desktop: #008080;
  --silver: #c0c0c0;
  --light: #fff;
  --mid: #808080;
  --dark: #000;
  --navy: #000080;
  --risk: #e38b00;
  font-family: Tahoma, Verdana, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--desktop); }

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  color: #111;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.07) 0 2px, transparent 3px),
    linear-gradient(145deg, #006f70, var(--desktop) 55%, #009191);
  background-size: 38px 38px, auto;
}

button, input, select { font: inherit; }
button, select { color: #111; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 6px;
  left: 6px;
  padding: 8px;
  color: #000;
  background: #fff;
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.desktop {
  width: min(1080px, calc(100% - 24px));
  margin: 0 auto;
  padding: clamp(12px, 3vw, 40px) 0 24px;
}

.window {
  overflow: hidden;
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  background: var(--silver);
  box-shadow: 10px 12px 0 rgba(0,0,0,.25);
}

.title-bar {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin: 2px;
  padding: 4px 4px 4px 8px;
  color: #fff;
  background: linear-gradient(90deg, #000080, #1084d0);
}

.title-bar h1 {
  flex: 1;
  margin: 0 8px;
  font-size: clamp(.78rem, 2.2vw, 1rem);
  line-height: 1.2;
}

.title-icon { font-size: 18px; }
.window-buttons { display: flex; gap: 3px; }
.window-buttons span,
.dialog-title button {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  color: #000;
  background: var(--silver);
  font-weight: bold;
  line-height: 1;
}

.menu-bar {
  display: flex;
  gap: 2px;
  padding: 1px 5px 4px;
  border-bottom: 1px solid var(--mid);
}
.menu-bar button { padding: 3px 8px; border: 0; background: transparent; }
.menu-bar button:hover, .menu-bar button:focus-visible { color: #fff; background: var(--navy); outline: 0; }

.app-body {
  display: grid;
  grid-template-columns: minmax(230px, .75fr) minmax(280px, 1fr);
  gap: 12px;
  padding: 12px;
}

.horse-panel,
.control-panel,
.result-panel {
  border: 2px solid;
  border-color: var(--mid) var(--light) var(--light) var(--mid);
  background: #d4d0c8;
}

.horse-panel { grid-row: span 2; padding: 8px; }
.camera-label { padding: 5px 7px; color: #0f0; background: #050505; font: bold .72rem "Courier New", monospace; }
.recording-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #f00; box-shadow: 0 0 7px #f00; }
.horse-button { display: block; width: 100%; padding: 0; border: 0; background: #171d0d; cursor: crosshair; }
.horse-button:focus-visible { outline: 3px solid #ff0; outline-offset: -3px; }
.horse-button img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; filter: saturate(.82) contrast(1.05); }
.horse-button.stud-mode img { animation: suspicious .55s steps(2, jump-none) infinite; filter: saturate(1.5) contrast(1.18) drop-shadow(0 0 10px #ff0); }
.camera-caption { min-height: 3.2em; margin: 0; padding: 8px; color: #8cff8c; background: #050505; font: .68rem/1.45 "Courier New", monospace; }
.horse-facts { margin: 10px 0 0; font-size: .76rem; }
.horse-facts div { display: grid; grid-template-columns: 92px 1fr; gap: 6px; padding: 5px 2px; border-bottom: 1px dotted #777; }
.horse-facts dt { font-weight: bold; }
.horse-facts dd { margin: 0; }

.control-panel { padding: 10px; }
fieldset { margin: 0 0 10px; padding: 10px; border: 2px groove #fff; }
legend { padding: 0 5px; font-weight: bold; font-size: .78rem; }
label:not(.check-row) { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0 3px; font-size: .76rem; font-weight: bold; }
output { font-family: "Courier New", monospace; }
input[type="range"], select { width: 100%; }
input[type="range"] { accent-color: var(--navy); }
select { min-height: 34px; padding: 4px; border: 2px solid; border-color: var(--mid) var(--light) var(--light) var(--mid); background: #fff; }
.check-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; font-size: .76rem; line-height: 1.35; }
.check-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--navy); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
button {
  min-height: 32px;
  padding: 5px 12px;
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  background: var(--silver);
  cursor: pointer;
}
button:active { border-color: var(--dark) var(--light) var(--light) var(--dark); }
button:focus-visible { outline: 2px dotted #000; outline-offset: -5px; }
button.primary { font-weight: bold; }

.result-panel {
  display: grid;
  grid-column: 2;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: center;
  padding: 12px;
}
.gauge-wrap { display: grid; place-items: center; }
.gauge {
  display: grid;
  width: 150px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid;
  border-color: var(--mid) var(--light) var(--light) var(--mid);
  border-radius: 50%;
  background: conic-gradient(var(--risk) 0 76%, #676767 76% 100%);
  box-shadow: inset 0 0 0 8px #d4d0c8;
}
.gauge-inner { display: grid; width: 102px; aspect-ratio: 1; place-items: center; align-content: center; border: 2px solid #444; border-radius: 50%; background: #050505; color: #52ff52; text-align: center; }
.gauge-inner strong { font: bold 2rem "Courier New", monospace; }
.gauge-inner span { font: .58rem "Courier New", monospace; }
.status-label { display: inline-block; margin: 0 0 4px; padding: 4px 7px; color: #fff; background: #a24400; font: bold .68rem "Courier New", monospace; }
.result-copy h2 { margin: 3px 0 5px; font-size: 1rem; }
.result-copy p, .result-copy li { font-size: .76rem; line-height: 1.4; }
.result-copy ul { margin: 8px 0 12px; padding-left: 20px; }

.status-bar { display: flex; justify-content: space-between; gap: 8px; margin: 0 4px 4px; }
.status-bar span { flex: 1; min-width: 0; padding: 4px 6px; overflow: hidden; border: 2px solid; border-color: var(--mid) var(--light) var(--light) var(--mid); font-size: .68rem; white-space: nowrap; text-overflow: ellipsis; }
.status-bar span:last-child { flex: 0 0 auto; }

.site-links { margin: 18px 0 0; color: #fff; text-align: center; text-shadow: 1px 1px #000; font-size: .8rem; }
.site-links a { color: #fff; }

dialog { width: min(430px, calc(100% - 24px)); padding: 2px; border: 2px solid; border-color: #fff #000 #000 #fff; background: var(--silver); box-shadow: 8px 10px 0 rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.42); }
.dialog-title { display: flex; align-items: center; justify-content: space-between; padding: 3px 3px 3px 7px; color: #fff; background: var(--navy); font-size: .8rem; font-weight: bold; }
.dialog-body { display: flex; gap: 16px; align-items: flex-start; padding: 20px; }
.dialog-body p { margin-top: 2px; font-size: .82rem; line-height: 1.45; }
.warning-icon { display: grid; flex: 0 0 42px; aspect-ratio: 1; place-items: center; border-radius: 50%; color: #fff; background: #d50000; font: bold 2rem serif; }

@keyframes suspicious { 50% { transform: translateX(4px) rotate(1deg); } }

@media (max-width: 760px) {
  .desktop { width: min(100% - 12px, 620px); padding-top: 6px; }
  .window { box-shadow: 5px 6px 0 rgba(0,0,0,.25); }
  .app-body { grid-template-columns: 1fr; padding: 8px; }
  .horse-panel { grid-row: auto; }
  .horse-button img { aspect-ratio: 16 / 8; }
  .result-panel { grid-column: 1; grid-template-columns: 120px 1fr; gap: 10px; }
  .gauge { width: 112px; }
  .gauge-inner { width: 78px; }
  .gauge-inner strong { font-size: 1.45rem; }
}

@media (max-width: 440px) {
  .window-buttons span { display: none; }
  .window-buttons span:last-child { display: grid; }
  .result-panel { grid-template-columns: 1fr; }
  .actions button, #copyButton { width: 100%; }
  .status-bar span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
