/* Character editor: a side panel on wide screens, a bottom sheet on phones. */
.character-panel {
  position: absolute;
  z-index: 6;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: min(340px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #16271fef;
  color: var(--paper);
  box-shadow: 0 6px 24px #0b14105c;
}
.character-panel[hidden] { display: none; }
.character-head { display: flex; flex: none; align-items: center; justify-content: space-between; }
.character-options {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 3px 4px 5px;
  margin-inline: -4px;
}
.character-head h2 { margin: 0; font: 400 30px/1 var(--serif); }
.character-close { width: 40px; height: 40px; border: 0; background: none; color: var(--muted); font-size: 26px; cursor: pointer; }
.character-label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
#characterName {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1d17;
  color: var(--paper);
  font-size: 16px;
}
#characterName:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.character-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.character-choice button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: transparent;
  color: var(--paper);
  font-weight: 600;
  cursor: pointer;
}
.character-choice button[aria-checked='true'] { border-color: var(--gold); background: #2d4237; }
.character-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.character-swatches button {
  aspect-ratio: 1;
  min-height: 40px;
  border: 1px solid #ffffff2e;
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
}
.character-swatches button[aria-checked='true'] { outline: 2px solid var(--paper); outline-offset: 3px; }
.character-actions { display: grid; flex: none; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.character-actions .button { justify-content: center; }
/* Phones held upright: a bottom sheet, leaving the character visible above it. */
@media (max-width: 600px) and (orientation: portrait) {
  .character-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 58dvh;
    padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
    border-radius: 12px 12px 0 0;
  }
  .character-label { margin: 13px 0 7px; }
}
/* Short landscape screens: a narrower side panel. */
@media (max-height: 520px) and (orientation: landscape) {
  .character-panel {
    top: 8px;
    bottom: 8px;
    left: max(8px, env(safe-area-inset-left));
    width: min(320px, 46vw);
    padding: 12px 14px 14px;
  }
  .character-swatches { gap: 6px; }
}
