:root {
  color-scheme: dark;
  font-family:
    ui-serif, Georgia, "Times New Roman", serif;
  background: #08100d;
  color: #edf3e7;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}
html,
body {
  min-height: 100%;
  margin: 0;
}
body {
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(
      circle at 18% 10%,
      rgba(77, 121, 92, 0.22),
      transparent 30rem
    ),
    radial-gradient(
      circle at 80% 88%,
      rgba(117, 88, 45, 0.18),
      transparent 32rem
    ),
    linear-gradient(145deg, #07100d 0%, #111b16 52%, #0b1210 100%);
}
button {
  font: inherit;
}
button:focus-visible {
  outline: 2px solid #d9c58a;
  outline-offset: 3px;
}

.app-shell {
  width: min(100% - 28px, 1120px);
  margin: 0 auto;
  padding: 28px 0 56px;
}

.panel {
  border: 1px solid rgba(206, 220, 190, 0.18);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 38px);
  background: rgba(11, 20, 16, 0.88);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.hero {
  min-height: min(720px, calc(100vh - 56px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.kicker,
.small-label,
.status-label {
  margin: 0;
  color: #a9b99e;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-title {
  margin: 14px 0 10px;
  font-size: clamp(2.7rem, 10vw, 6.8rem);
  line-height: 0.98;
  font-weight: 700;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.hero-subtitle,
.panel-hint {
  max-width: 720px;
  color: #c6d0bf;
  line-height: 1.75;
}
.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
}
.hero-marks,
.effect-row,
.selected-talents,
.achievement-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hero-marks {
  margin: 22px 0 36px;
}
.mark,
.effect-chip,
.talent-pill,
.achievement {
  border: 1px solid rgba(207, 221, 193, 0.16);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(235, 242, 223, 0.06);
  color: #dbe5d3;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.82rem;
}
.profile-line {
  margin: 0 0 16px;
  color: #a8b4a1;
}

.button {
  border: 1px solid rgba(224, 230, 201, 0.22);
  border-radius: 14px;
  min-height: 46px;
  padding: 11px 18px;
  background: rgba(238, 244, 221, 0.07);
  color: #f1f4e8;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}
.button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(238, 244, 221, 0.12);
}
.button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.button-primary {
  background: linear-gradient(135deg, #d8c58a, #a9bd85);
  border-color: transparent;
  color: #111710;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 800;
}

.panel-header {
  margin-bottom: 24px;
}
.panel-title {
  margin: 9px 0 8px;
  font-size: clamp(2rem, 6vw, 3.5rem);
  letter-spacing: -0.04em;
}
.panel-hint {
  margin: 0;
}
.selection-count {
  color: #d9c58a;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
}

.talent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.talent-card {
  min-height: 112px;
  padding: 16px;
  text-align: left;
  color: inherit;
  border: 1px solid rgba(207, 221, 193, 0.15);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}
.talent-card:hover:not(:disabled) {
  border-color: rgba(217, 197, 138, 0.5);
}
.talent-card.selected {
  border-color: #d9c58a;
  background: rgba(217, 197, 138, 0.11);
}
.talent-card:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.talent-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.talent-name {
  font-size: 1.06rem;
}
.rarity {
  color: #a8b99f;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.74rem;
  white-space: nowrap;
}
.effect-row {
  margin-top: 18px;
}
.effect-chip {
  padding: 4px 8px;
  font-size: 0.72rem;
}
.rarity-epic {
  box-shadow: inset 0 0 28px rgba(195, 150, 235, 0.05);
}
.rarity-rare {
  box-shadow: inset 0 0 28px rgba(108, 166, 220, 0.05);
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}
.selected-talents {
  align-items: center;
  margin: 14px 0 24px;
}
.selected-talents.compact {
  margin: 14px 0 18px;
}

.stat-grid {
  display: grid;
  gap: 10px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 62px;
  padding: 10px 12px 10px 18px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(207, 221, 193, 0.1);
}
.stat-controls {
  display: grid;
  grid-template-columns: 40px 52px 40px;
  gap: 6px;
  align-items: center;
}
.step-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(207, 221, 193, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #eef3e8;
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 1.15rem;
}
.step-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.stat-value {
  text-align: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.status-item {
  min-height: 64px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(207, 221, 193, 0.08);
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.status-item strong {
  font-size: 0.96rem;
}

.event-card {
  margin-top: 20px;
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid rgba(217, 197, 138, 0.23);
  border-radius: 20px;
  background: linear-gradient(
    145deg,
    rgba(217, 197, 138, 0.07),
    rgba(255, 255, 255, 0.025)
  );
}
.run-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(207, 221, 193, 0.09);
}
.run-mode-label {
  color: #9eaa98;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.run-mode-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(207, 221, 193, 0.12);
  border-radius: 11px;
  background: rgba(4, 10, 7, 0.34);
}
.run-mode-button {
  min-width: 72px;
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9eaa98;
  cursor: pointer;
  font:
    700 0.78rem/1 ui-sans-serif,
    system-ui,
    sans-serif;
}
.run-mode-button:hover {
  color: #eef3e8;
}
.run-mode-button.active {
  background: rgba(217, 197, 138, 0.16);
  color: #f0dfaa;
  box-shadow: inset 0 0 0 1px rgba(217, 197, 138, 0.2);
}
.run-mode-button:focus-visible {
  outline: 2px solid #d9c58a;
  outline-offset: 2px;
}
.run-mode-status {
  margin: -8px 0 14px;
  color: #aebb9f;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
  line-height: 1.45;
}
.run-mode-status.auto-running {
  color: #d9c58a;
}
.event-text {
  min-height: 78px;
  margin: 14px 0 22px;
  font-size: clamp(1.08rem, 2.6vw, 1.35rem);
  line-height: 1.75;
}
.choice-label {
  margin: 0 0 10px;
  color: #d9c58a;
}
.choice-list {
  display: grid;
  gap: 9px;
}
.choice-button {
  text-align: left;
}

.history {
  margin-top: 28px;
}
.section-title {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #cfd8c8;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.history-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid rgba(207, 221, 193, 0.07);
  color: #cbd4c5;
  line-height: 1.55;
}
.history-turn {
  color: #83917d;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}
.history-choice {
  grid-column: 2;
  color: #a6b49e;
}

.ending-card {
  padding: 24px;
  border-radius: 20px;
  border: 1px solid rgba(217, 197, 138, 0.28);
  background: rgba(217, 197, 138, 0.08);
}
.ending-title {
  margin: 10px 0 8px;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  line-height: 1.5;
}
.ending-meta {
  margin: 0;
  color: #aebb9f;
}
.summary-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 18px 0;
}
.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  text-align: center;
}
.summary-stat span {
  color: #9eaa98;
  font-size: 0.76rem;
}
.summary-stat strong {
  font-size: 1.2rem;
}
.summary-section {
  margin: 22px 0;
}
.summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 22px 0;
  color: #899687;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
  word-break: break-all;
}
.muted {
  color: #81907c;
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 18px, 960px);
    padding-top: 10px;
    padding-bottom: 24px;
  }
  .panel {
    border-radius: 18px;
    padding: 18px 14px 24px;
  }
  .hero {
    min-height: calc(100vh - 28px);
    padding: 24px 18px;
  }
  .talent-grid {
    grid-template-columns: 1fr;
  }
  .talent-card {
    min-height: 94px;
  }
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .summary-stats {
    grid-template-columns: repeat(3, 1fr);
  }
  .history-item {
    grid-template-columns: 62px 1fr;
  }
  .button {
    width: 100%;
  }
  .actions {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* M5 visual system */
body {
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
}
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(1px);
}
body::before {
  width: min(68vw, 760px);
  aspect-ratio: 1;
  top: -38vw;
  right: -18vw;
  border: 1px solid rgba(217, 197, 138, 0.09);
  box-shadow:
    0 0 0 80px rgba(217, 197, 138, 0.015),
    0 0 0 180px rgba(217, 197, 138, 0.012);
}
body::after {
  width: 620px;
  height: 220px;
  left: -160px;
  bottom: -80px;
  border-radius: 50% 55% 0 0;
  background: linear-gradient(165deg, rgba(67, 102, 77, 0.16), transparent 70%);
  transform: rotate(-8deg);
}

.panel {
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.42), transparent 42%);
}
.panel > * {
  position: relative;
}

.brand-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand-seal,
.result-seal {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(217, 197, 138, 0.5);
  color: #d9c58a;
  font-size: 1.55rem;
  transform: rotate(5deg);
  background: rgba(217, 197, 138, 0.06);
}

.home-progress {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 0 0 22px;
}
.home-progress-item {
  min-height: 82px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(207, 221, 193, 0.12);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.025);
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.home-progress-item strong {
  font-size: 1.35rem;
  color: #eef1df;
}
.home-progress-item span {
  color: #879587;
  font-size: 0.78rem;
}
.home-actions {
  width: min(100%, 620px);
  display: grid;
  gap: 9px;
}
.home-secondary-actions,
.share-actions,
.summary-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.home-secondary-actions .button,
.share-actions .button,
.summary-actions .button {
  flex: 1 1 180px;
}

.button-secondary {
  background: rgba(238, 244, 221, 0.045);
  color: #d9e1d3;
}
.button-resume {
  border-color: rgba(217, 197, 138, 0.42);
  background: rgba(217, 197, 138, 0.1);
  color: #efe5c7;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 750;
}
.button-danger {
  border-color: rgba(214, 122, 105, 0.34);
  background: rgba(168, 75, 61, 0.11);
  color: #efc5bc;
}

.realm-track {
  display: flex;
  gap: 6px;
  margin: -8px 0 20px;
  overflow-x: auto;
  padding: 3px 1px 9px;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 197, 138, 0.2) transparent;
}
.realm-step {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(207, 221, 193, 0.08);
  color: #667368;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.68rem;
  white-space: nowrap;
}
.realm-step.reached {
  color: #9da99a;
  border-color: rgba(207, 221, 193, 0.16);
}
.realm-step.current {
  color: #171a14;
  border-color: transparent;
  background: linear-gradient(135deg, #d8c58a, #a9bd85);
  font-weight: 800;
}

.run-content-grid {
  display: grid;
  gap: 22px;
  margin-top: 20px;
}
.run-content-grid .event-card,
.run-content-grid .history {
  margin-top: 0;
}

.collection-progress {
  width: 100%;
  height: 8px;
  margin: 0 0 24px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}
.collection-progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.05);
}
.collection-progress::-webkit-progress-value {
  background: linear-gradient(90deg, #9eaf7f, #d9c58a);
}
.collection-progress::-moz-progress-bar {
  background: linear-gradient(90deg, #9eaf7f, #d9c58a);
}
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.achievement-card {
  min-height: 126px;
  padding: 17px;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid rgba(207, 221, 193, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
}
.achievement-card.unlocked {
  border-color: rgba(217, 197, 138, 0.28);
  background: rgba(217, 197, 138, 0.055);
}
.achievement-card.locked {
  opacity: 0.52;
}

.achievement-symbol {
  color: #d9c58a;
  font-size: 1.25rem;
}
.achievement-name {
  font-size: 1rem;
  line-height: 1.45;
}
.achievement-state {
  color: #7f8d80;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.settings-list {
  display: grid;
  gap: 10px;
}
.setting-row {
  min-height: 76px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid rgba(207, 221, 193, 0.1);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}
.setting-copy {
  display: grid;
  gap: 5px;
}
.setting-copy small,
.settings-note,
.danger-zone p {
  color: #8e9b8e;
  line-height: 1.55;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.setting-row input {
  width: 22px;
  height: 22px;
  accent-color: #c8b77f;
}

.settings-note {
  margin: 16px 2px 0;
  font-size: 0.82rem;
}
.danger-zone {
  margin-top: 28px;
  padding: 18px;
  border: 1px solid rgba(214, 122, 105, 0.16);
  border-radius: 16px;
  background: rgba(130, 56, 45, 0.045);
}
.danger-zone p {
  margin: 7px 0 14px;
  font-size: 0.84rem;
}

.result-preview {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  background:
    radial-gradient(circle at 84% 12%, rgba(217, 197, 138, 0.16), transparent 12rem),
    linear-gradient(150deg, rgba(217, 197, 138, 0.09), rgba(75, 109, 84, 0.08));
}
.result-preview::after {
  content: "";
  position: absolute;
  width: 64%;
  height: 80%;
  right: -10%;
  bottom: -48%;
  border: 1px solid rgba(217, 197, 138, 0.12);
  border-radius: 50% 50% 0 0;
  transform: rotate(-9deg);
}
.result-seal {
  position: absolute;
  top: 20px;
  right: 20px;
}
.share-status {
  min-height: 1.4em;
  margin: 8px 0 0;
  color: #93a28f;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
}
.copy-fallback {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
}
.summary-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

@media (min-width: 880px) {
  .run-panel {
    height: calc(100dvh - 84px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-inline: 34px;
  }
  .run-panel > .panel-header,
  .run-panel > .realm-track,
  .run-panel > .status-grid,
  .run-panel > .selected-talents {
    flex: 0 0 auto;
  }
  .run-content-grid {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr);
    align-items: stretch;
    overflow: hidden;
  }
  .run-content-grid .event-card {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .run-content-grid .history {
    min-height: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid rgba(207, 221, 193, 0.08);
  }
  .run-content-grid .history-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
  .history-item {
    grid-template-columns: 62px 1fr;
  }
}

html[data-text-scale="large"] {
  font-size: 112.5%;
}
html[data-contrast="high"] .panel,
html[data-contrast="high"] .event-card,
html[data-contrast="high"] .talent-card,
html[data-contrast="high"] .stat-row,
html[data-contrast="high"] .achievement-card,
html[data-contrast="high"] .setting-row {
  border-color: rgba(238, 244, 226, 0.34);
}
html[data-contrast="high"] .panel-hint,
html[data-contrast="high"] .hero-subtitle,
html[data-contrast="high"] .history-item,
html[data-contrast="high"] .setting-copy small {
  color: #e0e8dc;
}
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  scroll-behavior: auto !important;
  transition: none !important;
}

@media (max-width: 680px) {
  .brand-seal {
    width: 44px;
    height: 44px;
  }
  .home-progress {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .home-progress-item {
    min-height: 68px;
    padding: 10px;
  }
  .home-progress-item strong {
    font-size: 1.05rem;
  }
  .achievement-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .achievement-card {
    min-height: 112px;
    padding: 14px;
  }
  .home-secondary-actions,
  .share-actions,
  .summary-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .share-actions .button,
  .summary-actions .button,
  .home-secondary-actions .button {
    width: 100%;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .app-shell {
    width: min(100% - 14px, 1120px);
    padding: 7px 0 16px;
  }
  .panel {
    border-radius: 16px;
    padding: 13px 16px 18px;
  }
  .panel-header {
    margin-bottom: 10px;
  }
  .panel-title {
    margin: 4px 0;
    font-size: clamp(1.45rem, 5vw, 2.1rem);
  }
  .panel-hint,
  .kicker {
    display: none;
  }
  .hero {
    min-height: calc(100vh - 14px);
    padding: 18px 22px;
  }
  .hero-title {
    font-size: clamp(2.3rem, 9vw, 4.2rem);
  }
  .hero-subtitle {
    max-width: 640px;
    margin: 4px 0;
    line-height: 1.45;
  }
  .hero-marks {
    margin: 10px 0 14px;
  }
  .home-progress {
    margin-bottom: 10px;
  }
  .home-progress-item {
    min-height: 52px;
    padding: 6px 10px;
  }
  .home-actions {
    grid-template-columns: minmax(180px, 1fr) minmax(240px, 1fr);
    align-items: stretch;
  }
  .home-actions > .button {
    min-width: 180px;
  }
  .realm-track {
    margin: -3px 0 8px;
    padding-bottom: 5px;
  }
  .status-grid {
    grid-template-columns: repeat(7, minmax(84px, 1fr));
    overflow-x: auto;
  }
  .status-item {
    min-height: 48px;
    padding: 7px 9px;
  }
  .selected-talents.compact {
    margin: 7px 0 9px;
  }
  .run-content-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
    gap: 14px;
    margin-top: 10px;
  }
  .event-card {
    padding: 14px;
  }
  .event-text {
    min-height: 0;
    margin: 8px 0 12px;
    font-size: 1rem;
    line-height: 1.55;
  }
  .history-list {
    gap: 3px;
  }
  .history-item {
    padding: 5px 1px;
    font-size: 0.83rem;
  }
  .achievement-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .achievement-card {
    min-height: 88px;
    padding: 10px;
  }
  .summary-stats {
    grid-template-columns: repeat(5, 1fr);
    margin: 10px 0;
  }
  .summary-section {
    margin: 12px 0;
  }
}

/* Desktop density adapts to the iframe height so primary play screens fit without page scrollbars. */
@media (min-width: 681px) and (max-height: 820px) {
  .app-shell {
    padding: 8px 0 10px;
  }
  .run-panel {
    height: calc(100dvh - 18px);
  }
  .panel {
    padding: 18px 20px;
  }
  .panel-header {
    margin-bottom: 12px;
  }
  .panel-title {
    margin: 4px 0;
    font-size: clamp(1.8rem, 5vh, 2.7rem);
  }
  .panel-hint {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
  }
  .selection-count {
    margin: 8px 0;
  }
  .hero {
    min-height: calc(100dvh - 18px);
    padding: 18px 24px;
  }
  .hero-title {
    margin: 8px 0 6px;
    font-size: clamp(3rem, 8vh, 5.1rem);
  }
  .hero-subtitle {
    margin: 4px 0;
    font-size: 1rem;
    line-height: 1.45;
  }
  .hero-marks {
    margin: 10px 0 14px;
  }
  .home-progress {
    margin-bottom: 10px;
  }
  .home-progress-item {
    min-height: 58px;
    padding: 8px 12px;
  }
  .home-progress-item strong {
    font-size: 1.1rem;
  }
  .button {
    min-height: 40px;
    padding: 8px 16px;
  }
  .home-actions,
  .home-secondary-actions {
    gap: 7px;
  }
  .actions {
    margin-top: 12px;
  }
  .selected-talents,
  .selected-talents.compact {
    margin: 8px 0 12px;
  }
  .talent-card {
    min-height: 88px;
    padding: 11px;
  }
  .talent-name {
    font-size: 0.95rem;
  }
  .effect-row {
    margin-top: 8px;
    gap: 5px;
  }
  .effect-chip,
  .talent-pill {
    padding: 4px 7px;
    font-size: 0.7rem;
  }
  .stat-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }
  .stat-row {
    min-height: 82px;
    padding: 9px;
    flex-direction: column;
    gap: 7px;
  }
  .stat-controls {
    grid-template-columns: 32px 34px 32px;
    gap: 4px;
  }
  .step-button {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .stat-value {
    font-size: 1rem;
  }
  .realm-track {
    margin: -3px 0 8px;
    padding-bottom: 5px;
  }
  .status-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
  }
  .status-item {
    min-height: 50px;
    padding: 7px 8px;
  }
  .status-label,
  .status-item strong {
    font-size: 0.72rem;
  }
  .run-content-grid {
    gap: 14px;
    margin-top: 10px;
  }
  .run-content-grid .history {
    padding-left: 14px;
  }
  .event-card {
    padding: 15px 16px;
  }
  .event-text {
    min-height: 0;
    margin: 9px 0 13px;
    font-size: 1rem;
    line-height: 1.5;
  }
  .history-list {
    gap: 3px;
  }
  .history-item {
    padding: 6px 2px;
    line-height: 1.4;
  }
}

@media (min-width: 1100px) and (max-height: 820px) {
  .talent-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (min-width: 681px) and (max-width: 1099px) and (max-height: 820px) {
  .talent-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
