/* はつめいロボバトルDX — screens.css：タイトル・重ねる画面（モーダル・しゃしん・ポーズ・あそびかた・せってい）（2026-12-02 P0 で css/style.css から同じ順番のまま分割。中身は変えていない。持ち主：P4） */

/* Title Overlay (#title-screen) — Non-blocking Showcase Framing */
#title-screen,
.title-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--tb);
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  pointer-events: none;
  /* 上は暗くしない（上に白い文字がないため。2026-12-02 本人指摘）。下はフッターの文字を読めるように残す */
  background: linear-gradient(
    180deg,
    rgba(25, 32, 56, 0) 0%,
    rgba(25, 32, 56, 0) 56%,
    rgba(25, 32, 56, 0.68) 100%
  );
}

.title-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  pointer-events: auto;
}

.title-meta-row {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.title-brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-orange);
  color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 3px 0 var(--ink);
}

.title-hero {
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 8px 18px 10px;
  box-shadow: 0 5px 0 var(--ink), 0 12px 24px rgba(15, 23, 42, 0.25);
  max-width: 520px;
}

.title-badge {
  display: inline-block;
  background: var(--accent-yellow);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 10.5px;
  font-weight: 900;
  margin-bottom: 3px;
}

.title-logo {
  margin: 0;
  font-size: clamp(20px, 5.2vw, 30px);
  font-weight: 900;
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.title-sub {
  margin: 3px 0 0;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

.title-career-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.title-rank-badge,
.title-bp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(25, 32, 56, 0.9);
  color: #fff;
  border: 2px solid var(--accent-yellow);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(15, 23, 42, 0.45);
}

.title-bp-badge {
  border-color: var(--accent-cyan);
  color: #e0f2fe;
}

.title-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  pointer-events: auto;
}

.title-cta-grid,
.title-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.title-cta {
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 62px;
  padding: 9px 8px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink), 0 8px 18px rgba(15, 23, 42, 0.25);
  transition: transform 0.09s ease, box-shadow 0.09s ease;
  text-align: center;
}

.title-cta:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.title-cta.primary,
.title-cta--battle {
  background: linear-gradient(180deg, #ff8f48 0%, #ff5722 100%);
  color: #ffffff;
  text-shadow: 0 1.5px 0 rgba(124, 45, 18, 0.65);
}

.title-cta--build {
  background: linear-gradient(180deg, #ffe066 0%, #fcc419 100%);
  color: var(--ink);
}

.title-cta--prog {
  background: linear-gradient(180deg, #a5f3fc 0%, #22d3ee 100%);
  color: var(--ink);
}

.title-cta-sub {
  font-size: 10px;
  font-weight: 800;
  opacity: 0.92;
}

.title-sec-bar,
.title-secondary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.title-sec-btn {
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2.5px 0 var(--ink);
  text-decoration: none;
}

.title-sec-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.title-sound-btn.is-off {
  background: #f1f5f9;
  color: #64748b;
}

.title-footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 10.5px;
  font-weight: 800;
  color: #e2e8f0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.title-footer-links a {
  color: #fff;
  text-underline-offset: 2px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--tb);
  background: rgba(25, 32, 56, 0.56);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  opacity: 0;
  transition: opacity 0.16s ease;
}

.modal-backdrop.open {
  display: flex;
  opacity: 1;
}

.modal-box {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 86dvh;
  overflow-y: auto;
  box-shadow: 0 7px 0 var(--ink);
  animation: popIn 0.18s ease-out;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.modal-title {
  font-size: 15px;
  font-weight: 900;
  margin: 0;
}

/* Photo Modal (IMAGE_SAVE_UX.md Sec 4–5) */
.modal-backdrop.photo-modal-backdrop.open,
#modal-photo.open {
  align-items: flex-start;
  overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.modal-backdrop.photo-modal-backdrop .modal-box,
#modal-photo .modal-box {
  max-height: none;
  overflow: visible;
  margin: 0 auto;
  text-align: center;
}

.photo-preview-img,
#photo-preview-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 10px;
  border-radius: 12px;
  border: 2.5px solid var(--ink);
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

#btn-photo-download,
#btn-photo-download:visited,
#photo-download-link,
#photo-download-link:visited {
  color: #ffffff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 8px 16px;
}

