/* One scene-led composition; the companion lives inside its own small corner. */
#game {
  max-width: 1480px;
  padding: 0 24px;
}
#game > header {
  gap: 18px;
  padding: 12px 0;
}
#game .progression-strip {
  display: block;
  margin-top: 12px;
  padding: 10px 16px;
  border-width: 1px;
}
.xp-details {
  gap: 5px;
}
.xp-heading {
  font-size: 18px;
}
.xp-heading strong {
  font-size: 25px;
}
.progression-strip #xp-progress {
  height: 26px;
}
#xp-progress-label {
  font-size: 18px;
}
.exploration {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 24px;
  padding: 18px 0;
  align-items: start;
}
.scene-viewport {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-width: 0;
}
.scene-viewport > .mono-scene {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  max-height: none;
}
.scene-caption {
  padding: 8px 12px;
  font-size: 18px;
}
.room-info #room-title {
  font-size: 30px;
  margin: 8px 0 12px;
}
.room-info #chapter-heading {
  font-size: 17px;
  margin: 0;
}
.room-info #description {
  font-size: 20px;
  line-height: 1.3;
  margin: 0 0 8px;
}
.scene-story {
  font-size: 18px;
  line-height: 1.3;
  margin: 0 0 14px;
}
.scene-story summary {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
}
.room-info #description-more {
  font-size: 19px;
  line-height: 1.35;
  white-space: pre-line;
  margin: 8px 0 12px;
}
.scene-mission {
  margin-top: 8px;
  padding-top: 10px;
}
.scene-mission h3 {
  font-size: 21px;
}
.scene-mission p {
  font-size: 19px;
  line-height: 1.3;
  margin-bottom: 12px;
}
.scene-actions button {
  font-size: 19px;
  padding: 7px 14px;
}
.room-info #narrative {
  font-size: 18px;
  line-height: 1.25;
  margin: 12px 0 0;
}
.workbench {
  margin-top: 4px;
}
.desk {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}
#adventurer-stage {
  --sprite-size: 132px;
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 12px;
  width: 150px;
  height: 152px;
  border: 3px double #000;
  background: #fff;
  color: #000;
  overflow: hidden;
  pointer-events: none;
}
.adventurer-motion {
  position: absolute;
  bottom: 18px;
  left: 6px;
  width: var(--sprite-size);
  height: var(--sprite-size);
  transform-origin: 50% 90%;
}
#adventurer-stage .adventurer {
  display: block;
  width: var(--sprite-size);
  height: var(--sprite-size);
  max-width: none;
  background-image: url("characters/codeborne-adventurer-atlas.png");
  background-size: 400% 200%;
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: pixelated;
  animation: none !important;
  filter: grayscale(1) contrast(1.5);
}
#companion-status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 17px;
  line-height: 20px;
  background: #fff;
  border-top: 1px solid #000;
}
.companion-orbit {
  display: none;
  position: absolute;
  right: 6px;
  top: 5px;
  font-size: 26px;
  line-height: 1;
  background: #fff;
  padding: 2px;
}
.adventurer-motion:after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 32px;
  width: 70px;
  height: 1px;
  background: #000;
  z-index: -1;
}
#adventurer-stage[data-action="walk"] .adventurer-motion {
  animation: none;
}
#adventurer-stage[data-action="think"] .companion-orbit {
  display: block;
  font-size: 0;
}
#adventurer-stage[data-action="think"] .companion-orbit:after {
  content: "…";
  font-size: 26px;
}
#adventurer-stage[data-action="typing"] .adventurer-motion {
  animation: companion-spar 0.36s steps(2, end) infinite;
}
#adventurer-stage[data-action="attack"] .adventurer-motion {
  animation: companion-thrust 0.5s steps(5, end) both;
}
#adventurer-stage[data-action="hurt"] .adventurer-motion {
  animation: companion-fall 0.45s steps(5, end) both;
}
#adventurer-stage[data-action="confused"] .companion-orbit {
  display: block;
  animation: companion-dazed 0.6s steps(2, end) infinite;
}
#adventurer-stage[data-action="rise"] .adventurer-motion {
  animation: companion-rise 0.5s steps(4, end) both;
}
@keyframes companion-spar {
  50% {
    transform: translateX(-7px) translateY(1px);
  }
}
@keyframes companion-thrust {
  0% {
    transform: translateX(6px);
  }
  45%,
  70% {
    transform: translateX(-9px);
  }
  100% {
    transform: translateX(0);
  }
}
@keyframes companion-fall {
  0% {
    transform: translateY(-6px) rotate(-7deg);
  }
  100% {
    transform: translateY(5px) rotate(0);
  }
}
@keyframes companion-dazed {
  50% {
    transform: translateX(-4px) rotate(-8deg);
  }
}
@keyframes companion-rise {
  from {
    transform: translateY(6px);
  }
  to {
    transform: translateY(0);
  }
}
#adventurer-stage[data-reduced="true"] * {
  animation: none !important;
  transform: none !important;
}
/* Every modal shares a fixed header and an independently scrolling body. */
dialog[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  width: min(960px, calc(100% - 32px));
  max-width: 960px;
  max-height: 88vh;
  max-height: 88dvh;
}
.dialog-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  flex-shrink: 0;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 3px double #000;
  z-index: 3;
}
.dialog-heading h2 {
  font-size: 28px;
  line-height: 1.1;
  margin: 0;
  overflow-wrap: anywhere;
}
#close-dialog {
  float: none;
  position: static;
  font-size: 19px;
  min-height: 44px;
  margin: 0;
  white-space: nowrap;
}
#dialog-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px;
  scrollbar-gutter: stable;
}
#dialog-body > div {
  margin-top: 0;
}
#dialog-body > :last-child {
  margin-bottom: 0;
}
@media (max-width: 1050px) {
  .exploration {
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  }
  .room-info #description {
    font-size: 19px;
  }
}
@media (max-width: 960px) {
  .exploration {
    grid-template-columns: 1fr;
  }
  .room-info {
    padding: 0;
  }
  .room-info #description {
    font-size: 20px;
  }
  .scene-story {
    margin-bottom: 12px;
  }
  .desk {
    grid-template-columns: 1fr;
  }
  .lesson-panel {
    border-right: 0;
    border-bottom: 3px double #000;
  }
}
@media (max-width: 600px) {
  #game {
    padding: 0 12px;
  }
  #game > header {
    padding: 10px 0;
  }
  .exploration {
    gap: 16px;
    padding: 14px 0;
  }
  .progression-strip .xp-heading {
    font-size: 17px;
  }
  .xp-heading strong {
    font-size: 24px;
  }
  #xp-progress-label {
    font-size: 17px;
  }
  #game .progression-strip {
    padding: 9px 12px;
  }
  #adventurer-stage {
    --sprite-size: 84px;
    right: 7px;
    bottom: 7px;
    width: 96px;
    height: 106px;
  }
  .adventurer-motion {
    left: 3px;
  }
  #companion-status {
    font-size: 15px;
  }
  .companion-orbit {
    font-size: 21px;
  }
  .room-info #room-title {
    font-size: 28px;
  }
  .scene-caption {
    font-size: 17px;
  }
  dialog[open] {
    width: calc(100% - 16px);
    max-height: 92vh;
    max-height: 92dvh;
  }
  .dialog-heading {
    padding: 10px;
    gap: 8px;
  }
  .dialog-heading h2 {
    font-size: 25px;
  }
  #close-dialog {
    font-size: 18px;
    padding: 8px 10px;
  }
  #dialog-body {
    padding: 12px;
    font-size: 21px;
  }
  .adventurer-motion:after {
    left: 20px;
    width: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #adventurer-stage * {
    animation: none !important;
    transform: none !important;
  }
}
#adventurer-stage[data-floating="true"] {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  box-shadow: 3px 3px 0 #000;
}
#adventurer-stage[hidden] {
  display: none;
}
@media (max-width: 600px) {
  #adventurer-stage[data-floating="true"] {
    right: 8px;
    bottom: 8px;
  }
}
.error-diagnostics {
  border: 2px solid #b00020;
  color: #b00020;
  padding: 14px;
  margin: 12px 0;
  font-size: 19px;
  line-height: 1.3;
}
.error-diagnostics h3 {
  font-size: 23px;
  margin: 0 0 8px;
}
.error-diagnostics h4 {
  font-size: 20px;
  margin: 12px 0 4px;
}
.error-diagnostics p {
  margin: 8px 0;
}
.error-diagnostics small {
  display: block;
  overflow-wrap: anywhere;
}
.error-diagnostics[hidden] {
  display: none;
}
#gold-balance {
  border-left: 2px solid #000;
  padding-left: 12px;
}
.lore-bridge {
  border-left: 3px solid #000;
  padding-left: 12px;
  margin-bottom: 16px;
}
.lore-bridge p {
  font-size: 20px;
  line-height: 1.3;
}
.answer-notice {
  font-size: 18px;
}
.execution {
  flex-wrap: wrap;
}
#success-message {
  pointer-events: auto;
  white-space: normal;
  font-size: 23px;
  padding: 18px;
  box-shadow: 4px 4px 0 #000;
}
#success-title {
  display: block;
  font-size: 29px;
}
#success-detail {
  font-size: 20px;
  line-height: 1.3;
  margin: 10px 0;
}
.success-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.success-actions button,
#proceed-inline {
  font-size: 21px;
  min-height: 44px;
}
#proceed-inline {
  display: block;
  margin: 12px 0;
  border: 4px double #000;
  font-weight: bold;
}
#proceed-inline[hidden] {
  display: none;
}
.learning-progress {
  border-bottom: 3px double #000;
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.learning-progress strong {
  font-size: 22px;
}
.learning-progress p {
  font-size: 18px;
  line-height: 1.25;
  margin: 6px 0;
}
.learning-progress progress {
  display: block;
  width: 100%;
  height: 14px;
  accent-color: #000;
  margin-top: 8px;
}
.thinking-plan ol {
  padding-left: 24px;
}
.thinking-plan li {
  margin: 10px 0;
  line-height: 1.4;
}
.tab-body {
  max-height: 650px;
}
.lore-bridge {
  font-size: 18px;
}
@media (max-width: 960px) {
  .tab-body {
    max-height: 520px;
  }
}
.success-actions button,
#proceed-inline {
  white-space: normal;
  max-width: 100%;
}

