/* Username + How-to modals (Frappy Brew shell) */

html.modal-open,
body.modal-open {
  overflow: hidden;
  touch-action: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(8, 16, 32, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-panel {
  position: relative;
  width: min(440px, 100%);
  max-height: min(88dvh, 720px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(28, 44, 78, 0.98) 0%, rgba(16, 28, 52, 0.99) 100%);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.modal-brand-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 20px 6px;
  flex-shrink: 0;
}

.modal-brand-lo {
  display: block;
  height: 40px;
  width: auto;
  max-width: min(56vw, 240px);
  object-fit: contain;
}

.modal-brand-x {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: rgba(255, 255, 255, 0.95);
  user-select: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 0 22px;
  flex-shrink: 0;
}

.modal-brand-strip + .modal-header {
  padding-top: 8px;
}

.modal-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1.2;
}

.modal-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin: -6px -6px 0 0;
  border: none;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.92);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.12s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.modal-close:active {
  transform: scale(0.96);
}

.modal-close:focus-visible {
  outline: 2px solid var(--lo-yellow, #ffdd55);
  outline-offset: 2px;
}

.modal-body {
  padding: 14px 22px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

.modal-body--scroll {
  max-height: min(62dvh, 520px);
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 0 22px 20px;
  flex-shrink: 0;
}

.username-modal-subtitle {
  margin: 0 0 14px 0;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.82);
}

.username-modal-subtitle[hidden] {
  display: none !important;
}

.username-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.username-field label {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
}

.username-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.username-input-wrap:focus-within {
  border-color: rgba(76, 111, 255, 0.85);
}

#usernameInput {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  outline: none;
}

#usernameInput::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.username-char-count {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.55);
}

.username-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.4;
}

.username-error {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: #ff8a7a;
  min-height: 1.2em;
}

.btn-modal-primary {
  padding: 12px 22px;
  border-radius: 14px;
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, #ffe986 0%, var(--lo-yellow, #ffdd55) 90%);
  color: #1a1a2e;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.65);
}

.btn-modal-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* How-to */
.howto-hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 18px;
  min-height: 140px;
  background: rgba(0, 0, 0, 0.35);
}

.howto-hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
}

.howto-hero-player {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: min(120px, 38%);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.45));
}

.howto-section {
  margin-bottom: 18px;
}

.howto-section:last-of-type {
  margin-bottom: 0;
}

.howto-section h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.95);
}

.howto-section--lead {
  margin-top: 4px;
}

.howto-theme-heading {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(200, 220, 255, 0.9);
}

.howto-lead {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.88);
}

.howto-section p,
.howto-section li {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.82);
}

.howto-section ul {
  margin: 0;
  padding-left: 1.15em;
}

.howto-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 8px;
}

.howto-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 13px;
  font-weight: 600;
}

.howto-chip img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

/* DDG +8 — a bit larger than other chips so the skull reads at the points line */
.howto-chip img#howtoImgFish {
  width: 52px;
  height: 52px;
}

.howto-chip .howto-mine-img {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.howto-chip .howto-mine-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.howto-chip .howto-pillar-img {
  width: 28px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.howto-chip .howto-pillar-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.howto-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}

/* Character select */
.modal-panel--character {
  width: min(520px, 100%);
}

.character-select-subtitle {
  margin: 0 0 14px 0;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.82);
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 12px;
}

.character-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 12px;
  margin: 0;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.character-card:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.character-card:focus-visible {
  outline: 2px solid var(--lo-yellow, #ffdd55);
  outline-offset: 2px;
}

.character-card--selected {
  border-color: rgba(255, 221, 85, 0.95);
  box-shadow: 0 0 0 2px rgba(255, 221, 85, 0.25);
}

.character-card-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #141820;
}

.character-card-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-card-player {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 52%;
  height: auto;
  max-height: 78%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.character-card-name {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.character-card-scene {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.25;
}
