:root {
  color-scheme: dark;
  --ink: #f7f2df;
  --muted: #b9c2cf;
  --bg: #050911;
  --panel: rgba(9, 18, 31, 0.94);
  --panel-soft: rgba(15, 28, 45, 0.88);
  --line: #3c526b;
  --gold: #f0c45c;
  --gold-deep: #9b6721;
  --blue: #4da3ff;
  --red: #ef5b55;
  --green: #70d67b;
  --purple: #ad78ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(44, 83, 128, 0.34), transparent 34rem),
    linear-gradient(180deg, #080f1c, #03060b 80%);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #8bc9ff;
  outline-offset: 3px;
}

img {
  display: block;
  max-width: 100%;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.game-app {
  min-height: 100vh;
}

.game-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 14px calc(28px + env(safe-area-inset-bottom));
}

.screen {
  animation: screen-in 320ms ease-out both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.title-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: max(24px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
  overflow: visible;
}

.title-art {
  position: relative;
  width: 100%;
  height: auto;
  max-height: min(68dvh, 660px);
  aspect-ratio: 1672 / 941;
  object-fit: contain;
  object-position: center center;
  border: 1px solid rgba(240, 196, 92, 0.45);
  border-radius: 18px;
  filter: saturate(0.98) brightness(0.94);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

.title-screen::after {
  content: none;
}

.title-panel {
  position: relative;
  z-index: 1;
  width: min(96%, 700px);
  padding: 18px 22px 20px;
  text-align: center;
  border: 1px solid rgba(240, 196, 92, 0.62);
  border-radius: 18px;
  background: rgba(4, 10, 18, 0.9);
  box-shadow: var(--shadow), inset 0 0 24px rgba(240, 196, 92, 0.08);
  backdrop-filter: blur(8px);
}

.title-kicker,
.section-kicker {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.title-panel h1 {
  margin: 0;
  color: var(--gold);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: clamp(0.9rem, 2.4vw, 1.08rem);
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 #000;
}

.title-panel h1 small {
  display: inline-block;
  color: var(--gold);
  font-family: system-ui, sans-serif;
  font-size: 0.72em;
  letter-spacing: 0.08em;
  vertical-align: 0.3em;
}

.title-intro {
  margin: 7px 0 0;
  color: #fff9e8;
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  font-weight: 900;
  line-height: 1.35;
  text-shadow: 0 2px 0 #000;
}

.title-lead {
  margin: 7px auto 15px;
  max-width: 34rem;
  color: #d9e3ec;
  line-height: 1.65;
}

.title-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.option-button,
.battle-command {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform 130ms ease, filter 130ms ease, border-color 130ms ease;
  touch-action: manipulation;
}

.primary-button {
  color: #161005;
  border-color: #ffe69b;
  background: linear-gradient(180deg, #ffe38b, #d79a2f);
  box-shadow: inset 0 1px #fff7cf, 0 6px 20px rgba(222, 159, 51, 0.24);
}

.secondary-button {
  color: #eaf4ff;
  border-color: #567b9f;
  background: linear-gradient(180deg, #25486a, #142b43);
}

.ghost-button {
  color: #dce8f3;
  border-color: #516274;
  background: rgba(12, 24, 38, 0.82);
}

.danger-button {
  color: #fff0ea;
  border-color: #9e453e;
  background: linear-gradient(180deg, #6f2927, #3e1718);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.option-button:hover,
.battle-command:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none !important;
  filter: none !important;
}

.fine-print,
.disclaimer {
  color: #9eabba;
  font-size: 0.77rem;
  line-height: 1.55;
}

.disclaimer {
  padding: 13px 15px;
  border-left: 3px solid #a57935;
  background: rgba(17, 25, 36, 0.74);
}

.setup-header,
.page-header {
  padding: max(22px, env(safe-area-inset-top)) 2px 14px;
}

.setup-header h1,
.page-header h1,
.event-copy h1,
.result-copy h1 {
  margin: 0;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: clamp(1.55rem, 6vw, 2.4rem);
  line-height: 1.25;
}

.setup-header p,
.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.setup-steps {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-body {
  padding: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(30, 57, 83, 0.72), rgba(12, 23, 38, 0.76));
  font-size: 1rem;
}

.step-number {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  margin-right: 8px;
  border-radius: 50%;
  color: #251b08;
  background: var(--gold);
}

.selection-count,
.sum-badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid #526b83;
  border-radius: 999px;
  color: #d7e8f8;
  background: #10243a;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.sum-badge.is-valid {
  color: #d9ffe1;
  border-color: #438d53;
  background: #153d22;
}

.sum-badge.is-invalid {
  color: #ffe6df;
  border-color: #aa5047;
  background: #4a1e1d;
}

.job-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.job-stat-guide {
  margin: 0 0 12px;
  border: 1px solid #4a6076;
  border-radius: 10px;
  color: #dbe5ed;
  background: rgba(12, 28, 44, 0.78);
  overflow: hidden;
}

.job-stat-guide summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  color: #f0d38a;
  font-size: 0.8rem;
  font-weight: 850;
  list-style: none;
  cursor: pointer;
  touch-action: manipulation;
}

.job-stat-guide summary::-webkit-details-marker {
  display: none;
}

.job-stat-guide summary::after {
  content: "＋";
  display: grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #6c7f91;
  border-radius: 50%;
  color: #f2c75e;
  line-height: 1;
}

.job-stat-guide[open] summary {
  border-bottom: 1px solid #354b60;
  background: rgba(185, 147, 63, 0.08);
}

.job-stat-guide[open] summary::after {
  content: "−";
}

.job-stat-guide summary:focus-visible {
  outline: 3px solid rgba(242, 199, 94, 0.72);
  outline-offset: -3px;
}

.job-stat-guide-content {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.job-stat-guide-content section {
  min-width: 0;
}

.job-stat-guide-content h3 {
  margin: 0 0 4px;
  color: #f4f0e5;
  font-size: 0.78rem;
}

.job-stat-guide-content p {
  margin: 0;
  color: #b9c8d4;
  font-size: 0.72rem;
  line-height: 1.65;
}

.job-stat-guide-content small {
  padding-top: 9px;
  border-top: 1px solid #32475b;
  color: #91a5b6;
  font-size: 0.66rem;
  line-height: 1.55;
}

.job-card {
  position: relative;
  display: block;
  min-width: 0;
  border: 2px solid #33465b;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  text-align: left;
  background: #0b1522;
  cursor: pointer;
  touch-action: manipulation;
}

.job-card:focus-visible {
  outline: 3px solid rgba(242, 199, 94, 0.78);
  outline-offset: 3px;
}

.job-card[aria-pressed="true"] {
  border-color: var(--job-color, var(--gold));
  background: color-mix(in srgb, var(--job-color) 9%, #0b1522);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08), 0 0 22px color-mix(in srgb, var(--job-color) 36%, transparent);
}

.job-card-image-wrap {
  position: relative;
  display: block;
}

.job-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center 31%;
  filter: brightness(0.83);
}

.job-card[aria-pressed="true"] img {
  filter: brightness(1);
}

.job-card-copy {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.job-card-heading,
.job-card-title,
.job-card-meta {
  display: block;
}

.job-card-description {
  display: -webkit-box;
  min-height: 2.9em;
  overflow: hidden;
  color: #c3d0db;
  font-size: 0.7rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.job-card-title {
  font-size: 0.9rem;
  line-height: 1.35;
}

.job-card[aria-pressed="true"] .job-card-title {
  color: color-mix(in srgb, var(--job-color) 72%, white);
}

.job-card-meta {
  margin-top: 2px;
  color: #9eb0c2;
  font-size: 0.73rem;
}

.job-stats {
  display: grid;
  gap: 5px;
}

.job-stat-row {
  display: grid;
  grid-template-columns: 76px 30px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.job-stat-label {
  display: flex;
  gap: 4px;
  align-items: center;
  color: #c4d0db;
  font-size: 0.68rem;
  font-weight: 750;
  white-space: nowrap;
}

.job-stat-value {
  color: #f6f2e7;
  font-size: 0.8rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
}

.job-stat-track {
  display: block;
  min-width: 0;
  height: 6px;
  overflow: hidden;
  border: 1px solid #31465b;
  border-radius: 999px;
  background: #101e2d;
}

.job-stat-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.job-stat-attack .job-stat-track > span {
  background: linear-gradient(90deg, #a84f3c, #e49a5e);
}

.job-stat-defense .job-stat-track > span {
  background: linear-gradient(90deg, #3973a5, #6eafe0);
}

.job-stat-stability .job-stat-track > span {
  background: linear-gradient(90deg, #39774e, #72bd82);
}

.job-check {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 50%;
  background: rgba(3, 8, 14, 0.8);
  font-weight: 900;
}

.job-card[aria-pressed="true"] .job-check {
  color: #12200d;
  background: var(--job-color, var(--gold));
}

.support-job-section {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #35485d;
}

.support-job-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.support-job-heading .section-kicker {
  margin-bottom: 2px;
}

.support-job-heading h3 {
  margin: 0;
  color: #eef4f8;
  font-size: 0.95rem;
}

.support-job-heading > span,
.support-slot-badge {
  border: 1px solid #4f7e45;
  border-radius: 999px;
  color: #dffbd3;
  background: rgba(40, 83, 40, 0.9);
  font-size: 0.68rem;
  font-weight: 850;
  white-space: nowrap;
}

.support-job-heading > span {
  padding: 5px 8px;
}

.support-slot-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 5px 9px;
}

.support-job-layout {
  display: grid;
  gap: 10px;
}

.support-job-layout > p {
  align-self: center;
  margin: 0;
  color: #b8c8d5;
  font-size: 0.76rem;
  line-height: 1.65;
}

.support-job-card {
  cursor: default;
}

.support-job-card img {
  filter: brightness(0.96);
}

.allocation-list {
  display: grid;
  gap: 11px;
}

.allocation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid #344a60;
  border-radius: 10px;
  background: #0b1826;
}

.allocation-name {
  min-width: 0;
}

.allocation-name strong,
.allocation-name span {
  display: block;
}

.allocation-name span {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stepper button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #55728e;
  border-radius: 8px;
  color: white;
  background: #18334e;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 900;
}

.money-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.money-stepper button {
  width: 40px;
  height: 42px;
  padding: 0;
  border: 1px solid #55728e;
  border-radius: 8px;
  color: white;
  background: #18334e;
  font-size: 1.2rem;
}

.money-stepper label,
.policy-input {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #b9c9d7;
  font-size: 0.76rem;
}

.money-stepper input,
.policy-input input {
  width: 78px;
  min-height: 42px;
  border: 1px solid #58718a;
  border-radius: 8px;
  padding: 7px;
  color: white;
  background: #081522;
  text-align: right;
  font: inherit;
  font-weight: 900;
}

.policy-input input { width: 54px; }

.computed-level {
  min-width: 45px;
  color: var(--gold);
  text-align: right;
  font-size: 0.8rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.cash-allocation {
  border-color: color-mix(in srgb, #79b84c 58%, #344a60);
  background: color-mix(in srgb, #79b84c 7%, #0b1826);
}

.level-value {
  min-width: 58px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.allocation-bar {
  display: flex;
  width: 100%;
  height: 13px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid #617185;
  border-radius: 999px;
  background: #050b12;
}

.allocation-bar span {
  min-width: 0;
  transition: width 180ms ease;
}

.input-grid {
  display: grid;
  gap: 12px;
}

.field-label {
  display: grid;
  gap: 6px;
  color: #dbe7f1;
  font-size: 0.87rem;
  font-weight: 700;
}

.field-label input,
.field-label select {
  min-height: 50px;
  width: 100%;
  border: 1px solid #58718a;
  border-radius: 9px;
  padding: 9px 12px;
  color: white;
  background: #081522;
  font-size: 1rem;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 12px;
}

.preset-button {
  min-height: 42px;
  padding: 7px;
  border-color: #4f6880;
  color: #dbe8f3;
  background: #10243a;
}

.preset-button.is-selected {
  border-color: var(--gold);
  color: #241a08;
  background: var(--gold);
}

.fixed-contribution {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #8a713d;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(240, 196, 92, 0.14), rgba(20, 38, 57, 0.86));
}

.fixed-contribution strong {
  color: #ffe194;
}

.fixed-contribution span {
  color: #c6d3df;
  font-size: 0.78rem;
  line-height: 1.5;
}

.confirmation-total {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  color: #c4d2df;
}

.confirmation-total strong { color: var(--gold); }

.confirmation-list {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.confirmation-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid #34495e;
  border-radius: 7px;
  background: #091522;
  font-size: 0.8rem;
}

.stat-preview,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat-box {
  min-width: 0;
  padding: 10px 6px;
  border: 1px solid #3e5368;
  border-radius: 9px;
  text-align: center;
  background: rgba(8, 18, 29, 0.78);
}

.stat-box span,
.stat-box strong {
  display: block;
}

.stat-box span {
  color: #9fafbf;
  font-size: 0.68rem;
}

.stat-box strong {
  margin-top: 2px;
  font-size: 1.06rem;
  font-variant-numeric: tabular-nums;
}

.setup-footer {
  display: grid;
  gap: 12px;
  padding: 4px 0 30px;
}

.setup-footer .primary-button {
  width: 100%;
}

.status-shell {
  position: sticky;
  z-index: 20;
  top: 0;
  margin: 0 -14px;
  padding: max(8px, env(safe-area-inset-top)) 14px 9px;
  border-bottom: 1px solid #425a72;
  background: rgba(4, 10, 17, 0.94);
  backdrop-filter: blur(12px);
}

.status-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
}

.year-badge {
  color: var(--gold);
  font-weight: 900;
  white-space: nowrap;
}

.asset-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 800;
}

.hud-note {
  color: #a8b8c6;
  font-size: 0.72rem;
}

.money-hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
}

.hud-metric {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid #344d66;
  border-radius: 7px;
  background: rgba(10, 25, 40, 0.86);
}

.hud-metric span,
.hud-metric strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-metric span {
  color: #aebdca;
  font-size: 0.62rem;
}

.hud-metric strong {
  margin-top: 1px;
  color: #f6e2aa;
  font-size: clamp(0.73rem, 3vw, 0.92rem);
  font-variant-numeric: tabular-nums;
}

.hp-cluster {
  display: inline-grid;
  grid-template-columns: max-content minmax(150px, 240px) max-content;
  column-gap: 10px;
  align-items: center;
  width: auto;
  max-width: 100%;
  margin-top: 7px;
  font-size: 0.72rem;
  font-weight: 800;
}

.hp-label,
.hp-value {
  white-space: nowrap;
}

.hp-meter {
  width: 100%;
}

.meter {
  position: relative;
  height: 12px;
  overflow: hidden;
  border: 1px solid #687789;
  border-radius: 999px;
  background: #120b0c;
}

.meter > span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: linear-gradient(90deg, #d64b46, #efc85c 56%, #69d477);
  transition: width 260ms ease;
}

.journey-progress {
  height: 3px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #1d2d3e;
}

.journey-progress span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--gold);
}

.main-stack {
  display: grid;
  gap: 14px;
  padding-top: 14px;
}

.portfolio-strip {
  padding: 12px;
  border: 1px solid #344d66;
  border-radius: 12px;
  background: rgba(8, 18, 30, 0.9);
}

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

.portfolio-strip-head strong {
  font-size: 0.82rem;
}

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

.level-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--chip-color) 65%, #314050);
  border-radius: 7px;
  background: color-mix(in srgb, var(--chip-color) 12%, #08131f);
  font-size: 0.73rem;
  font-weight: 800;
}

.party-details {
  margin-top: 11px;
  border-top: 1px solid #30465b;
}

.party-details summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  color: #d6e3ee;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
}

.party-details summary span {
  color: #aabac8;
  font-size: 0.68rem;
  font-weight: 600;
}

.table-scroll {
  margin-top: 9px;
  overflow-x: auto;
}

.party-details table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.party-details th,
.party-details td {
  padding: 7px 8px;
  border-bottom: 1px solid #2d4256;
  text-align: right;
  white-space: nowrap;
}

.party-details th:first-child,
.party-details tbody th { text-align: left; }

.event-hero,
.battle-stage,
.result-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid #5c4a2b;
  border-radius: 15px;
  background: #05080d;
  box-shadow: var(--shadow);
}

.event-hero img,
.result-hero img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: center 24%;
}

.event-hero::after,
.result-hero::after {
  content: "";
  position: absolute;
  inset: 40% 0 0;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(3, 7, 12, 0.94));
}

.event-copy,
.result-copy {
  position: relative;
  z-index: 1;
  margin-top: -92px;
  padding: 16px;
}

.event-copy p,
.result-copy p {
  margin: 7px 0 0;
  color: #d7e0e8;
  line-height: 1.55;
}

.navigator {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px 10px 10px;
  border: 1px solid color-mix(in srgb, var(--nav-color) 68%, #44505c);
  border-radius: 12px;
  background: color-mix(in srgb, var(--nav-color) 10%, #09131f);
}

.navigator-portrait {
  width: 70px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--nav-color) 70%, white);
  border-radius: 14px;
  background: #d8d9dc;
  box-shadow: 0 0 0 2px rgba(4, 9, 15, 0.68), 0 5px 14px rgba(0, 0, 0, 0.3);
}

.navigator-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.navigator-copy strong {
  display: block;
  color: color-mix(in srgb, var(--nav-color) 78%, white);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

.navigator-copy strong span {
  display: inline-block;
  margin-left: 0.35em;
  color: #bac7d2;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.navigator-copy p {
  margin: 3px 0 0;
  line-height: 1.55;
}

.option-grid {
  display: grid;
  gap: 9px;
}

.allocation-comparison {
  padding: 14px;
  border: 1px solid #6d5593;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(49, 31, 78, 0.72), rgba(9, 20, 33, 0.94));
}

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

.comparison-head h2 {
  margin: 0;
  font-size: 1rem;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(82px, 1fr) auto auto auto 42px;
  gap: 7px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed #51466b;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.comparison-row em {
  color: #b8c6d2;
  text-align: right;
  font-style: normal;
  font-weight: 900;
}

.comparison-row em.is-over { color: #ff9c8f; }
.comparison-row em.is-under { color: #7fd4ff; }

.allocation-comparison > p {
  margin: 11px 0 0;
  color: #c5d0dc;
  font-size: 0.76rem;
  line-height: 1.55;
}

.option-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  text-align: left;
  border-color: #49657f;
  background: linear-gradient(180deg, #15304a, #0d2033);
}

.option-button strong,
.option-button span {
  display: block;
}

.option-button span {
  margin-top: 3px;
  color: #aec0d0;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}

.option-reward {
  align-self: center;
  color: var(--gold);
  font-size: 0.78rem;
  white-space: nowrap;
}

.battle-layout {
  display: grid;
  gap: 12px;
}

.battle-stage {
  min-height: 318px;
}

.battle-art,
.monster-fallback {
  width: 100%;
  height: 100%;
  min-height: 318px;
  max-height: 560px;
  object-fit: cover;
  object-position: center 28%;
}

.monster-fallback {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle, rgba(103, 78, 148, 0.48), transparent 32%),
    repeating-linear-gradient(135deg, #120e1c 0 16px, #0a0b12 16px 32px);
  color: #b991ff;
  font-family: Georgia, serif;
  font-size: 8rem;
}

.battle-stage::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(transparent, rgba(3, 5, 10, 0.97));
}

.enemy-hud {
  position: absolute;
  z-index: 2;
  inset: auto 12px 12px;
  padding: 12px;
  border: 1px solid #7f5f35;
  border-radius: 11px;
  background: rgba(3, 7, 12, 0.88);
  backdrop-filter: blur(8px);
}

.enemy-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.enemy-head h1 {
  min-width: 0;
  margin: 0;
  font-size: clamp(1.15rem, 5vw, 1.65rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enemy-tag {
  color: #ffb59f;
  font-size: 0.73rem;
  font-weight: 900;
  white-space: nowrap;
}

.enemy-hp-line {
  display: grid;
  grid-template-columns: auto minmax(70px, 1fr) auto;
  gap: 7px;
  align-items: center;
  margin-top: 9px;
  font-size: 0.72rem;
  font-weight: 900;
}

.enemy-meter > span {
  background: linear-gradient(90deg, #a7272a, #ef6c45);
}

.battle-info {
  display: grid;
  gap: 10px;
}

.battle-summary {
  padding: 12px;
  border: 1px solid #40556c;
  border-radius: 11px;
  background: var(--panel-soft);
}

.battle-summary p {
  margin: 0;
  color: #c9d4df;
  font-size: 0.84rem;
  line-height: 1.5;
}

.market-impact {
  display: grid;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid #376b67;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(18, 61, 58, 0.68), rgba(8, 21, 32, 0.94));
}

.market-impact > div:first-child strong,
.market-impact > div:first-child small {
  display: block;
}

.market-impact > div:first-child small {
  margin-top: 2px;
  color: #a8c6c4;
  font-size: 0.68rem;
}

.market-rate-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.market-rate-chips span {
  padding: 4px 7px;
  border: 1px solid #48766f;
  border-radius: 999px;
  color: #d6eeeb;
  background: rgba(5, 18, 25, 0.64);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.market-rate-chips strong {
  margin-right: 4px;
}

.battle-turnline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.battle-command {
  min-height: 62px;
  padding: 9px 10px;
  text-align: left;
  border-color: #4e6880;
  background: linear-gradient(180deg, #173450, #0d2236);
}

.battle-command strong,
.battle-command span {
  display: block;
}

.battle-command strong {
  font-size: 0.88rem;
}

.battle-command span {
  margin-top: 3px;
  color: #aebdcb;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.35;
}

.battle-command.conserve { border-color: #568451; }
.battle-command.extra { border-color: #b68b3e; }
.battle-command.retreat { border-color: #8c4746; background: linear-gradient(180deg, #4c2528, #2b171c); }

.battle-log {
  max-height: 160px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid #374a5e;
  border-radius: 10px;
  background: #060d15;
  color: #c8d4df;
  font-size: 0.77rem;
  line-height: 1.55;
  scrollbar-color: #566b7e #07101a;
}

.battle-log p {
  margin: 0;
}

.battle-log p + p {
  margin-top: 4px;
}

.outcome-card {
  padding: 16px;
  border: 1px solid #54708b;
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(20, 48, 70, 0.95), rgba(8, 18, 29, 0.97));
}

.outcome-card h2 {
  margin: 0;
  color: var(--gold);
  font-family: Georgia, "Yu Mincho", serif;
}

.outcome-card p {
  margin: 7px 0 0;
  line-height: 1.55;
}

.learning-summary {
  clear: both;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #4776a2;
  border-radius: 10px;
  background: rgba(7, 24, 39, 0.86);
}

.learning-summary h3 {
  margin: 0;
  color: #8cc8ff;
  font-size: 0.95rem;
}

.learning-summary ul {
  display: grid;
  gap: 6px;
  margin: 7px 0 0;
  padding-left: 1.2rem;
  color: #d1dbe4;
  font-size: 0.78rem;
  line-height: 1.5;
}

.learning-summary .catch-up-note {
  color: #f4cf77;
  font-size: 0.72rem;
  font-weight: 900;
}

.reward-thumbnail {
  float: right;
  width: 82px;
  aspect-ratio: 1;
  margin: 0 0 8px 12px;
  border: 1px solid #9b7b3b;
  border-radius: 9px;
  object-fit: cover;
  object-position: center 34%;
}

.learn-link {
  display: inline-flex;
  margin-top: 9px;
  color: #8cc8ff;
  font-size: 0.8rem;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-decoration: underline;
}

.result-articles {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid #415e78;
  border-radius: 11px;
  background: #091827;
}

.result-articles h2 {
  margin: 0;
  color: #9dd2ff;
  font-size: 1rem;
}

.result-articles p {
  margin: 5px 0 10px;
  color: #b9c8d5;
  font-size: 0.76rem;
  line-height: 1.5;
}

.result-articles > div {
  display: grid;
  gap: 7px;
}

.result-article-link {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #4f718e;
  border-radius: 8px;
  color: #a9d7ff;
  text-align: left;
  text-decoration: none;
  background: #0d2234;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
}

.result-layout {
  display: grid;
  gap: 14px;
  padding-top: max(12px, env(safe-area-inset-top));
}

.score-card {
  padding: 16px;
  border: 1px solid #78603a;
  border-radius: 14px;
  background: linear-gradient(145deg, #14263a, #09121e);
  box-shadow: var(--shadow);
}

.score-hero {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.rank-medal {
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
  border: 3px solid #ffe597;
  border-radius: 50%;
  color: #fff3bd;
  background: radial-gradient(circle, #8b5b22, #33200c);
  box-shadow: 0 0 24px rgba(240, 196, 92, 0.3);
  font-family: Georgia, serif;
  font-size: 2.5rem;
  font-weight: 900;
}

.score-main strong,
.score-main span {
  display: block;
}

.score-main strong {
  color: var(--gold);
  font-size: 1.15rem;
}

.score-main span {
  margin-top: 5px;
  color: #dbe6ee;
}

.score-total {
  margin-top: 6px;
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.score-breakdown {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed #3b5064;
  font-size: 0.84rem;
}

.score-row strong {
  color: #f6d586;
  font-variant-numeric: tabular-nums;
}

.result-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.number-card {
  padding: 12px;
  border: 1px solid #415970;
  border-radius: 10px;
  background: #0a1724;
}

.number-card span,
.number-card strong {
  display: block;
}

.number-card span {
  color: #9fafbd;
  font-size: 0.7rem;
}

.number-card strong {
  margin-top: 4px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.help-dialog {
  width: min(92vw, 680px);
  max-height: 85vh;
  padding: 0;
  overflow: auto;
  border: 1px solid #637891;
  border-radius: 14px;
  color: var(--ink);
  background: #09131f;
  box-shadow: 0 24px 90px #000;
}

.help-dialog::backdrop {
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(4px);
}

.help-dialog-body {
  padding: 20px;
}

.help-dialog h2 {
  margin: 0;
  font-family: Georgia, "Yu Mincho", serif;
}

.help-dialog h3 {
  margin: 19px 0 6px;
  color: var(--gold);
  font-size: 0.95rem;
}

.help-dialog p,
.help-dialog li {
  color: #c4d0db;
  line-height: 1.6;
}

.help-dialog ul {
  padding-left: 1.3rem;
}

.error-message {
  padding: 11px 13px;
  border: 1px solid #a64e48;
  border-radius: 9px;
  color: #ffe3dc;
  background: #401c1c;
  font-size: 0.82rem;
}

.flash {
  animation: flash 380ms ease-out;
}

@keyframes flash {
  0%, 100% { filter: none; }
  35% { filter: brightness(1.55) saturate(0.6); }
}

@media (min-width: 680px) {
  .game-shell { padding-inline: 20px; }
  .job-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-stat-guide-content { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .job-stat-guide-content small { grid-column: 1 / -1; }
  .support-job-layout { grid-template-columns: minmax(0, 1fr) minmax(170px, 0.9fr); }
  .input-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-steps { gap: 22px; }
  .battle-layout { grid-template-columns: minmax(0, 1.28fr) minmax(310px, 0.72fr); align-items: start; }
  .battle-info { position: sticky; top: 150px; }
  .battle-stage, .battle-art, .monster-fallback { min-height: 590px; }
  .battle-art { max-height: 720px; }
  .event-hero img, .result-hero img { aspect-ratio: 16 / 8.5; }
  .option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-layout { grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr); align-items: start; }
  .result-hero img { aspect-ratio: 4 / 5; max-height: 760px; }
  .result-hero .result-copy { margin-top: -125px; }
  .score-card { position: sticky; top: 20px; }
}

@media (min-width: 980px) {
  .setup-steps { grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr); align-items: start; }
  .setup-steps .job-panel { grid-row: span 4; }
  .job-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-card img { aspect-ratio: 16 / 9; }
}

@media (max-width: 560px) {
  .title-screen {
    min-height: 100dvh;
    justify-content: flex-start;
    gap: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .title-art {
    max-height: none;
    border-radius: 12px;
    object-fit: contain;
    object-position: center center;
  }
  .title-panel {
    width: min(96%, 620px);
    padding: 15px 14px 17px;
  }
  .title-lead { font-size: 0.83rem; }
  .allocation-row { grid-template-columns: 1fr; }
  .stepper, .money-stepper { justify-content: space-between; }
  .computed-level { width: 100%; text-align: left; }
  .hp-cluster {
    grid-template-columns: max-content minmax(70px, 1fr) max-content;
    column-gap: 8px;
    width: 100%;
  }
  .comparison-head { align-items: flex-start; flex-direction: column; }
  .comparison-row { grid-template-columns: minmax(64px, 1fr) auto auto 34px; gap: 5px; }
  .comparison-row > :nth-child(3) { display: none; }
}

@media (max-width: 440px) {
  .job-grid { grid-template-columns: 1fr; }
  .support-job-heading { align-items: flex-start; flex-direction: column; }
  .job-card-description { min-height: 0; }
  .job-stat-label { font-size: 0.72rem; }
  .job-stat-value { font-size: 0.8rem; }
}

@media (max-width: 380px) {
  .game-shell { padding-inline: 10px; }
  .status-shell { margin-inline: -10px; padding-inline: 10px; }
  .job-grid { gap: 7px; }
  .job-card-copy { padding: 8px; }
  .allocation-row { grid-template-columns: 1fr; }
  .stepper, .money-stepper { justify-content: space-between; }
  .computed-level { width: 100%; text-align: left; }
  .hud-note { display: none; }
  .hp-cluster { font-size: 0.66rem; }
  .party-details summary span { display: none; }
  .command-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
