.login-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgb(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
}

.login-modal-content {
  position: relative;
  background-color: #111;
  padding: 2rem;
  width: 90%;
  max-width: 400px;
  border-radius: 12px;
  color: var(--text-color);
  border: 2px solid var(--pink-primary);
  box-shadow: 0 0 20px var(--pink-primary-03);
  margin: 8px;
}

.close-login-modal {
  position: absolute;
  right: 6px;
  top: 6px;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-color);
  transition: color 0.3s ease;
  width: 32px;
  height: 32px;
}

.close-login-modal:hover {
  color: var(--pink-primary);
}

.login-modal h2 {
  text-align: center;
  color: var(--text-color);
  margin-bottom: 2rem;
  font-size: 1.8rem;
}

.login-options {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.email-login {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-input {
  padding: 12px;
  border: 2px solid rgb(255, 255, 255, 0.1);
  border-radius: 8px;
  background-color: #333;
  color: var(--text-color);
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.login-input:focus {
  border-color: var(--pink-primary);
  outline: none;
}

.login-btn {
  padding: 12px;
  background: linear-gradient(90deg, var(--pink-primary) 0%, var(--pink-hover) 50%, var(--pink-primary) 100%);
  background-size: 200% 100%;
  color: var(--text-color);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  animation: gradientMove 3s linear infinite;
  transition: transform 0.3s ease;
}

.login-btn:hover,
.login-btn:active,
.login-btn:focus {
  transform: translateY(-2px);
  animation: gradientMove 1s linear infinite;
  background: linear-gradient(90deg, var(--pink-primary) 0%, var(--pink-hover) 50%, var(--pink-primary) 100%);
  background-size: 200% 100%;
  outline: none;
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #666;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #333;
}

.login-divider span {
  padding: 0 10px;
}

.social-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 12px;
  background-color: #333;
  color: var(--text-color);
  border: 2px solid rgb(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.3s ease;
}

.social-login-btn:hover {
  background-color: #444;
  transform: translateY(-2px);
}

.social-login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.social-login-btn img {
  width: 24px;
  height: 24px;
  margin-right: 10px;
}

.login-modal-message {
  color: var(--pink-hover);
  margin-bottom: 15px;
  text-align: center;
  display: block;
}

.login-modal-message.success {
  color: #4CAF50;
}

.login-modal-message.error {
  color: var(--color-error);
}

@media (max-width: 480px) {
  .login-modal-content {
    width: 95%;
    margin: 10vh auto;
    padding: 1.5rem;
  }

  .login-modal h2 {
    font-size: 1.5rem;
  }

  .social-login-btn {
    font-size: 0.9rem;
  }
}

.modal-content.character-modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40%;
  max-width: 1045px;
  height: 74vh;
  max-height: 695px;
  margin: 0;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  padding: 0;
  background-color: rgb(15, 15, 25, 0.98);
  backdrop-filter: blur(8px);
  border: 2px solid var(--pink-primary);
  overflow: hidden;
  box-shadow: 0 10px 30px rgb(0, 0, 0, 0.5);
}

.close-btn {
  position: absolute;
  top: 60px;
  left: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgb(255, 255, 255, 0.1);
  border: none;
  color: var(--text-color);
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 100;
  box-shadow: 0 2px 10px rgb(0, 0, 0, 0.3);
}

.close-btn:hover {
  background-color: rgb(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.character-details {
  width: 100%;
  height: 100%;
  padding: 10px;
  overflow: hidden;
}

.character-content {
  max-width: 100%;
  margin: 0;
  height: 100%;
  overflow: hidden;
}

.character-modal-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: flex-start;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  gap: 8px;
  position: relative;
  padding: 0;
  align-items: stretch;
}

.character-modal-left {
  flex: 0 0 auto;
  max-width: 100%;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  height: auto;
  padding: 0 10px 0 0;
  justify-content: flex-start;
  gap: 12px;
  overflow: hidden;
  --party-header-h: 3.6rem;
  --party-image-h: 220px;
}

.character-party-stage {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  min-width: 0;
  height: 400px;
}

.character-party-shared-bg {
  position: absolute;
  top: var(--party-header-h);
  left: 0;
  right: 0;
  height: var(--party-image-h);
  width: 100%;
  object-fit: cover;
  border-radius: 12px;
  z-index: 0;
  pointer-events: none;
}

.character-party-columns {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.character-primary-column,
.character-party-column {
  flex: 0 0 auto;
  width: min(200px, 32vw);
  max-width: 220px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.character-primary-column .character-header,
.character-party-column .character-header {
  min-height: var(--party-header-h);
  box-sizing: border-box;
  padding: 0 28px 0 4px;
}

.character-primary-column .character-header h2,
.character-party-column .character-header h2,
.character-primary-column .character-name-header,
.character-party-column .character-name-header {
  font-size: 1.15rem;
  margin: 0 0 0.15rem;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-primary-column .character-creator,
.character-party-column .character-creator {
  font-size: 0.75rem;
  margin: 0;
  min-height: 1em;
}

.character-primary-column .character-modal-image,
.character-party-column .character-modal-image {
  width: 100%;
  height: var(--party-image-h);
  min-height: var(--party-image-h);
  max-height: var(--party-image-h);
  margin: 0;
}

.character-primary-column .character-modal-image .character-image,
.character-party-column .character-modal-image .character-image {
  width: auto;
  height: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 12px;
  position: relative;
  z-index: 1;
}

.character-party-slots {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 0;
  margin-top: var(--party-header-h);
}

.character-modal-right {
  flex: 1 1 auto;
  max-width: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 10px 0;
  position: relative;
  min-height: 0;
  overflow-y: hidden;
  border-top: 1px solid rgb(255, 255, 255, 0.1);
}

.character-header {
  text-align: center;
  margin-top: 0;
}

.character-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.2;
  text-align: center;
}

.character-creator {
  font-size: 1rem;
  color: #888;
  margin-top: 0.1rem;
  margin-bottom: 0.3rem;
  text-align: center;
}

.character-modal-image {
  width: 100%;
  min-height: 180px;
  max-height: 260px;
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 0 0.5rem;
}

.character-modal-image img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  border-radius: 12px;
  object-fit: cover;
}

.character-footer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 0;
  padding-bottom: 8px;
}

.character-traits {
  display: flex;
  margin: 0.5rem 0 0;
  text-align: center;
  width: 100%;
  justify-content: center;
}

.trait-tag {
  opacity: 0.7;
}

.trait-tag.initial {
  opacity: 1;
}

.trait-tag.active {
  border-color: var(--pink-primary);
  background-color: var(--pink-primary-01);
}

.traits-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
}

.trait-tag {
  background-color: rgb(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.trait-tag:hover {
  background-color: rgb(255, 255, 255, 0.2);
}

.spots-container-wrapper {
  margin-top: 1rem;
  overflow-y: auto;
  max-height: 520px;
  padding-right: 45px;
  flex: 1;
  min-height: 0;
}

.spots-container-wrapper::-webkit-scrollbar {
  width: 6px;
}

.spots-container-wrapper::-webkit-scrollbar-track {
  background: rgb(255, 255, 255, 0.1);
  border-radius: 10px;
}

.spots-container-wrapper::-webkit-scrollbar-thumb {
  background: rgb(255, 255, 255, 0.3);
  border-radius: 10px;
}

.spots-container-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgb(255, 255, 255, 0.5);
}

.section-title {
  position: relative;
  margin: 1rem 0 2rem;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
  color: var(--text-color);
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background-color: var(--pink-primary);
  border-radius: 2px;
}

.spot-button {
  position: relative;
  padding: 0;
  background-color: rgb(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 140px;
  height: 175px;

  /* Increased from 150px to 175px */
  overflow: hidden;
  border: none;
}

.spot-button:hover {
  background-color: rgb(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgb(0, 0, 0, 0.3);
}

.spot-button.disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.spot-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 120%;
  object-fit: cover;
  z-index: 1;
  transition: all 0.3s ease;
}

.spot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  justify-content: center;
  margin-top: 1rem;
  padding-right: 15px;
  max-height: 676px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.spot-row::-webkit-scrollbar {
  display: none;
}

.confirmation-button {
  /* padding: 6px 16px; */
  border-radius: 20px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.confirm-yes {
  background-color: var(--pink-primary);
  color: var(--text-color);
}

.confirm-yes:hover {
  background-color: var(--pink-deep);
  transform: translateY(-2px);
}

.confirm-no {
  background-color: rgb(255, 255, 255, 0.15);
  color: var(--text-color);
}

.confirm-no:hover {
  background-color: rgb(255, 255, 255, 0.25);
}

.spot-search-bar {
  width: 80%;
  margin: 10px auto;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid rgb(255, 255, 255, 0.2);
  background-color: rgb(255, 255, 255, 0.1);
  color: var(--text-color);
  font-size: 0.9rem;
  outline: none;
  display: block;
  transition: all 0.3s ease;
}

.spot-filters-panel {
  display: none;
  width: 100%;
  margin: 0 auto 8px;
  padding: 0 4px 8px;
}

.spot-filters-panel.active {
  display: block;
}

.spot-search-bar.active {
  display: block;
}

.spot-char-count-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}

.spot-char-count-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
  margin-right: 4px;
}

.spot-char-count-btn {
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  cursor: pointer;
}

.spot-char-count-btn.is-selected,
.spot-char-count-btn[aria-pressed="true"] {
  border-color: var(--pink-primary);
  background: rgba(236, 72, 153, 0.2);
  color: var(--text-color);
}

.spot-filters-panel .scenario-tags-picker {
  max-height: 120px;
  overflow-y: auto;
  margin-top: 4px;
}

.spot-search-bar:focus {
  border-color: rgb(255, 255, 255, 0.4);
  background-color: rgb(255, 255, 255, 0.15);
  box-shadow: 0 0 0 2px rgb(255, 255, 255, 0.2);
}

.spot-search-bar::placeholder {
  color: var(--text-grey);
}

body.modal-open {
  overflow: hidden;
}

/* History Modal Message Styles */
.message-avatar {
  width: 180px;
  height: 650px;
  position: relative;
  display: inline-block;
  vertical-align: top;
  margin-right: 12px;
  margin-top: 2px;
  flex-shrink: 0;
}

/* Persona 5-style avatar frame for message avatars */
.message-avatar .persona-avatar-frame {
  position: relative;
  width: 180px;
  height: 450px;

  /* Increased from 250px to 450px */
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%);
  border: 3px solid #c00;
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 0 20px rgb(192, 0, 0, 0.4),
    inset 0 0 15px rgb(0, 0, 0, 0.5);
  transform: skew(-2deg, 0deg);
  transition: all 0.3s ease;
}

/* Variant colors for different characters */
.message-avatar[data-char-index="1"] .persona-avatar-frame {
  border-color: #07f;
  box-shadow: 0 0 20px rgb(0, 119, 255, 0.4), inset 0 0 15px rgb(0, 0, 0, 0.5);
}

.message-avatar[data-char-index="2"] .persona-avatar-frame {
  border-color: #ffbf00;
  box-shadow: 0 0 20px rgb(255, 191, 0, 0.4), inset 0 0 15px rgb(0, 0, 0, 0.5);
}

/* Adjust glowing border animation colors */
.message-avatar[data-char-index="1"] .persona-avatar-frame::before {
  background: linear-gradient(45deg, #07f, #3af, #07f, #04a);
}

.message-avatar[data-char-index="2"] .persona-avatar-frame::before {
  background: linear-gradient(45deg, #ffbf00, #ffd54f, #ffbf00, #ff9500);
}

.message-avatar .persona-avatar-frame:hover {
  transform: skew(-2deg, 0deg) scale(1.02);
  box-shadow:
    0 0 30px rgb(192, 0, 0, 0.6),
    inset 0 0 20px rgb(0, 0, 0, 0.3);
  border-color: #f00;
}

.message-avatar .persona-avatar-frame::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, #c00, #f44, #c00, #800);
  background-size: 400% 400%;
  animation: persona-border-glow 3s ease-in-out infinite;
  border-radius: 6px;
  z-index: -1;
}

.message-avatar .persona-avatar-frame::after {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  background: linear-gradient(45deg, #c00, #f00);
  clip-path: polygon(0% 0%, 100% 0%, 100% 70%, 70% 100%, 0% 100%);
  opacity: 0.8;
}

.message-avatar .persona-avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 20%;

  /* Focus on head/upper torso area */
  border: none;
  border-radius: 0;
  box-shadow: none;
  transform: skew(2deg, 0deg);

  /* Counter the frame skew */
  transition: transform 0.3s ease;
}

@keyframes persona-border-glow {
  0%,
  100% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }
}

/* Enhanced message layout */
.message.character-message {
  display: flex;
  align-items: flex-start;
  padding: 12px 15px;
  margin: 8px 0;
  background: linear-gradient(135deg, rgb(var(--pink-ink-rgb), 0.08), rgb(var(--pink-ink-rgb), 0.03));
  border-radius: 12px;
  border-left: 3px solid var(--pink-primary-03);
  position: relative;
  transition: all 0.2s ease;
}

.message.character-message:hover {
  background: linear-gradient(135deg, rgb(var(--pink-ink-rgb), 0.12), rgb(var(--pink-ink-rgb), 0.05));
  border-left-color: var(--pink-primary-05);
  transform: translateX(2px);
}

.message-content {
  flex: 1;
  line-height: 1.4;
  position: relative;
}

.message.user-message {
  padding: 12px 15px;
  margin: 8px 0;
  background: linear-gradient(135deg, rgb(100, 100, 100, 0.15), rgb(100, 100, 100, 0.05));
  border-radius: 12px;
  border-right: 3px solid rgb(100, 100, 100, 0.3);
  text-align: right;
  transition: all 0.2s ease;
}

.message.user-message:hover {
  background: linear-gradient(135deg, rgb(100, 100, 100, 0.2), rgb(100, 100, 100, 0.08));
  border-right-color: rgb(100, 100, 100, 0.5);
  transform: translateX(-2px);
}

.message.system-message {
  padding: 8px 15px;
  margin: 5px 0;
  font-style: italic;
  color: var(--text-grey);
  background: rgb(50, 50, 50, 0.3);
  border-radius: 8px;
  text-align: center;
  font-size: 0.9em;
  border: 1px solid rgb(255, 255, 255, 0.1);
}

/* Add subtle animation for new messages */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  animation: messageSlideIn 0.3s ease-out;
}

.spots-header-container {
  gap: 8px;
}

.spots-title {
  margin: 0;
}

@media (width <= 1024px) and (orientation: portrait) {
  .modal-content.character-modal-content {
    width: 95%;
    height: 98vh;
    max-height: 98vh;
    max-width: none;
    margin: 0.25vh auto 0;
    padding: 15px;
  }

  .character-details {
    padding: 10px 4px;
    height: 100%;
  }

  .character-modal-body {
    flex-direction: column;
    height: 100%;
    gap: 5px;
  }

  .character-modal-left {
    flex: 0 0 auto;
    max-width: 100%;
    width: 100%;
    height: auto;
    padding: 0;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    gap: 8px;
    --party-header-h: 2.8rem;
    --party-image-h: 160px;
  }

  .character-primary-column,
  .character-party-column {
    width: min(140px, 30vw);
    max-width: 160px;
  }

  .character-party-stage {
    height: 350px;
  }

  .character-party-slots {
    gap: 8px;
    margin-top: var(--party-header-h);
  }

  .character-party-slot.add-character-slot {
    width: min(140px, 30vw);
    max-width: 160px;
    height: var(--party-image-h);
    min-height: var(--party-image-h);
    max-height: var(--party-image-h);
  }

  .character-modal-body .character-modal-right {
    flex: 1;
    width: 100%;
    max-width: 100%;
    padding: 0;
    border-left: none;
    border-top: 1px solid rgb(255, 255, 255, 0.1);
    margin: 0 auto;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
  }

  .character-header {
    margin-right: 0;
    margin-bottom: 0;
    text-align: center;
  }

  .character-header h2 {
    font-size: 1.1rem;
    margin-bottom: 0;
  }

  /* Keep creator as spacer for party column header alignment */
  .character-creator {
    visibility: hidden !important;
    display: block !important;
    height: 1em;
    margin: 0;
    overflow: hidden;
  }

  .character-primary-column .character-modal-image,
  .character-party-column .character-modal-image {
    width: 100%;
    height: var(--party-image-h);
    min-height: var(--party-image-h);
    max-height: var(--party-image-h);
    margin-right: 0;
    margin-bottom: 0.25rem;
  }

  .character-primary-column .character-modal-image img,
  .character-party-column .character-modal-image img {
    max-width: 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .character-traits {
    width: 100%;
    height: auto;
    margin: 0.25rem 0 0;
  }

  .traits-list {
    flex-wrap: wrap;
    flex-direction: row;
  }

  .trait-tag {
    font-size: 0.8rem;
    padding: 3px 8px;
  }

  .spots-container-wrapper {
    padding-right: 10px;
    margin-top: 0;
    max-height: 100%;
    overflow-y: auto;
  }

  .spot-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    justify-content: flex-start;
    overflow: hidden auto;
    max-height: 460px;
  }

  .spot-button {
    width: calc((100% - 2.4rem) / 3);
    height: 180px;
    min-width: auto;
  }

  .confirmation-button {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .close-btn {
    top: 35px;
    left: 10px;
    width: 35px;
    height: 35px;
    font-size: 22px;
  }

  .character-footer-section {
    padding-bottom: 8px;
  }

  /* Scenario "Create Character" modal: mobile portrait layout */
  #scenario-character-create-modal .modal-content.character-modal-content {
    width: 95%;
    height: 98vh;
    max-height: 98vh;
    max-width: none;
    margin: 0.25vh auto 0;
    padding: 15px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Avoid clipping the top of the form inside nested overflow containers */
  #scenario-character-create-modal .character-details {
    overflow: visible;
    height: auto;
  }

  #scenario-character-create-modal .character-modal-body {
    flex-direction: column;
    height: auto;
    gap: 12px;
  }

  #scenario-character-create-modal .character-modal-left {
    flex: 0 0 auto;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Preview: keep it tall enough but not dominating */
  #scenario-character-create-modal #scenario-character-create-preview {
    height: 260px;
  }

  #scenario-character-create-modal .character-modal-right {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    padding: 0;
    border-left: none;
    border-top: 1px solid rgb(255, 255, 255, 0.1);
    padding-top: 10px;
    overflow: visible;
  }

  /* Fix inline row in the modal (name/gender/voice) so it wraps nicely */
  #scenario-character-create-modal .character-modal-right .form-row {
    /* HTML has inline margin-top:50px; pull it back on mobile so the row is visible immediately */
    margin-top: 0;
    flex-wrap: wrap;
    gap: 12px;
  }

  /* Make each field full-width for touch, except we can keep 2-up when space allows */
  #scenario-character-create-modal .character-modal-right .form-row .form-field {
    width: 100%;
    min-width: 0;
    flex-basis: 100%;
  }

  /* Ensure controls actually fill their field (the HTML uses some inline width:auto) */
  #scenario-character-create-modal #scenario-character-create-name,
  #scenario-character-create-modal #scenario-character-create-gender {
    width: 100%;
    min-width: 0;
  }

  /* Voice: size to content instead of full-width (but never overflow the viewport) */
  #scenario-character-create-modal #scenario-character-create-voice-root {
    width: auto;
    max-width: 100%;
  }

  #scenario-character-create-modal #scenario-character-create-voice {
    width: max-content;
    max-width: 100%;
    min-width: 0;
    display: inline-block;
  }

  #scenario-character-create-modal .close-btn {
    top: 35px;
    left: 10px;
    width: 35px;
    height: 35px;
    font-size: 22px;
  }
}

