:root {
  --bg: #f6f3e9;
  --panel: #fff8d5;
  --panel-strong: #ffffff;
  --border: #ddb53e;
  --text: #232323;
  --accent: #2f93de;
  --accent-strong: #1f5f9c;
  --danger: #d73a49;
  --motif-red: #e60012;
  --green: #66c59b;
  --orange: #f07d12;
  --light-orange: #f7c98d;
  --cream: #fffdf5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  background:
    repeating-linear-gradient(
      180deg,
      var(--cream) 0 28px,
      var(--bg) 28px 56px
    );
  color: var(--text);
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

h1 {
  margin: 0 auto 10px;
  max-width: 920px;
  text-align: center;
  background: #ffe27a;
  border: 5px solid #d5a52b;
  border-radius: 24px;
  padding: 18px 14px 18px 120px;
  box-shadow: 0 4px 0 color-mix(in srgb, #d5a52b 65%, black 35%);
  position: relative;
}

h1::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  translate: 0 -50%;
  width: 82px;
  height: 38px;
  border-radius: 999px;
  background: var(--motif-red);
}

h1::after {
  content: "";
  position: absolute;
  left: 29px;
  top: 50%;
  translate: 0 -50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 47px 0 0 #fff;
}

.subtitle {
  text-align: center;
  margin: 0 auto 12px;
  max-width: 900px;
  font-weight: 700;
  color: #5a3900;
}

.panel {
  background: var(--panel);
  border: 5px solid var(--border);
  border-radius: 22px;
  padding: 16px;
  margin: 14px 0;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--border) 58%, black 42%);
}

.controls {
  background: var(--panel-strong);
}

.controls label { font-weight: 700; display: block; margin-bottom: 8px; }
#personalityLabel { margin-top: 12px; }
select {
  width: 100%;
  max-width: 460px;
  font-size: 1rem;
  padding: 10px 12px;
  border: 3px solid #7a5c1f;
  border-radius: 12px;
  background: #fffdf5;
}


.description {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.personality-title {
  display: inline-block;
  width: fit-content;
  padding: 3px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--personality-color) 22%, white 78%);
  border: 3px solid var(--personality-color);
  font-weight: 700;
}

.personality-subtitle {
  font-size: 0.9rem;
  color: #4b4b4b;
}

.personality-range {
  font-size: 0.95rem;
}

.hint { display: none; }
.weighting-note {
  margin: 0 0 10px;
  color: #4b4b4b;
  font-size: 0.92rem;
}

.slider-grid { display: grid; gap: 12px; }

.slider-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  padding: 2px 0;
}

.slider-scale {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  gap: 8px;
  align-items: center;
  border: 2px solid #e7e6ea;
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
}

.trait {
  font-weight: 800;
  position: relative;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--motif-red);
  border-radius: 999px;
  padding: 2px 18px;
  text-align: center;
  letter-spacing: 0.01em;
}

.trait::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  translate: 0 -50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
}

.trait::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 50%;
  translate: 0 -50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
}
.pole {
  font-size: 0.9rem;
  text-align: center;
}

.boxes {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.box {
  width: 100%;
  min-height: 28px;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 2px solid #fff;
  background: #d9d9d9;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0;
  color: transparent;
  cursor: pointer;
  position: relative;
}

.box.allowed.pos-1 { background: #27c89f; }
.box.allowed.pos-2 { background: #42d3b2; }
.box.allowed.pos-3 { background: #62ddd0; }
.box.allowed.pos-4 { background: #8de8e3; }
.box.allowed.pos-5 { background: #edc8b9; }
.box.allowed.pos-6 { background: #efb784; }
.box.allowed.pos-7 { background: #eea149; }
.box.allowed.pos-8 { background: #ef8f1e; }

.box.allowed {
  border-color: color-mix(in srgb, #fff 72%, #858585 28%);
}

.box.selected,
.box.allowed.selected {
  background: var(--motif-red);
  border-color: #ffffff;
  box-shadow: inset 0 -2px 0 color-mix(in srgb, #a2000d 70%, black 30%);
}

.box.selected::after {
  content: "✓";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  text-shadow: none;
}

.box.disabled,
.box:disabled {
  background: #d9d9d9;
  color: #7b7b7b;
  border-color: #b5b5b5;
  cursor: not-allowed;
}

.box:focus-visible {
  outline: 3px solid #2b66da;
  outline-offset: 2px;
}

.ok { color: #1a7f37; font-weight: 700; }
.warn { color: #b54708; font-weight: 700; }

pre {
  white-space: pre-wrap;
  background: #fffdf5;
  border: 2px solid #dfc37a;
  border-radius: 10px;
  padding: 10px;
}

h2 {
  margin-top: 0;
  color: #1f2e3d;
}

summary {
  font-weight: 700;
  color: #7a4e00;
}

.breakdown p strong {
  color: #1f2e3d;
}


@media (max-width: 720px) {
  .app {
    padding: 16px 10px 32px;
  }

  h1 {
    font-size: 1.4rem;
    line-height: 1.25;
    padding-left: 92px;
  }

  .panel {
    padding: 10px;
    margin: 10px 0;
    border-radius: 16px;
  }

  .slider-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .slider-row .trait {
    justify-self: start;
    width: fit-content;
    max-width: 100%;
    justify-content: flex-start;
    text-align: left;
  }

  .slider-scale {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    gap: 6px;
  }

  .pole {
    font-size: 0.85rem;
  }

  .boxes {
    gap: 4px;
  }

  .box {
    min-height: 30px;
    font-size: 0.85rem;
  }
}
