:root {
  --bg: #ebd5ab;
  --surface: #fffdf7;
  --surface-2: #f3e8ca;
  --text: #1b211a;
  --muted: #628141;
  --accent: #628141;
  --accent-hover: #4e6933;
  --accent-soft: #8bae66;
  --border: rgba(98, 129, 65, 0.24);
  --shadow: rgba(27, 33, 26, 0.14);
  --success: #537541;
  --warning: #ad791f;
  --danger: #a83b35;
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Inter", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(139, 174, 102, 0.22), transparent 30rem),
    radial-gradient(circle at 88% 88%, rgba(98, 129, 65, 0.16), transparent 26rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  width: 100%;
  background-color: #1b211a;
  border-bottom: 1px solid rgba(139, 174, 102, 0.25);
}

.site-header-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px;
}

.site-logo {
  color: #ebd5ab;
  font-family: "Coustard", serif;
  font-size: 1.8rem;
  font-weight: 900;
  text-decoration: none;
}

.site-logo:hover {
  color: #8bae66;
}

.app {
  width: min(100%, 860px);
  min-height: calc(100vh - 73px);
  margin: 0 auto;
  padding: 48px 18px;
  display: flex;
  align-items: center;
}

.card {
  width: 100%;
  padding: clamp(24px, 5vw, 42px);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 22px 55px var(--shadow);
}

.centered {
  text-align: center;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
  font-family: "Coustard", serif;
}

h1 {
  font-size: clamp(2.2rem, 8vw, 4rem);
  font-weight: 900;
  line-height: 1.05;
}

h2 {
  font-size: 1.05rem;
  font-weight: 900;
}

.subtitle {
  max-width: 620px;
  margin: 14px auto 30px;
  color: var(--muted);
  line-height: 1.6;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.color-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface-2);
}

.panel-heading,
.slider-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.small-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1.45 / 1;
  margin: 14px 0 12px;
  border: 2px solid rgba(27, 33, 26, 0.13);
  border-radius: 15px;
  background: rgb(128, 128, 128);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.rgb-value {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.hidden-value {
  color: var(--muted);
}

.controls {
  display: grid;
  gap: 18px;
  margin: 28px 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: rgba(235, 213, 171, 0.34);
}

.slider-row label,
.slider-row output {
  font-weight: 800;
}

.slider-row output {
  min-width: 3ch;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  margin: 10px 0 0;
  accent-color: var(--accent);
}

.red-channel input[type="range"] {
  accent-color: #b9473f;
}

.green-channel input[type="range"] {
  accent-color: #628141;
}

.blue-channel input[type="range"] {
  accent-color: #4e6ea8;
}

.button {
  min-height: 50px;
  padding: 13px 18px;
  border: 2px solid transparent;
  border-radius: 13px;
  font-weight: 800;
  transition:
    transform 120ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(98, 129, 65, 0.28);
  outline-offset: 2px;
}

.primary {
  color: #fffdf7;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(98, 129, 65, 0.2);
}

.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.secondary {
  color: var(--text);
  background: var(--surface-2);
  border-color: rgba(98, 129, 65, 0.32);
}

.secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.full {
  width: 100%;
}

.result {
  margin-top: 24px;
  padding: 22px;
  border: 2px solid var(--border);
  border-radius: 17px;
  background: var(--surface-2);
  text-align: center;
}

.result[hidden] {
  display: none;
}

.score-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.score-line strong {
  font-family: "Coustard", serif;
  font-size: clamp(2.5rem, 10vw, 4.4rem);
  line-height: 1;
}

.score-line span {
  font-weight: 800;
}

.result-message {
  margin: 12px auto 18px;
  color: var(--muted);
  line-height: 1.55;
}

.result-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.result-values span {
  padding: 10px;
  border-radius: 11px;
  background: var(--surface);
  font-size: 0.82rem;
  line-height: 1.4;
}

.result.excellent {
  border-color: rgba(83, 117, 65, 0.7);
  animation: excellent-pop 520ms ease-out;
}

.result.good {
  border-color: rgba(83, 117, 65, 0.55);
}

.result.medium {
  border-color: rgba(173, 121, 31, 0.58);
}

.result.bad {
  border-color: rgba(168, 59, 53, 0.55);
}

.game-shake {
  animation: shake 360ms ease-in-out;
}

.result-flash {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
}

.result-flash.active {
  animation: flash 520ms ease-out;
}

.result-flash.good {
  background: rgba(83, 117, 65, 0.26);
}

.result-flash.medium {
  background: rgba(206, 156, 56, 0.27);
}

.result-flash.bad {
  background: rgba(168, 59, 53, 0.25);
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes excellent-pop {
  0% { transform: scale(0.97); }
  55% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes flash {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

@media (max-width: 620px) {
  .app {
    min-height: calc(100vh - 73px);
    align-items: stretch;
    padding: 0;
  }

  .card {
    min-height: calc(100vh - 73px);
    padding: 30px 18px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .color-grid {
    grid-template-columns: 1fr;
  }

  .color-swatch {
    aspect-ratio: 1.8 / 1;
  }
}

@media (max-width: 420px) {
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .result-values {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b211a;
    --surface: #293027;
    --surface-2: #343d30;
    --text: #ebd5ab;
    --muted: #a9c28e;
    --accent: #8bae66;
    --accent-hover: #9cbe78;
    --accent-soft: #628141;
    --border: rgba(139, 174, 102, 0.25);
    --shadow: rgba(0, 0, 0, 0.28);
    --success: #9fc782;
    --warning: #d7ab52;
    --danger: #c85d55;
  }

  body {
    background:
      radial-gradient(circle at 12% 8%, rgba(139, 174, 102, 0.11), transparent 30rem),
      radial-gradient(circle at 88% 88%, rgba(98, 129, 65, 0.1), transparent 26rem),
      var(--bg);
  }

  .card {
    background: rgba(41, 48, 39, 0.96);
  }

  .primary {
    color: #1b211a;
  }

  .controls {
    background: rgba(98, 129, 65, 0.08);
  }

  .color-swatch {
    border-color: rgba(235, 213, 171, 0.14);
  }
}

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

  .confetti-canvas {
    display: none;
  }
}