.learning-progress strong {
  display: block;
}
.learning-progress strong + strong {
  font-size: 20px;
  margin-top: 7px;
}

#scene-hero {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 2%;
  height: 28%;
  aspect-ratio: 2/3;
  transform: translateX(-50%);
  background-image: url("characters/codeborne-rear-view.png");
  background-size: contain;
  background-position: center bottom;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  filter: grayscale(1) contrast(1.5);
  pointer-events: none;
}
#scene-hero:before {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 12%;
  width: 65%;
  height: 2px;
  background: #000;
  border-radius: 50%;
  z-index: -1;
}
#adventurer-stage .adventurer[data-sheet="walk"] {
  background-image: url("characters/codeborne-walk-cycle.png");
  transform: translateY(var(--plant-offset, 0px));
}
.adventurer-motion:after {
  display: none;
}
.adventurer-ground {
  position: absolute;
  left: 25px;
  right: 25px;
  bottom: calc(18px + var(--sprite-size) * 0.075);
  height: 2px;
  background: #000;
}
.adventurer-ground:after {
  content: "";
  position: absolute;
  top: 3px;
  left: 0;
  width: 100%;
  height: 1px;
  background: repeating-linear-gradient(
    90deg,
    #000 0 2px,
    transparent 2px 16px
  );
  background-position-x: var(--ground-offset, 0px);
}
#adventurer-stage:not([data-action="walk"]) .adventurer-ground:after {
  display: none;
}
#adventurer-stage[data-reduced="true"] .adventurer-ground:after {
  display: none;
}
@media (max-width: 600px) {
  .adventurer-ground {
    left: 18px;
    right: 18px;
  }
}