#btn-photo-share {
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 11px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2.5px 0 var(--ink);
}

#btn-photo-share:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Pause, Help, Settings Modals */
.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pause-btn {
  font-family: inherit;
  width: 100%;
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 2.5px solid var(--ink);
  background: #f8fafc;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
}

.pause-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.pause-btn.primary {
  background: linear-gradient(180deg, #ff7b3b 0%, #f04e18 100%);
  color: #fff;
}

.pause-btn.danger {
  background: #ffe4e6;
  color: #be123c;
}

.help-tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.help-tab-btn {
  font-family: inherit;
  flex: 1 1 80px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #f1f5f9;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.help-tab-btn.active {
  background: var(--accent-yellow);
}

.help-card {
  background: #f8fafc;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
  margin-bottom: 8px;
}

.help-card h4 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 900;
}

.help-card kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0 5px;
  border: 1.5px solid var(--ink);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: #f8fafc;
}

.setting-info {
  min-width: 0;
}

.setting-label {
  font-size: 12.5px;
  font-weight: 900;
}

.setting-desc {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.setting-btn {
  font-family: inherit;
  flex-shrink: 0;
  min-width: 76px;
  min-height: 36px;
  padding: 5px 12px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #e2e8f0;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}

.setting-btn.is-on {
  background: var(--accent-green);
  color: #fff;
}

.setting-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.preset-list,
.book-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.preset-item {
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 2.5px 0 var(--ink);
}

.book-card {
  padding: 8px 11px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: #f8fafc;
}

.book-card.unlocked {
  background: #fff9db;
  border-color: #d9480f;
}

.replay-badge {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  background: #e03131;
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 900;
  z-index: 22;
  display: none;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  letter-spacing: 0.04em;
}

.replay-badge.active {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#photo-studio-bar {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  display: none;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.96);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 6px 8px;
  box-shadow: 0 4px 0 var(--ink);
  max-width: 96vw;
  overflow-x: auto;
  scrollbar-width: none;
}
#photo-studio-bar.active {
  display: flex;
}
#photo-studio-bar::-webkit-scrollbar { display: none; }

.gp-bracket-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  flex: 1 1 220px;
}

.gp-bracket-bar.active {
  display: flex;
}

.gp-step {
  padding: 4px 8px;
  border-radius: 9px;
  border: 2px solid var(--ink);
  background: #f1f5f9;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
  flex-shrink: 0;
}
.gp-step.current {
  background: var(--accent-yellow);
  border-color: #d9480f;
}
.gp-step.won {
  background: #dcfce7;
  color: #15803d;
}

.modal-subtabs {
  display: flex;
  gap: 6px;
  margin-bottom: 9px;
}

.subtab-btn {
  font-family: inherit;
  flex: 1;
  padding: 6px 8px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #f1f5f9;
  font-size: 11.5px;
  font-weight: 900;
  cursor: pointer;
}
.subtab-btn.active {
  background: var(--accent-yellow);
}

.swatch-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2.5px solid var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}

.color-swatch.selected {
  outline: 3px solid var(--accent-orange);
  outline-offset: 2px;
}

.head-style-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.ffa-rival-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 1px;
}
.ffa-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  font-weight: 900;
}
.ffa-row.out {
  opacity: 0.42;
  text-decoration: line-through;
}
.ffa-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  flex-shrink: 0;
}
.ffa-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ffa-bar-wrap {
  width: 48px;
  height: 6px;
  background: #e2e8f0;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.ffa-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b, #f03e3e);
  transition: width 0.12s ease;
}
.part-card.locked-part {
  opacity: 0.62;
  background: #f1f5f9;
  border-style: dashed;
}
.color-swatch.locked-swatch {
  opacity: 0.45;
  position: relative;
  border-style: dashed;
}

.code-textarea {
  width: 100%;
  height: 88px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  resize: none;
  margin-bottom: 8px;
}

/* Mobile Portrait Optimizations (No max-height: 450px landscape override — handled by orient.js) */
@media (max-width: 620px) {
  .code-textarea {
    font-size: 16px;
  }
  .title-cta-grid,
  .title-actions {
    gap: 6px;
  }
  .title-cta {
    min-height: 56px;
    font-size: 12.5px;
    padding: 7px 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop,
  .modal-box {
    animation: none !important;
    transition: none !important;
  }
}
