.c1-ending {
  box-sizing: border-box;
  width: min(960px, 96vw);
  max-width: 96vw;
  max-height: 92dvh;
  padding: 0;
  border: 1px solid #d5b772;
  border-radius: 18px;
  background: #f8f4e3;
  color: #1e3e32;
  box-shadow: 0 20px 70px #071b17a8;
  font-family: system-ui, sans-serif;
  overflow: auto;
}

.c1-ending[open] {
  display: grid;
  grid-template-columns: 46% minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: min(540px, 92dvh);
}

.c1-ending::backdrop { background: #0c231fdf; }
.c1-ending [hidden] { display: none !important; }

.c1-ending-art {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  object-position: center;
  background: #25453c;
}

.c1-ending-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: auto;
  padding: clamp(20px, 4vw, 44px);
  background: radial-gradient(ellipse at top right, #fff9dc, transparent 58%), #f8f4e3;
}

.c1-ending-heading, .c1-ending-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.c1-ending-heading {
  justify-content: space-between;
  color: #70551e;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .1em;
}

.c1-ending-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.c1-ending #chapterEndingTitle {
  margin: 18px 0 14px;
  color: #224c37;
  font-size: clamp(26px, 3.5vw, 40px);
  line-height: 1.12;
}

.c1-ending-copy {
  margin: 0 0 20px;
  font-size: 1rem;
  line-height: 1.65;
}

.c1-ending-reward {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 12px;
  padding: 8px 16px 8px 10px;
  border: 1px solid #d5bd79;
  border-radius: 10px;
  background: #fff4d4;
  color: #604214;
}

.c1-ending-reward img { object-fit: contain; }
/* v1.22 (Đợt 66): Security Profiles granted after Inferno */
.c1-ending-modules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.c1-ending-modules[hidden] { display: none; }
.c1-ending-modules li { padding: 8px 12px; border: 1px solid #b9d3b0; border-left: 4px solid #3b8f4e; border-radius: 10px; background: #f1f8ec; color: #24402a; }
.c1-ending-modules strong { display: block; font-size: .95rem; }
.c1-ending-modules small { display: block; font-size: .78rem; line-height: 1.35; color: #4b6650; }
.c1-ending-reward small, .c1-ending-reward strong { display: block; }
.c1-ending-next { color: #3b613b; font-weight: 700; margin: 0; }
.c1-ending-navigation { margin-top: auto; padding-top: 26px; }
.c1-ending-progress { margin: 0 0 10px; color: #4f6048; font-size: .8rem; }
.c1-ending-error { color: #8c3022; margin: 0 0 12px; }
.c1-ending-error:empty { display: none; }

.c1-ending button {
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid #799459;
  border-radius: 8px;
  background: #eff4db;
  color: #2f5337;
  font: 700 .9rem system-ui, sans-serif;
  cursor: pointer;
}

.c1-ending button[data-ending="next"] { background: #236344; color: #fff; }
.c1-ending button:disabled { opacity: .65; cursor: wait; }
.c1-ending button:focus-visible { outline: 2px solid #946319; outline-offset: 2px; }
.c1-ending-tools .narration-controls {
  flex-wrap: nowrap;
  margin: 0;
}

.c1-ending .c1-ending-tools button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  box-shadow: none;
}

.c1-ending-tools button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.c1-ending .c1-ending-tools [data-narration="toggle"][aria-pressed="true"] {
  border-color: #236344;
  background: #236344;
  color: #fff;
}

.c1-ending .c1-ending-tools [data-narration="toggle"][aria-pressed="false"] {
  background: #eff4db;
  color: #2f5337;
}

.c1-ending-tools [aria-pressed="true"] .voice-muted,
.c1-ending-tools [aria-pressed="false"] .voice-enabled {
  display: none;
}

.c1-ending-tools [data-narration-status] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 680px) {
  .c1-ending[open] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: clamp(180px, 58vw, 260px) auto;
    height: auto;
  }

  .c1-ending[data-scene="seal"] .c1-ending-art { object-position: center 12%; }
  .c1-ending:is([data-scene="firewall-strike"], [data-scene="octopus-strike"], [data-chapter="3"])[open] {
    grid-template-rows: clamp(250px, 84vw, 360px) auto;
  }
  .c1-ending[data-scene="firewall-strike"] .c1-ending-art { object-position: center 46%; }
  .c1-ending[data-scene="octopus-strike"] .c1-ending-art { object-position: center 52%; }
  .c1-ending[data-scene="trace-hand-v3"] .c1-ending-art { object-position: center 36%; }
  .c1-ending[data-scene="rescue-launch-v2"] .c1-ending-art { object-position: center 18%; }
  .c1-ending[data-scene="logs"] .c1-ending-art { object-position: center 38%; }
  .c1-ending-content { padding: 18px 20px 22px; }
  .c1-ending .c1-ending-tools button { width: 44px; height: 44px; }
}