@media (width <= 1024px) and (orientation: landscape) {
  .modal-content.character-modal-content {
    width: 88%;
    height: 90%;
  }

  .character-details {
    padding: 0;
  }

  /* Keep header spacer even when creator is visually hidden */
  .character-creator {
    visibility: hidden !important;
    display: block !important;
    height: 1em;
    margin: 0;
    overflow: hidden;
  }

  /* Reduce vertical gap between image and traits */
  .character-modal-left {
    padding-bottom: 0;
    flex-direction: row;
    --party-header-h: 2.6rem;
    --party-image-h: 140px;
  }

  .character-primary-column,
  .character-party-column {
    width: min(120px, 22vw);
    max-width: 140px;
  }

  .character-primary-column .character-modal-image,
  .character-party-column .character-modal-image {
    height: var(--party-image-h);
    min-height: var(--party-image-h);
    max-height: var(--party-image-h);
  }

  .character-party-slot.add-character-slot {
    width: min(120px, 22vw);
    max-width: 140px;
    height: var(--party-image-h);
    min-height: var(--party-image-h);
    max-height: var(--party-image-h);
  }

  .character-traits {
    margin-top: 0.15rem;
  }

  .character-footer-section {
    gap: 3px;
    padding-bottom: 10px;
  }

  /* Tighten trait tags so they fit on screen */
  .traits-list {
    gap: 0.35rem;
  }

  .trait-tag {
    font-size: 0.75rem;
    padding: 2px 7px;
  }

  .spots-container-wrapper {
    padding-right: 0;
  }
}

/* Extra safeguard for iOS Safari: hide creator by small viewport height */
@media (width <= 1024px) and (height <= 480px) {
  .character-creator {
    visibility: hidden !important;
    display: block !important;
    height: 1em;
    margin: 0;
    overflow: hidden;
  }
}

/* Mobile (portrait and landscape): stack title words one per line */
@media (width <= 1024px) {
  .spots-title .title-word {
    display: block;
  }
}
