* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 32px 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(180deg, #f3f0e4 0%, #e7e0c8 100%);
  font-family: Georgia, 'Times New Roman', serif;
  color: #3a3320;
}

.card {
  width: 100%;
  max-width: 680px;
  background: #fffdf5;
  border: 1.5px solid #b8862c;
  border-radius: 14px;
  padding: 28px 32px 32px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

h1 {
  margin: 0 0 6px;
  color: #4a6b2a;
  font-size: 28px;
}

.hint {
  margin: 0 0 20px;
  color: #8a7a4a;
  font-size: 14px;
  line-height: 1.5;
}

.error {
  background: #fbe3df;
  border: 1.5px solid #c0552f;
  color: #8a2f12;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}

label {
  display: block;
  font-weight: 700;
  margin: 14px 0 6px;
  color: #4a6b2a;
}

input[type="text"], textarea {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1.5px solid #b8a86c;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
}

input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: #5a8835;
}

textarea { resize: vertical; line-height: 1.5; }

fieldset {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1.5px solid #b8a86c;
  border-radius: 8px;
}

legend {
  font-weight: 700;
  color: #4a6b2a;
  padding: 0 6px;
}

.radio {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  margin: 8px 0;
  cursor: pointer;
  font-size: 14px;
}

.radio b { color: #3a5520; }

.radio.standalone { margin: 16px 0 0; }

.custom-size input[type="number"] {
  width: 56px;
  font-family: inherit;
  font-size: 14px;
  padding: 4px 6px;
  border: 1.5px solid #b8a86c;
  border-radius: 6px;
}

select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1.5px solid #b8a86c;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
}

select:focus { outline: none; border-color: #5a8835; }

button[type="submit"] {
  margin-top: 22px;
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 13px;
  border: 1.5px solid #5a8835;
  border-radius: 10px;
  background: #c8d8a4;
  color: #3a5520;
  cursor: pointer;
}

button[type="submit"]:hover { background: #d6e4b6; }

.mode-bar { display: flex; gap: 14px; flex-wrap: wrap; }

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

.tile input { position: absolute; opacity: 0; pointer-events: none; }

.tile span {
  display: block;
  min-width: 36px;
  padding: 7px 8px;
  text-align: center;
  font-size: 16px;
  border: 1.5px solid #b8a86c;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  user-select: none;
}

.tile input:checked + span {
  background: #c8d8a4;
  border-color: #5a8835;
  color: #3a5520;
  font-weight: 700;
}

.tile span:hover { border-color: #5a8835; }

.inline-select {
  width: auto;
  font-family: inherit;
  font-size: 14px;
  padding: 4px 8px;
  border: 1.5px solid #b8a86c;
  border-radius: 6px;
  background: #fff;
}


/* Персонажи масок — внутри общей карточки генератора. */
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button, .quiet {
  font-family: inherit; font-size: 14px; padding: 7px 12px;
  border: 1.5px solid #b8a86c; border-radius: 8px;
  background: #fff; color: #3a5520; cursor: pointer;
}
.presets button[aria-pressed="true"] { background: #c8d8a4; border-color: #5a8835; font-weight: 700; }
.presets button:hover, .quiet:hover { border-color: #5a8835; }
.quiet { margin-top: 10px; font-size: 12px; }
.hint.tight { margin: 10px 0 0; font-size: 13px; }
.group-title { margin: 12px 0 6px; color: #8a7a4a; font-size: 13px; }
.group-title:first-child { margin-top: 0; }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.choice { display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin: 0; padding: 8px 4px; border: 1.5px solid #b8a86c; border-radius: 8px;
  background: #fff; color: #3a5520; cursor: pointer; font-size: 12px; text-align: center; font-weight: 400; }
.choice:has(input:checked) { background: #e6edda; border-color: #5a8835; }
.choice svg { width: 60px; height: 60px; }
input[type="radio"], input[type="checkbox"] { accent-color: #5a8835; }
.preview-label { margin-top: 0; font-size: 14px; font-weight: 400; }
#portrait-preview { max-width: 220px; margin: 12px auto 0; }
#portrait-preview svg { display: block; width: 100%; height: auto; }
.summary { margin: 16px 0 0; }
h2 { margin: 24px 0 10px; font-size: 20px; color: #4a6b2a; }
.how { margin: 0; padding-left: 22px; color: #5a4a20; font-size: 14px; line-height: 1.6; }
.how li + li { margin-top: 8px; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #5a8835; outline-offset: 2px; }
@media (max-width: 560px) {
  .card { padding: 22px 18px 26px; }
  .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}