@font-face {
  font-family: "Maplestory";
  src: url("../assets/fonts/Maplestory Light.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "NanumCoDingHeuiMang";
  src: url("../assets/fonts/NanumCoDingHeuiMang.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Maplestory";
  src: url("../assets/fonts/Maplestory Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #263b45;
  --muted: #5d7078;
  --paper: #fffdf7;
  --cream: #fff6dc;
  --sky: #dff4ff;
  --blue: #3a82c4;
  --blue-dark: #245d91;
  --green: #5dac78;
  --green-dark: #397752;
  --yellow: #f5c34c;
  --coral: #ed786a;
  --coral-dark: #b94c43;
  --line: #cad8d8;
  --shadow: 0 14px 35px rgba(35, 67, 78, 0.12);
  --radius: 22px;
  --tile-size: clamp(40px, 4.2vw, 54px);
  font-family: "Maplestory", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background: #edf7f4;
}

* {
  box-sizing: border-box;
}

/* Author 스타일의 grid/flex 선언이 브라우저 기본 [hidden] 규칙을 덮지 않게 합니다. */
[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 7% 4%, rgba(245, 195, 76, 0.28), transparent 21rem),
    radial-gradient(circle at 94% 15%, rgba(58, 130, 196, 0.2), transparent 25rem),
    linear-gradient(180deg, #f4fbf8 0%, #edf7f4 100%);
  font-size: 18px;
  line-height: 1.62;
  letter-spacing: 0.01em;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
input,
textarea,
select,
a {
  outline-offset: 3px;
}

:focus-visible {
  outline: 4px solid #132f46;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

img {
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  padding: 10px 16px;
  border-radius: 10px;
  color: white;
  background: #132f46;
}

.skip-link:focus {
  transform: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 14px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.18rem, 2.1vw, 1.75rem);
  line-height: 1.28;
}

.brand-home-link {
  min-width: 0;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-home-link:hover { background: rgba(255, 255, 255, 0.64); }
.brand-home-link:focus-visible {
  outline: 4px solid rgba(24, 90, 131, 0.42);
  outline-offset: 3px;
}

.eyebrow,
.screen-kicker {
  margin: 0 0 3px;
  color: var(--blue-dark);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.save-indicator {
  box-sizing: border-box;
  inline-size: 10.75rem;
  flex: 0 0 10.75rem;
  padding: 9px 14px;
  border: 1px solid #bad1cf;
  border-radius: 999px;
  color: #355a58;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.progress-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto 16px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.progress-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(122px, 1fr));
  min-width: 732px;
  padding: 5px;
  margin: 0;
  list-style: none;
  border: 1px solid #cbdedb;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.progress-list li {
  padding: 0;
  border-radius: 11px;
  color: #687b80;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.progress-list button {
  width: 100%;
  padding: 9px 8px;
  border: 0;
  border-radius: inherit;
  color: inherit;
  background: transparent;
  font: inherit;
  white-space: inherit;
  opacity: 1;
}

.progress-list li.is-complete {
  color: var(--green-dark);
  background: #e5f5e9;
}

.progress-list li.is-complete button {
  cursor: pointer;
}

.progress-list li.is-complete button:hover {
  background: #d5efdc;
}

.progress-list li.is-complete button:focus-visible {
  outline: 3px solid #2f7f63;
  outline-offset: -3px;
}

.progress-list li.is-current {
  color: white;
  background: var(--blue-dark);
}

.app-main {
  width: min(1480px, calc(100% - 40px));
  min-height: 65vh;
  margin: 0 auto;
}

.screen {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 4vw, 52px);
  border: 1px solid rgba(161, 190, 187, 0.65);
  border-radius: 30px;
  background: rgba(255, 253, 247, 0.96);
  box-shadow: var(--shadow);
}

.screen[hidden] {
  display: none !important;
}

.wide-screen {
  padding-right: clamp(18px, 2.5vw, 34px);
  padding-left: clamp(18px, 2.5vw, 34px);
}

.screen-heading {
  max-width: 850px;
  margin: 0 auto 26px;
  text-align: center;
}

.screen-heading h2,
.hero-copy h2 {
  margin: 8px 0 10px;
  color: #203e4c;
  font-size: clamp(1.75rem, 3.5vw, 3.25rem);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.screen-heading p {
  margin: 0;
  color: var(--muted);
}

.step-chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: var(--sky);
  font-size: 0.86rem;
  font-weight: 900;
}

.example-chip {
  color: #765314;
  background: #fff0b8;
}

.home-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  align-items: center;
  gap: clamp(30px, 6vw, 80px);
  min-height: 670px;
}

/* 첫 화면에서만 교육과정과 학습문제를 강조합니다. 공통 편집 헤더는 유지합니다. */
body:has(.home-screen:not([hidden])) #grade-label {
  margin-bottom: 5px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.01em;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.home-screen > .hero-copy > .screen-kicker {
  margin-bottom: 10px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.01em;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.hero-copy > p:not(.screen-kicker) {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 420px;
}

.hero-art::before {
  position: absolute;
  width: 82%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(145deg, #e4f6ff, #fff0bd);
  content: "";
}

.hero-art img {
  position: relative;
  display: block;
  width: min(100%, 560px);
  height: auto;
  max-height: 360px;
  aspect-ratio: 1672 / 940;
  object-fit: contain;
  filter: drop-shadow(0 20px 15px rgba(35, 67, 78, 0.16));
}

.home-actions,
.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0;
}

.home-start-note {
  margin: -16px 0 22px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.button {
  position: relative;
  min-height: 46px;
  padding: 11px 18px;
  border: 2px solid transparent;
  border-radius: 14px;
  font-weight: 900;
  line-height: 1.3;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

/* 저장·계산·제출처럼 시간이 걸리는 동작은 버튼 안에서 바로 진행 상태를 보여 줍니다. */
.button[aria-busy="true"]::before {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.48em;
  border: 0.16em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  vertical-align: -0.08em;
  animation: button-pending-spin 700ms linear infinite;
}

@keyframes button-pending-spin {
  to { transform: rotate(360deg); }
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 13px rgba(35, 67, 78, 0.13);
}

.button.primary {
  color: white;
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.button.primary:hover:not(:disabled) {
  background: #164d78;
}

.button.secondary {
  color: var(--blue-dark);
  background: white;
  border-color: #78a9ce;
}

.button.ghost {
  color: #405b63;
  background: #f3f7f5;
  border-color: #c5d4d2;
}

.button.danger {
  color: white;
  background: var(--coral-dark);
}

.button.compact {
  min-height: 44px;
  padding: 8px 13px;
  font-size: 0.9rem;
}

.privacy-note,
.perspective-note,
.transfer-note {
  padding: 17px 19px;
  border-left: 5px solid var(--green);
  border-radius: 8px 16px 16px 8px;
  background: #ebf6e9;
}

.privacy-note ul {
  padding-left: 22px;
  margin: 8px 0 0;
}

.privacy-note li + li {
  margin-top: 4px;
}

.status-message,
.warning-banner {
  position: sticky;
  z-index: 30;
  top: 8px;
  width: min(900px, calc(100% - 24px));
  margin: 0 auto 12px;
  padding: 13px 18px;
  border-radius: 14px;
  color: #163d4d;
  background: #dff4ff;
  box-shadow: 0 8px 20px rgba(35, 67, 78, 0.18);
  font-weight: 800;
  text-align: center;
}

.status-message.is-error {
  color: #7b2f2a;
  background: #ffe4df;
}

/* 일시적인 안내는 문서 높이와 스크롤을 바꾸지 않습니다. 지도 입력도 가로채지 않습니다. */
.status-message {
  position: fixed;
  top: auto;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  pointer-events: none;
}

.warning-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #6d352d;
  background: #fff0c9;
}

.warning-banner[hidden],
.status-message[hidden] {
  display: none;
}

.form-card,
.drawing-card,
.palette-card,
.town-stage-card,
.summary-card,
.resident-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: 0 8px 18px rgba(35, 67, 78, 0.08);
}

.form-card {
  padding: clamp(20px, 3vw, 32px);
}

.profile-card {
  max-width: 900px;
  margin: 0 auto;
}

label,
.field-label,
legend {
  color: #294b57;
  font-weight: 900;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  margin: 6px 0 4px;
  padding: 10px 12px;
  border: 2px solid #b8cdcc;
  border-radius: 12px;
  color: var(--ink);
  background: #fffefa;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue-dark);
}

fieldset {
  padding: 0;
  margin: 22px 0 0;
  border: 0;
}

.field-help {
  margin: 2px 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.alias-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  margin-top: 20px;
  border-radius: 16px;
  background: var(--cream);
}

.alias-row strong {
  display: block;
  color: #754f0d;
  font-size: 1.3rem;
}

.character-options,
.feeling-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.choice-button {
  position: relative;
  min-height: 150px;
  padding: 12px;
  border: 3px solid transparent;
  border-radius: 18px;
  color: var(--ink);
  background: #f1f7f5;
  font-weight: 900;
}

.choice-button img {
  display: block;
  width: 124px;
  max-width: 100%;
  height: 124px;
  margin: 0 auto 6px;
  object-fit: contain;
}

.choice-button.is-selected {
  border-color: var(--blue-dark);
  background: #e6f4ff;
}

.choice-button.is-selected::after {
  position: absolute;
  top: 6px;
  right: 8px;
  content: "선택";
  color: var(--blue-dark);
  font-size: 0.7rem;
}

.screen-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  max-width: 1100px;
  margin: 28px auto 0;
}

.ceremony-screen {
  display: grid;
  place-items: center;
  min-height: 560px;
  text-align: center;
  background: linear-gradient(180deg, #dff4ff 0%, #fff6dc 60%, #e9f6e7 100%);
}

.ceremony-content {
  position: relative;
  z-index: 2;
  width: min(920px, 100%);
  max-width: 920px;
}

.ceremony-story-card {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(300px, 1.1fr);
  gap: 24px;
  align-items: center;
  padding: 22px;
  border: 4px solid rgba(255, 255, 255, 0.95);
  border-radius: 30px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: 0 18px 46px rgba(49, 85, 95, 0.18);
  animation: ceremony-page-in 420ms ease both;
}

.ceremony-story-card img {
  width: 100%;
  max-height: 330px;
  object-fit: contain;
  border-radius: 24px;
}

.ceremony-copy { text-align: left; }

.ceremony-copy h2 {
  margin: 8px 0 12px;
  color: #214f72;
  font-size: clamp(1.75rem, 3.4vw, 3rem);
  line-height: 1.22;
}

.ceremony-copy p:last-child {
  margin: 0;
  font-size: 1.12rem;
}

.ceremony-step {
  margin: 0;
  color: #7b5819;
  font-size: 0.9rem;
  font-weight: 900;
}

.ceremony-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
}

.ceremony-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #b7c8cd;
}

.ceremony-dots .is-current {
  width: 34px;
  border-radius: 999px;
  background: var(--blue-dark);
}

.ceremony-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

@keyframes ceremony-page-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.drawing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 20px;
}

.drawing-card {
  padding: 16px;
}

.drawing-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tool-button,
.color-button {
  min-width: 44px;
  min-height: 44px;
  border: 2px solid #b8cdcc;
  border-radius: 11px;
  color: var(--ink);
  background: white;
  font-size: 0.86rem;
  font-weight: 900;
}

.tool-button.is-active {
  color: white;
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.danger-text { color: var(--coral-dark); }

.color-button {
  position: relative;
  width: 44px;
  padding: 4px;
}

.color-button span {
  display: block;
  width: 27px;
  height: 27px;
  margin: auto;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
}

.color-button.is-selected {
  border-color: #132f46;
  box-shadow: inset 0 0 0 2px white;
}

.size-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.size-label select {
  width: auto;
  margin: 0;
}

#place-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 3px solid #66848b;
  border-radius: 14px;
  background: white;
  touch-action: none;
  cursor: crosshair;
}

.story-card label:not(:first-child) {
  display: block;
  margin-top: 16px;
}

.feeling-options {
  grid-template-columns: repeat(3, 1fr);
}

.feeling-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 8px;
  border: 3px solid transparent;
  border-radius: 13px;
  background: #f3f7f5;
  font-weight: 900;
}

.feeling-button .feeling-dot {
  width: 18px;
  height: 18px;
  border: 2px solid #40545a;
  border-radius: 50%;
}

.feeling-button.is-selected {
  border-color: var(--blue-dark);
  background: #e7f4ff;
}

.town-workspace {
  display: grid;
  grid-template-columns: minmax(235px, 0.28fr) minmax(650px, 0.72fr);
  gap: 18px;
  align-items: start;
}

.palette-card {
  position: sticky;
  top: 10px;
  padding: 16px;
}

.palette-card h3 {
  margin: 0 0 12px;
}

.improvement-advisor-board {
  display: grid;
  gap: 9px;
  padding: 13px;
  margin: 0 0 18px;
  border: 2px solid #e2b856;
  border-radius: 16px;
  background: linear-gradient(145deg, #fff8d8, #fffdf4);
  box-shadow: 0 5px 0 rgba(151, 108, 26, 0.12);
}

.improvement-advisor-board .advisor-kicker {
  margin: 0;
  color: #87611a;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.improvement-advisor-board h3,
.improvement-advisor-board > p { margin: 0; }

.improvement-advisor-board > p:not(.advisor-kicker) {
  color: #655634;
  font-size: 0.78rem;
  line-height: 1.45;
}

.improvement-advisor-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.improvement-advisor-option {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
  border: 2px solid #d8c58b;
  border-radius: 11px;
  color: #4d472f;
  background: #ffffff;
  text-align: left;
}

.improvement-advisor-option strong { color: #285e74; font-size: 0.76rem; }
.improvement-advisor-option span { font-size: 0.68rem; line-height: 1.3; }
.improvement-advisor-option:hover,
.improvement-advisor-option:focus-visible,
.improvement-advisor-option.is-selected {
  border-color: var(--blue-dark);
  background: #e8f5ff;
}

.improvement-advisor-option.is-selected::after {
  content: "참고 중";
  color: var(--blue-dark);
  font-size: 0.66rem;
  font-weight: 900;
}

.improvement-advisor-detail {
  display: grid;
  gap: 5px;
  min-height: 74px;
  padding: 9px;
  border-radius: 11px;
  color: #4e4a38;
  background: rgba(255, 255, 255, 0.85);
  font-size: 0.72rem;
  line-height: 1.42;
}

.improvement-advisor-detail p,
.improvement-advisor-detail small { margin: 0; }
.improvement-advisor-detail small { color: #6b6654; }

.facility-palette {
  min-width: 0;
}

.facility-category-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  padding: 2px 2px 10px;
  overflow: visible;
}

.hero-handwriting {
  font-family: "NanumCoDingHeuiMang", "Maplestory", "Malgun Gothic", sans-serif;
  /* 원본 글꼴 파일은 그대로 두고 이 제목에만 합성 굵기를 적용합니다. */
  font-weight: 700;
}

.facility-category-tab {
  min-width: 0;
  min-height: 42px;
  padding: 6px 5px;
  border: 2px solid #bfd1d2;
  border-radius: 14px;
  color: #38545e;
  background: #ffffff;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.18;
  white-space: normal;
  overflow-wrap: anywhere;
}

.facility-category-tab.is-active {
  border-color: var(--blue-dark);
  color: #ffffff;
  background: var(--blue-dark);
}

.facility-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.facility-button {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 7px;
  min-height: 70px;
  padding: 7px;
  border: 3px solid transparent;
  border-radius: 13px;
  color: var(--ink);
  background: #edf5f3;
  font-size: 0.78rem;
  font-weight: 900;
}

.facility-button img {
  display: block;
  width: 38px;
  height: 38px;
  grid-row: 1 / 3;
  margin: 0 auto;
  object-fit: contain;
}

.facility-button .road-icon {
  display: block;
  width: 40px;
  height: 20px;
  grid-row: 1 / 3;
  margin: 8px auto;
  border: 3px dashed #e8f6ff;
  border-radius: 5px;
  background: #4c8fc5;
}

.facility-button.is-active {
  border-color: var(--blue-dark);
  background: #dff1ff;
}

.facility-label,
.facility-size { text-align: left; }

.facility-size {
  color: #60767d;
  font-size: 0.72rem;
  font-weight: 700;
}

.editor-undo-button {
  width: 100%;
  margin-top: 10px;
}

.editor-undo-button:disabled {
  color: #718184;
  border-color: #c9d5d4;
  background: #eef2f0;
  cursor: default;
}

/* 편집 이력과 철거 상태는 기존 도구 안에 둡니다. 안내는 지도에 겹쳐 표시해
   켜고 끌 때 지도 좌표와 페이지 스크롤이 달라지지 않도록 합니다. */
.editor-history-buttons { display: flex; gap: 6px; }
.editor-history-buttons .editor-undo-button { flex: 1; width: auto; min-width: 0; white-space: nowrap; padding-inline: 7px; }
.map-camera-toolbar .map-demolition-button { margin-inline-start: 8px; color: #a83736; font-weight: 700; }
.map-camera-toolbar .map-demolition-button[aria-pressed="true"] { background: #fff0ed; border-color: #b84239; color: #922e29; }
.demolition-hint { position: absolute; z-index: 30; left: 12px; top: 12px; max-width: min(540px, calc(100% - 24px)); margin: 0; padding: 10px 14px; border: 1px solid #d89a91; border-radius: 12px; background: #fff4ef; color: #7f302c; font-size: 14px; line-height: 1.5; pointer-events: none; box-shadow: 0 2px 8px #53321b18; }
.town-grid[data-demolition-input="true"],
.town-grid[data-demolition-input="true"] .quarter-object,
.town-grid[data-demolition-input="true"] .town-cell { cursor: crosshair; }

.selection-card,
.change-summary {
  padding: 12px;
  margin-top: 14px;
  border-radius: 14px;
  background: var(--cream);
}

.selection-card[hidden] { display: none; }
.selection-card p { margin: 4px 0 10px; font-size: 0.83rem; }
.place-detail-card[hidden] { display: none; }

.place-detail-card {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(190px, 1.2fr);
  gap: 16px;
  align-items: center;
}

.place-detail-card img {
  display: block;
  width: 100%;
  max-height: 360px;
  border: 3px solid #f2bf58;
  border-radius: 16px;
  background: white;
  object-fit: contain;
  object-position: center;
  transform: none;
  perspective: none;
}

.place-detail-card dl { margin: 0; }
.place-detail-card dt { margin-top: 8px; color: var(--blue-dark); font-size: 0.78rem; font-weight: 900; }
.place-detail-card dd { margin: 1px 0; color: var(--ink); white-space: pre-wrap; }

.place-detail-card--compact {
  grid-template-columns: 1fr;
  gap: 7px;
  padding-top: 10px;
}

.place-detail-card--compact img { max-height: 150px; }
.place-detail-card--compact dd { font-size: 0.82rem; }

.place-detail-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 22px;
  overflow: auto;
  border: 3px solid var(--blue-dark);
  border-radius: 22px;
  color: var(--ink);
  background: #fffdf7;
  box-shadow: 0 20px 70px rgba(31, 72, 81, 0.35);
}

.place-detail-dialog::backdrop { background: rgba(24, 55, 66, 0.48); }
.place-detail-dialog__heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.place-detail-dialog__heading h2 { margin: 7px 0 0; }
.place-detail-card--dialog img { min-height: 220px; }

.map-help-dialog {
  width: min(720px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: clamp(20px, 4vw, 32px);
  overflow: auto;
  border: 3px solid #315f70;
  border-radius: 24px;
  color: var(--ink);
  background: linear-gradient(145deg, #fffdf4, #eaf7ff);
  box-shadow: 0 24px 80px rgba(24, 55, 66, 0.38);
}

.map-help-dialog::backdrop { background: rgba(24, 55, 66, 0.56); backdrop-filter: blur(3px); }
.map-help-dialog__heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.map-help-dialog__heading h2 { margin: 7px 0 0; }
.map-help-steps { display: grid; gap: 10px; padding: 0; margin: 22px 0; list-style: none; counter-reset: map-help; }
.map-help-steps li {
  display: grid;
  grid-template-columns: minmax(135px, 0.38fr) minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #c8dcda;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  counter-increment: map-help;
}
.map-help-steps strong::before { content: counter(map-help) ". "; color: #b06a28; }
.map-help-steps span { line-height: 1.5; }
.map-help-footnote { margin: 0; color: #4f676d; font-size: 0.86rem; line-height: 1.55; }

.button-row { display: flex; flex-wrap: wrap; gap: 7px; }
.mode-hint { min-height: 44px; color: var(--muted); font-size: 0.86rem; }
.change-summary { color: #5f4719; font-weight: 900; }

.town-stage-card {
  position: relative;
  padding: 15px;
  overflow: hidden;
  background: linear-gradient(180deg, #e8f7ff 0%, #f4fbff 42%, #eef6e8 100%);
}

.town-legend {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.map-interaction-help {
  margin: 0 0 9px;
  color: #365b68;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.45;
}

.road-swatch {
  display: inline-block;
  width: 26px;
  height: 13px;
  vertical-align: -1px;
  border: 2px solid #55778a;
  background: linear-gradient(135deg, #718f9f 42%, #f7e7a0 43% 53%, #718f9f 54%);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.map-camera {
  position: relative;
}

.map-camera-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 7px;
  margin-bottom: 8px;
  border: 1px solid rgba(73, 113, 125, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
}

/*
 * JG360과 같은 펼치기/접기 모양을 쓰되 외부 아이콘 파일이나 CDN은
 * 불러오지 않습니다. 마지막의 auto 여백으로 어느 지도에서도 오른쪽 위에
 * 머물고, 글자 설명을 띄우지 않아 지도 도구막대가 복잡해지지 않습니다.
 */
.map-camera-toolbar .map-fullscreen-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  padding: 6px;
  margin-left: auto;
}

.map-fullscreen-toggle svg {
  display: block;
  width: 23px;
  height: 23px;
  pointer-events: none;
}

.map-fullscreen-toggle .map-fullscreen-shrink-icon,
.map-fullscreen-toggle[aria-pressed="true"] .map-fullscreen-expand-icon {
  display: none;
}

.map-fullscreen-toggle[aria-pressed="true"] .map-fullscreen-shrink-icon {
  display: block;
}

/*
 * Fullscreen API가 활성화되면 지도 도구, 실제 지도, 미니맵을 한 덩어리로
 * 확장합니다. 카메라 배율은 유지하고 ResizeObserver가 새 viewport 크기에
 * 맞춰 위치만 안전하게 다시 제한합니다.
 */
.map-camera:fullscreen,
.map-camera.is-map-fullscreen,
.map-camera:-webkit-full-screen {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 12px;
  background: #e9f5f0;
}

.map-camera:fullscreen .town-scroll,
.map-camera.is-map-fullscreen .town-scroll,
.map-camera:-webkit-full-screen .town-scroll {
  flex: 1 1 auto;
  min-height: 0;
}

.map-camera:fullscreen :where(.town-grid),
.map-camera.is-map-fullscreen :where(.town-grid),
.map-camera:-webkit-full-screen :where(.town-grid) {
  height: 100%;
  min-height: 0;
}

.map-camera-toolbar button {
  min-width: 42px;
  min-height: 40px;
  padding: 6px 10px;
  border: 2px solid #9abbbd;
  border-radius: 10px;
  color: #294b57;
  background: #f8fcfa;
  font-size: 0.78rem;
  font-weight: 900;
}

.map-camera-toolbar button:hover,
.map-camera-toolbar button:focus-visible,
.map-camera-toolbar button.is-active {
  color: white;
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

.map-camera-toolbar button:disabled {
  color: #6f7f83;
  border-color: #c9d5d4;
  background: #eef2f0;
}

.map-camera-toolbar .map-label-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  white-space: nowrap;
}

.map-label-switch-track {
  position: relative;
  flex: none;
  width: 28px;
  height: 16px;
  border: 1px solid currentColor;
  border-radius: 999px;
}

.map-label-switch-track::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  content: '';
}

.map-label-toggle[aria-checked="true"] .map-label-switch-track::after {
  transform: translateX(12px);
}

.map-camera-toolbar output {
  min-width: 54px;
  padding: 6px 5px;
  color: var(--blue-dark);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
}

.map-camera-toolbar .map-compare-button {
  margin-left: auto;
  border-color: #d49a2d;
  color: #684a12;
  background: #fff4c9;
}

.map-camera-toolbar .map-view-state {
  min-width: 132px;
  padding-inline: 10px;
  border-radius: 999px;
  color: #325a4a;
  background: #e9f7ec;
  white-space: nowrap;
}

.town-scroll {
  position: relative;
  overflow: hidden;
  padding: 0;
  border: 2px solid rgba(68, 105, 116, 0.35);
  border-radius: 18px;
  background: rgba(218, 244, 255, 0.48);
}

.town-grid {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(430px, 56vh, 650px);
  flex: none;
  margin: 0 auto;
  border: 0;
  border-radius: 16px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 85% 13%, rgba(255, 255, 255, 0.74) 0 4px, transparent 5px),
    linear-gradient(180deg, rgba(218, 244, 255, 0.45), rgba(225, 242, 218, 0.38));
  isolation: isolate;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.town-camera-scene {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  will-change: transform;
  contain: layout style;
}

/* 게임 지도 안에서만 브라우저의 파란 선택/이미지 끌기를 막습니다.
 * 장소 이야기와 그 밖의 작성 입력란은 기존 선택·복사 동작을 유지합니다. */
.town-grid,
.town-grid * {
  -webkit-user-select: none;
  user-select: none;
}

.town-grid input,
.town-grid textarea,
.town-grid [contenteditable="true"],
.town-grid [contenteditable="true"] * {
  -webkit-user-select: text;
  user-select: text;
}

.town-grid img {
  -webkit-user-drag: none;
}

.map-minimap {
  position: absolute;
  z-index: 20;
  right: 12px;
  bottom: 12px;
  width: 174px;
  padding: 5px;
  border: 2px solid rgba(36, 93, 145, 0.75);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 5px 14px rgba(31, 72, 81, 0.2);
}

.map-minimap span {
  display: block;
  padding: 0 4px 2px;
  color: var(--blue-dark);
  font-size: 0.67rem;
  font-weight: 900;
}

.map-minimap canvas {
  display: block;
  width: 160px;
  height: 82px;
  border-radius: 8px;
  cursor: crosshair;
}

.town-grid.is-camera-edge-scrolling { cursor: grab; }

.town-grid.is-camera-dragging,
.town-grid.is-camera-dragging * { cursor: grabbing !important; }

.town-grid.is-camera-dragging .quarter-preview-layer { display: none; }

.town-grid.is-road-stroking,
.town-grid.is-road-stroking * { cursor: crosshair !important; }

.quarter-layer {
  position: absolute;
  inset: 0;
}

.quarter-ground-layer { z-index: 1; pointer-events: none; }
.quarter-road-layer { z-index: 2; pointer-events: none; }
.quarter-hit-layer { z-index: 3; }
.quarter-object-layer { z-index: 4; pointer-events: none; }
.quarter-selection-layer { z-index: 5; pointer-events: none; }
.quarter-preview-layer { z-index: 6; pointer-events: none; }
.quarter-bubble-layer { z-index: 7; pointer-events: none; }
.quarter-inspection-layer { z-index: 8; pointer-events: none; }
.town-grid[data-map-input-mode="readonly-pan"] .quarter-inspection-layer { z-index: 3; }
.quarter-hit-layer[data-hit-mode="readonly-sparse"] { pointer-events: none; }

.quarter-ground-tile {
  position: absolute;
  display: block;
  box-sizing: border-box;
  border: 1px solid rgba(56, 104, 71, 0.42);
  background: #b9db8b;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.quarter-ground-tile.is-alternate {
  background: #c8e59a;
}

.town-cell {
  position: absolute;
  display: block;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.town-cell:not(.is-readonly):hover:not(:disabled),
.town-cell:focus-visible {
  z-index: 3;
  outline: 0;
  background: rgba(69, 160, 218, 0.34);
  box-shadow: inset 0 0 0 4px #185a83;
}

.town-cell.is-readonly {
  cursor: default;
  pointer-events: none;
}

.town-cell.is-readonly.is-viewable {
  cursor: pointer;
  pointer-events: auto;
}

.town-cell.is-readonly.is-viewable:hover,
.town-cell.is-readonly.is-viewable:focus-visible {
  background: rgba(255, 237, 92, 0.3);
  box-shadow: inset 0 0 0 4px #8b6815;
}

.town-cell.is-placeable:hover:not(:disabled),
.town-cell.is-placeable:focus-visible {
  cursor: copy;
  background: rgba(91, 190, 111, 0.42);
  box-shadow: inset 0 0 0 4px #27773f;
}

.town-cell.is-blocked:hover:not(:disabled),
.town-cell.is-blocked:focus-visible {
  cursor: not-allowed;
  background: rgba(235, 94, 87, 0.38);
  box-shadow: inset 0 0 0 4px #aa3e3a;
}

.town-cell:disabled {
  opacity: 1;
  cursor: default;
}

.town-cell.is-selected {
  background: rgba(255, 239, 105, 0.16);
}

.town-inspect-target {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.town-inspect-target:hover,
.town-inspect-target:focus,
.town-inspect-target:focus-visible {
  outline: 0;
  background: rgba(255, 237, 92, 0.3);
  box-shadow: inset 0 0 0 4px #8b6815;
}

.quarter-road {
  position: absolute;
  display: block;
  overflow: visible;
  pointer-events: none;
  filter: none;
}

.quarter-road-curb { stroke: #dce3d6; stroke-width: 20; stroke-linecap: round; }

.quarter-road-surface {
  stroke: #89999c;
  stroke-width: 16;
  stroke-linecap: round;
}

.quarter-road-center {
  fill: #89999c;
  stroke: #dce3d6;
  stroke-width: 1.6;
}

.quarter-road-lane {
  stroke: #f8f6df;
  stroke-width: 1.8;
  stroke-dasharray: 4 3;
  stroke-linecap: round;
}

.quarter-object {
  position: absolute;
  display: block;
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
  pointer-events: none;
}

.quarter-object.is-interactive {
  cursor: pointer;
  pointer-events: auto;
}

.quarter-resident {
  position: absolute;
  display: block;
  width: 44px;
  height: 54px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  /* 좌표 이동을 transform에 합쳐 주민 애니메이션을 합성 단계에서 처리합니다. */
  transform: translate3d(0, 0, 0) translate(-50%, -100%);
  transform-origin: 50% 100%;
  pointer-events: auto;
  touch-action: none;
}

.quarter-resident-image {
  position: absolute;
  bottom: 0;
  left: 50%;
  display: block;
  width: 34px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 2px 1px rgba(40, 73, 67, 0.2));
  transform: translateX(-50%);
  pointer-events: none;
}

@keyframes resident-guide-pulse {
  0% { opacity: 0.9; transform: scale(0.72); }
  75% { opacity: 0.12; transform: scale(1.42); }
  100% { opacity: 0; transform: scale(1.5); }
}

.quarter-resident.is-guide-target::before {
  position: absolute;
  z-index: -1;
  right: 1px;
  bottom: 1px;
  width: 38px;
  height: 38px;
  border: 4px solid #ffd744;
  border-radius: 50%;
  content: "";
  animation: resident-guide-pulse 900ms ease-out 3;
  pointer-events: none;
}

.quarter-resident:hover .quarter-resident-image,
.quarter-resident:focus-visible .quarter-resident-image,
.quarter-resident.is-selected .quarter-resident-image {
  outline: 3px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  filter: drop-shadow(0 0 0 #245d91) drop-shadow(0 3px 2px rgba(40, 73, 67, 0.25));
}

.quarter-resident.is-unreachable .quarter-resident-image { opacity: 0.88; }

.quarter-resident-speech {
  position: absolute;
  right: 50%;
  bottom: calc(100% + 5px);
  width: 142px;
  padding: 6px 8px;
  border: 2px solid #315f70;
  border-radius: 12px 12px 3px 12px;
  color: #23414a;
  background: #fffdf3;
  box-shadow: 0 3px 0 rgba(50, 80, 74, 0.18);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
  pointer-events: none;
}

.quarter-resident.is-guide-target .quarter-resident-speech {
  border-color: #d58c14;
  color: #68430b;
  background: #fff8cf;
}

.quarter-object-shadow {
  position: absolute;
  z-index: 0;
  right: 6%;
  bottom: -1px;
  left: 6%;
  height: 18px;
  border-radius: 50%;
  background: rgba(38, 73, 57, 0.28);
  filter: blur(2px);
  transform: skewX(-28deg) scaleY(0.62);
}

.quarter-object-image {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: none;
  pointer-events: none;
}

.quarter-object-name {
  position: absolute;
  z-index: 4;
  right: 50%;
  bottom: 2px;
  display: none;
  max-width: 112px;
  padding: 2px 5px;
  overflow: hidden;
  border: 1px solid rgba(35, 72, 83, 0.46);
  border-radius: 999px;
  color: #203f4a;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 2px 5px rgba(31, 67, 74, 0.16);
  font-size: 9px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(50%);
  pointer-events: none;
}

.town-grid[data-facility-label-mode="expanded"] .quarter-object-name {
  display: block;
}

/* 일반 시설의 작은 이름표만 숨깁니다. 학생 그림의 큰 표지판과 선택 말풍선은 유지합니다. */
.town-grid[data-town-renderer="quarter-view"][data-facility-labels-visible="false"] .quarter-object-name {
  display: none;
}

.quarter-custom-building,
.quarter-custom-roof,
.quarter-custom-face,
.quarter-custom-frame,
.quarter-custom-name,
.quarter-sketch-extrusion-layer,
.quarter-sketch-extrusion-surface,
.quarter-sketch-front {
  position: absolute;
  display: block;
  pointer-events: none;
}

.quarter-custom-building {
  z-index: 2;
  inset: 0;
}

.quarter-custom-roof {
  z-index: 2;
  top: 48px;
  left: 3px;
  width: 70px;
  height: 36px;
  border: 2px solid #7f6538;
  background: #ffd86a;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.quarter-custom-face {
  z-index: 3;
  top: 66px;
  width: 35px;
  height: 20px;
  border: 2px solid #6f654c;
}

.quarter-custom-face--left {
  left: 3px;
  background: #f5c85e;
  clip-path: polygon(0 0, 100% 18px, 100% 100%, 0 2px);
}

.quarter-custom-face--right {
  left: 38px;
  background: #e1a94b;
  clip-path: polygon(0 18px, 100% 0, 100% 2px, 0 100%);
}

.quarter-custom-frame {
  z-index: 5;
  top: 9px;
  left: 11px;
  width: 54px;
  height: 48px;
}

.quarter-sketch-extrusion-layer {
  inset: 0;
}

.quarter-sketch-extrusion-surface {
  inset: 0;
  width: 100%;
  height: 100%;
}

.quarter-sketch-extrusion-surface--silhouette {
  object-fit: contain;
  object-position: center;
  filter: brightness(0.58) saturate(0.72) sepia(0.12);
}

.quarter-sketch-extrusion-surface--card {
  border: 2px solid #a66f3d;
  border-radius: 10px;
  background: #cf894c;
}

.quarter-sketch-front {
  z-index: 20;
  inset: 0;
  box-sizing: border-box;
  padding: 3px;
  overflow: hidden;
  border: 3px solid #fffaf0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 3px 0 #d99845, 0 6px 8px rgba(76, 65, 45, 0.25);
}

.quarter-custom-building[data-sketch-mode="card"] .quarter-sketch-extrusion-surface--silhouette,
.quarter-custom-building[data-sketch-mode="silhouette"] .quarter-sketch-extrusion-surface--card {
  display: none;
}

.quarter-custom-building[data-sketch-mode="silhouette"] .quarter-sketch-front {
  padding: 0;
  overflow: visible;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.quarter-custom-name {
  z-index: 7;
  top: 70px;
  left: 8px;
  width: 60px;
  min-height: 15px;
  padding: 2px 3px;
  overflow: hidden;
  border: 2px solid #7f6538;
  border-radius: 7px;
  color: #4f3a1d;
  background: #fff8d9;
  font-size: 8px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quarter-custom-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: contain;
  object-position: center;
  filter: none;
  transform: none;
  perspective: none;
}

.quarter-selection {
  position: absolute;
  display: block;
  box-sizing: border-box;
  background: rgba(255, 237, 92, 0.23);
  box-shadow: inset 0 0 0 5px #ffdf3b, 0 0 0 2px rgba(85, 70, 13, 0.5);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  filter: drop-shadow(0 0 5px rgba(255, 213, 33, 0.9));
}

.quarter-placement-preview {
  position: absolute;
  display: block;
  box-sizing: border-box;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.quarter-placement-preview.is-placeable {
  background: rgba(91, 190, 111, 0.4);
  box-shadow: inset 0 0 0 4px #27773f;
}

.quarter-placement-preview.is-blocked {
  background: rgba(235, 94, 87, 0.38);
  box-shadow: inset 0 0 0 4px #aa3e3a;
}

.quarter-placement-preview.is-front-anchor {
  background: rgba(255, 229, 82, 0.52);
  box-shadow: inset 0 0 0 4px #9b7412, 0 0 0 2px rgba(255, 255, 255, 0.82);
}

.quarter-road-stroke-preview {
  position: absolute;
  display: block;
  box-sizing: border-box;
  background: rgba(64, 141, 198, 0.52);
  box-shadow: inset 0 0 0 4px #265f8d;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.quarter-road-stroke-preview.is-blocked {
  background: rgba(235, 94, 87, 0.4);
  box-shadow: inset 0 0 0 4px #aa3e3a;
}

.quarter-placement-anchor {
  position: absolute;
  display: block;
  box-sizing: border-box;
  background: rgba(255, 229, 82, 0.42);
  box-shadow: inset 0 0 0 4px #9b7412, 0 0 0 2px rgba(255, 255, 255, 0.82);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.quarter-placement-ghost {
  opacity: 0.56;
  filter: saturate(0.82);
  pointer-events: none;
}

.quarter-placement-ghost.is-blocked { filter: grayscale(0.7) sepia(0.4) hue-rotate(310deg); }

.quarter-bubble {
  position: absolute;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 3px 7px;
  border: 2px solid #315f70;
  border-radius: 12px;
  color: #23414a;
  background: #fffdf3;
  box-shadow: 0 3px 0 rgba(50, 80, 74, 0.2);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.quarter-bubble::after {
  position: absolute;
  bottom: -7px;
  left: calc(50% - 6px);
  width: 10px;
  height: 10px;
  border-right: 2px solid #315f70;
  border-bottom: 2px solid #315f70;
  background: #fffdf3;
  content: "";
  transform: rotate(45deg);
}

.quarter-selection-actions {
  position: absolute;
  z-index: 2;
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 2px solid rgba(49, 95, 112, 0.82);
  border-radius: 14px;
  background: rgba(255, 253, 243, 0.97);
  box-shadow: 0 4px 0 rgba(50, 80, 74, 0.22);
  pointer-events: auto;
}

.quarter-selection-action {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: #174f78;
  background: #e7f4ff;
  box-shadow: inset 0 0 0 2px rgba(37, 102, 149, 0.22);
}

.quarter-selection-action:hover,
.quarter-selection-action:focus-visible {
  color: #0f3e60;
  background: #cfeaff;
}

.quarter-selection-action.is-cancel {
  color: #4e5f67;
  background: #eef2f3;
  box-shadow: inset 0 0 0 2px rgba(78, 95, 103, 0.2);
}

.quarter-selection-action.is-cancel:hover,
.quarter-selection-action.is-cancel:focus-visible {
  color: #2f3c42;
  background: #dfe7e9;
}

.quarter-selection-action.is-delete {
  color: #8f322e;
  background: #ffebe8;
  box-shadow: inset 0 0 0 2px rgba(179, 70, 63, 0.22);
}

.quarter-selection-action.is-delete:hover,
.quarter-selection-action.is-delete:focus-visible {
  color: #70211e;
  background: #ffd6d1;
}

.quarter-selection-action svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.opinion-layout {
  display: grid;
  grid-template-columns: minmax(600px, 0.62fr) minmax(340px, 0.38fr);
  gap: 18px;
  align-items: start;
}

.compact-map { align-self: start; }

.resident-list {
  display: grid;
  gap: 12px;
}

.resident-advisory,
.simulation-compare-panel,
.readonly-simulation-card {
  display: grid;
  gap: 12px;
}

.situation-card,
.simulation-compare-panel,
.readonly-simulation-card,
.happiness-result {
  padding: 16px;
  border: 2px solid rgba(73, 113, 125, 0.28);
  border-radius: 18px;
  background: rgba(255, 253, 243, 0.96);
  box-shadow: 0 5px 0 rgba(49, 95, 112, 0.1);
}

.situation-card {
  border-color: #79a9d7;
  background: linear-gradient(145deg, #e7f6ff, #fff9df);
}

.situation-card > span {
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 900;
}

.situation-card h3,
.simulation-compare-panel h3,
.readonly-simulation-card h3,
.happiness-result h3 { margin: 4px 0; }

.situation-card p,
.simulation-compare-panel p,
.readonly-simulation-card p,
.happiness-result p { margin: 4px 0; line-height: 1.45; }

.resident-population { color: #765314; font-weight: 900; }

.simulation-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.simulation-status {
  min-height: 1.5em;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.simulation-explore-help {
  margin: 0;
  padding: 10px 12px;
  border-left: 5px solid var(--blue);
  border-radius: 9px 13px 13px 9px;
  color: #244d64;
  background: #edf7ff;
  font-size: 0.86rem;
  font-weight: 700;
}

.resident-onboarding-card {
  position: absolute;
  z-index: 45;
  top: 62px;
  right: 12px;
  width: min(310px, calc(100% - 24px));
  padding: 14px 44px 14px 14px;
  border: 3px solid #e1a42d;
  border-radius: 16px;
  color: #4f3b12;
  background: rgba(255, 250, 219, 0.98);
  box-shadow: 0 7px 0 rgba(108, 78, 18, 0.18);
}

.resident-onboarding-card > strong {
  display: block;
  margin-bottom: 5px;
  color: #6e4d08;
  font-size: 1.05rem;
}

.resident-onboarding-card p {
  margin: 0 0 10px;
  line-height: 1.45;
}

.resident-guide-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid #bd861d;
  border-radius: 50%;
  color: #6e4d08;
  background: #fffdf1;
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
}

.resident-guide-close:hover,
.resident-guide-close:focus-visible {
  color: white;
  background: #8b6110;
}

.ai-narration-status {
  width: fit-content;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid #88a8d6;
  border-radius: 999px;
  color: #264f79;
  background: #eef6ff;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.4;
}

.ai-narration-status[data-ai-narration-state="succeeded"] {
  border-color: #79af93;
  color: #256046;
  background: #eefbf3;
}

.happiness-result {
  border-color: #f2c34e;
  background: #fff9d9;
}

.happiness-result > h3,
.happiness-comparison strong,
.readonly-simulation-card > strong {
  color: #765314;
  font-size: 1.25rem;
  font-weight: 900;
}

.advice-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.advice-columns > div {
  padding: 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.78);
}

.advice-columns h4 { margin: 0 0 5px; font-size: 0.9rem; }
.advice-columns ul { margin: 0; padding-left: 20px; }
.advice-columns li { margin: 4px 0; font-size: 0.84rem; line-height: 1.4; }

.simulation-compare-panel {
  max-width: 1180px;
  margin: 20px auto 0;
  scroll-margin-top: 16px;
  border-color: #75b394;
  background: linear-gradient(145deg, #effaf2, #fffce8);
}

.improvement-comparison-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.improvement-comparison-heading > :first-child { min-width: 0; }

.improvement-comparison-heading .improvement-submit-actions {
  flex: 0 0 auto;
  max-width: none;
  margin: 0;
}

.improvement-submit-actions {
  flex-direction: column;
  align-items: center;
}

.submit-scope-help {
  max-width: 310px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.happiness-comparison {
  display: grid;
  grid-template-columns: auto auto auto minmax(220px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: white;
}

.happiness-comparison p { margin: 0; }

.readonly-simulation-card {
  margin-bottom: 14px;
  border-color: #98c7af;
  background: #f2fbf5;
}

.resident-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.resident-card img {
  width: 58px;
  height: 58px;
  padding: 7px;
  border-radius: 50%;
  background: var(--sky);
}

.resident-card.is-good { border-left: 6px solid var(--green); }
.resident-card.is-consider { border-left: 6px solid var(--yellow); }
.resident-card h3 { margin: 0; font-size: 1rem; }
.resident-card .resident-name { color: var(--blue-dark); font-size: 0.82rem; font-weight: 900; }
.resident-card .ai-narration-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #315b82;
  background: #e8f3ff;
  font-size: 0.7rem;
  font-weight: 900;
  vertical-align: middle;
}
.resident-card p { margin: 3px 0; font-size: 0.9rem; line-height: 1.45; }
.resident-card .reason { color: var(--muted); font-size: 0.78rem; }

#improve-resident-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.perspective-note {
  max-width: 950px;
  margin: 22px auto 0;
}

.improvement-form {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 9px 18px;
  max-width: 1050px;
  margin: 22px auto 0;
  align-items: center;
}

.optional-form-note {
  grid-column: 1 / -1;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.improvement-form label span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.improvement-form input,
.improvement-form textarea,
.improvement-form select {
  margin: 0;
}

.selected-advisor-note {
  grid-column: 1 / -1;
  margin: 3px 0 0;
  padding: 9px 12px;
  border-radius: 11px;
  color: #75521a;
  background: #fff4d3;
  font-weight: 800;
}

.selected-advisor-note.is-complete {
  color: #275c45;
  background: #e6f5e9;
}

.improvement-run-actions,
.improvement-submit-actions {
  justify-content: center;
  margin-top: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.summary-card {
  padding: 20px;
}

.summary-card h3 { margin-top: 0; }

.summary-drawing {
  display: block;
  width: 100%;
  max-height: 260px;
  margin-bottom: 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: white;
  object-fit: contain;
}

.summary-card dl { margin: 0; }
.summary-card dt { margin-top: 9px; color: var(--blue-dark); font-size: 0.82rem; font-weight: 900; }
.summary-card dd { margin: 1px 0; white-space: pre-wrap; }
.big-summary { color: #765314; font-size: 1.25rem; font-weight: 900; }
.meta-card { background: #eef8f2; }
.summary-actions { justify-content: center; }
.completion-scope {
  max-width: 860px;
  margin: 0 auto 16px;
  padding: 11px 14px;
  border: 1px solid #e4cb8b;
  border-radius: 13px;
  color: #72531b;
  background: #fff7dc;
  font-weight: 900;
  text-align: center;
}
.completion-scope[data-scope="online"] {
  border-color: #90c8ae;
  color: #245d48;
  background: #edf9f2;
}
.transfer-note { max-width: 930px; margin: 20px auto 0; }

.app-footer {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 10px 0 12px;
  color: var(--muted);
  text-align: center;
  font-size: 0.85rem;
}

.app-footer > p {
  margin: 0;
}

.source-disclosure {
  max-width: 920px;
  margin: 10px auto 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
}

.source-disclosure summary {
  cursor: pointer;
  color: var(--blue-dark);
  font-weight: 900;
}

.source-disclosure p { margin: 7px 0 0; }

@media (prefers-reduced-motion: reduce) {
  .button[aria-busy="true"]::before { animation-duration: 1400ms; }
}

/* 온라인 학급방 계층은 기존 학습 화면의 카드 언어를 그대로 사용합니다. */
.app-header-actions {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px 24px;
  min-width: 0;
}

.header-button-group { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.app-header-actions .button { min-height: 44px; white-space: nowrap; }
.app-header-actions .save-status-group { flex-direction: column; align-items: flex-end; width: 196px; flex: 0 0 196px; gap: 3px; }
.app-header-actions .save-indicator { flex: none; width: 100%; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.app-header-actions .cloud-save-indicator { max-width: 100%; }

/* 버튼은 헤더에 두고 실제 전체화면 중에만 활성 편집 screen으로 옮깁니다. */
.app-fullscreen-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid #226252;
  color: #174f43;
  background: #f0faf4;
  white-space: nowrap;
}
.app-fullscreen-toggle svg { flex: none; }
.app-fullscreen-toggle[aria-pressed="true"] { color: #fff; background: #226252; }
.map-fullscreen-toggle { display: none !important; }
.editor-screen-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.editor-screen-toolbar > strong { color: #31564c; margin-right: auto; }
.editor-screen-toolbar > .app-fullscreen-toggle { margin-left: auto; }
.screen.wide-screen:fullscreen {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 10px; border: 0; border-radius: 0;
  overflow: hidden; background: #edf7f4;
}
.screen.wide-screen:fullscreen > .screen-heading { display: none; }
.screen.wide-screen:fullscreen > .editor-screen-toolbar { flex: none; margin: 0 0 8px; }
.screen.wide-screen:fullscreen .editor-screen-toolbar > .personal-toolbar {
  order: 5; width: 100%; max-height: 90px; overflow-y: auto;
  margin: 0; padding: 0; gap: 5px 12px; border: 0;
}
.screen.wide-screen:fullscreen #personal-mode-label { font-size: .78rem; }
.screen.wide-screen:fullscreen #experience-server-state { flex-basis: 100%; font-size: .7rem; }
.editor-activity-menu { position: relative; }
.editor-activity-menu > summary { min-height: 44px; padding: 10px 14px; border: 1px solid #96b7a8; border-radius: 12px; background: #fff; cursor: pointer; }
.editor-activity-menu > .personal-activities { position: absolute; z-index: 90; top: 100%; right: 0; width: 240px; padding: 10px; background: #fff; border: 1px solid #96b7a8; border-radius: 12px; box-shadow: var(--shadow); }
.editor-activity-menu > .personal-activities .button { flex: 1 1 40%; }
.editor-activity-menu > summary:focus-visible { outline: 3px solid #226252; outline-offset: 2px; }
.screen.wide-screen:fullscreen > .town-workspace {
  flex: 1 1 0; min-height: 0; width: 100%;
  grid-template-columns: clamp(210px, 19vw, 280px) minmax(0, 1fr);
  align-items: stretch; gap: 10px;
}
.screen.wide-screen:fullscreen .palette-card { position: static; min-height: 0; overflow: auto; }
.screen.wide-screen:fullscreen .town-stage-card { display: flex; flex-direction: column; min-height: 0; padding: 8px; }
.screen.wide-screen:fullscreen .town-stage-card > .town-legend,
.screen.wide-screen:fullscreen .town-stage-card > .map-interaction-help { display: none; }
.screen.wide-screen:fullscreen .map-camera { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.screen.wide-screen:fullscreen .map-camera-toolbar { flex: none; margin-bottom: 6px; }
.screen.wide-screen:fullscreen .town-scroll { flex: 1 1 0; min-height: 0; }
.screen.wide-screen:fullscreen .town-grid { height: 100%; min-height: 0; }
.screen.wide-screen:fullscreen > .screen-actions { flex: none; margin: 8px 0 0; }
.screen.wide-screen:fullscreen > #status-message {
  position: absolute; z-index: 100; top: auto; bottom: 76px;
  left: 50%; transform: translateX(-50%); margin: 0;
  width: min(800px, calc(100% - 40px)); pointer-events: none;
}
.screen.wide-screen:fullscreen > #storage-warning { flex: none; order: -1; margin: 0 0 6px; }
.screen.wide-screen:fullscreen .palette-card > .improvement-form,
.screen.wide-screen:fullscreen .palette-card > .simulation-compare-panel { margin-top: 14px; padding: 10px; }
.screen.wide-screen:fullscreen .improvement-comparison-heading { display: block; }
.screen.wide-screen:fullscreen .advice-columns { grid-template-columns: 1fr; }
@media (max-width: 680px) {
  .screen.wide-screen:fullscreen > .town-workspace { grid-template-columns: 180px minmax(0, 1fr); }
  .screen.wide-screen:fullscreen .palette-card { padding: 7px; }
  .screen.wide-screen:fullscreen .facility-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen.wide-screen:fullscreen .editor-screen-toolbar > strong { display: none; }
}
.home-secondary-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.personal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto 10px;
  padding: 10px 14px;
  border: 1px solid #c4dcd2;
  border-radius: 16px;
  background: #fffdf8;
  color: #31564c;
  font-size: .85rem;
}
.personal-activities, #experience-role-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.experience-guide { display: flex; align-items: center; gap: 8px; flex: 1 1 630px; }
.experience-guide-copy { flex: 1; min-width: 0; }
.experience-guide-copy p { margin: 4px 0 0; font-size: .78rem; line-height: 1.4; }
.experience-free-menu { position: relative; }
body[data-play-mode="experience"] .experience-free-menu { flex: 1 1 100%; }
.experience-free-menu > summary { width: fit-content; max-width: 100%; cursor: pointer; padding: 10px; min-height: 44px; border: 1px solid #c4dcd2; border-radius: 10px; }
.experience-free-menu[open] > div { margin-top: 8px; }
.experience-free-menu select { max-width: 250px; min-height: 44px; border: 1px solid #9bbbab; border-radius: 9px; padding: 5px; }
.personal-file-controls, .teacher-example-controls { display: flex; flex-wrap: wrap; gap: 6px; }
body[data-workspace-purpose="teacher-example"] .personal-file-controls { display: none; }
body[data-workspace-purpose="teacher-example"] #experience-free-menu { display: none; }
body[data-workspace-purpose="teacher-example"] .screen:fullscreen #personal-mode-label { display: block; }
.experience-fresh-row { display: flex !important; align-items: center; justify-content: space-between; gap: 16px; padding: 12px; border-radius: 10px; background: #eef6f1; cursor: pointer; }
.experience-fresh-row[hidden] { display: none !important; }
.online-dialog-form .experience-fresh-row input { width: 20px; height: 20px; min-height: 20px; margin: 0; flex: none; accent-color: #226252; }
.real-works-directory { padding: 14px; margin: 12px 0; border: 1px solid #c4dcd2; background: #f4f9f5; border-radius: 14px; }
.real-works-room-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
body[data-play-mode="experience"] [data-screen] > .screen-heading > .step-chip { display: none; }
body[data-play-mode="experience"] .screen-actions > .button.primary { background: #e5f2eb; color: #245747; border-color: #a8caba; box-shadow: none; }
.screen.wide-screen:fullscreen .editor-screen-toolbar > .personal-toolbar { max-height: 130px; }
.screen.wide-screen:fullscreen .experience-guide { flex-basis: 60%; }
.screen.wide-screen:fullscreen .experience-guide-copy p { display: none; }
.screen.wide-screen:fullscreen .experience-free-menu[open] { max-height: 180px; overflow: auto; }
@media (max-width: 760px) {
  .experience-guide { flex-wrap: wrap; flex-basis: 100%; }
  .experience-guide-copy { flex-basis: 100%; }
  .experience-guide-copy p { display: none; }
}
.personal-activities .button, #experience-role-controls .button { min-height: 44px; }
#experience-student-select { max-width: 190px; min-height: 44px; border: 1px solid #9bbbab; border-radius: 9px; padding: 5px; }
#experience-server-state { font-size: .76rem; color: #4c6661; }
body[data-play-mode="guest"] .progress-shell,
body[data-play-mode="experience"] .progress-shell { display: none; }
body[data-play-mode] .app-header,
body[data-play-mode] .app-main { width: min(1680px, calc(100% - 32px)); }
body[data-play-mode="guest"] .app-header,
body[data-play-mode="experience"] .app-header {
  position: sticky; top: 0; z-index: 60;
  padding-block: 8px; gap: 12px;
  background: rgba(244, 251, 248, .98);
  border-bottom: 1px solid #c4dcd2;
}
body[data-play-mode="guest"] .app-header h1,
body[data-play-mode="experience"] .app-header h1 { font-size: clamp(1rem, 1.55vw, 1.4rem); }
body[data-play-mode="guest"] .save-status-group,
body[data-play-mode="experience"] .save-status-group { font-size: .76rem; }
body[data-play-mode] .wide-screen { padding: 18px; border-radius: 22px; }
body[data-play-mode] .wide-screen > .screen-heading { max-width: none; margin: 0 0 14px; text-align: left; }
body[data-play-mode] .wide-screen > .screen-heading h2 { display: inline; margin-left: 10px; font-size: clamp(1.25rem, 2vw, 1.65rem); }
body[data-play-mode] .wide-screen > .screen-heading p { margin-top: 5px; font-size: .86rem; }
body[data-play-mode] .town-workspace { grid-template-columns: 270px minmax(0, 1fr); gap: 14px; }
body[data-play-mode] .palette-card,
body[data-play-mode] .town-stage-card { padding: 12px; border-radius: 16px; }
body[data-play-mode] .town-grid { height: clamp(420px, 61vh, 800px); background: #dbeadc; }
body[data-play-mode] .town-grid .quarter-ground-tile { background: #bed5a9; border-color: #b8cfa5; }
body[data-play-mode] .town-grid .quarter-ground-tile.is-alternate { background: #c4d9b0; }
.quarter-resident[data-life-phase="visiting"]::after { content: ""; position: absolute; top: 0; right: 0; width: 8px; height: 8px; border: 2px solid white; border-radius: 50%; background: #22845a; pointer-events: none; }
.resident-life-changes { margin: 12px 0; padding: 12px 30px; background: #eaf5eb; border-radius: 14px; }
.resident-life-changes:empty { display: none; }
@media (max-width: 1050px) {
  body[data-play-mode] .town-workspace { grid-template-columns: 230px minmax(0, 1fr); }
  .personal-toolbar { gap: 6px; padding: 8px; }
}
@media (max-width: 760px) {
  body[data-play-mode] .app-header { gap: 10px; padding-block: 10px; }
  body[data-play-mode] .town-workspace { grid-template-columns: minmax(0, 1fr); }
  body[data-play-mode] .facility-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body[data-play-mode] .wide-screen { padding: 10px; }
  .app-fullscreen-toggle { min-height: 46px; }
}

.save-status-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.cloud-save-indicator,
.online-session-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.cloud-save-indicator {
  min-width: 0;
  white-space: nowrap;
  padding: 7px 10px;
  border: 1px solid #b7d6ca;
  border-radius: 999px;
  color: var(--green-dark);
  background: #f2fbf5;
  font-size: 0.8rem;
  font-weight: 800;
}

.cloud-save-indicator span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-save-indicator[data-cloud-status="failed"] {
  border-color: #e7aaa4;
  color: var(--coral-dark);
  background: #fff3f1;
}

.online-session-status {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

/* 접속 모드와 체험 역할은 로그아웃 버튼과 별도로 읽을 수 있게 표시합니다. */
.online-session-actions:has(.online-session-status:not(.sr-only)) { flex-wrap: wrap; }
.online-session-status:not(.sr-only) { flex-basis: 100%; text-align: right; color: var(--blue-dark); }

.public-room-section {
  grid-column: 1 / -1;
  padding: 22px;
  border: 2px solid #c9e1d8;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
}

.public-room-heading,
.online-view-heading,
.online-view-actions,
.gallery-town-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.public-room-heading h3,
.gallery-town-heading h3 { margin: 0; }
.public-room-heading > p { max-width: 560px; margin: 0; color: var(--muted); }

.public-room-list,
.gallery-town-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.public-room-card,
.gallery-town-card,
.gallery-feedback-card,
.management-list-card {
  position: relative;
  padding: 17px;
  border: 1px solid #cbdedb;
  border-radius: 17px;
  background: white;
  box-shadow: 0 8px 22px rgba(35, 67, 78, 0.08);
}

.public-room-card h4,
.gallery-town-card h4,
.management-list-card h4 { margin: 0 0 4px; }
.public-room-card p,
.gallery-town-card p,
.management-list-card p { margin: 4px 0; }
.public-room-meta,
.public-room-count,
.gallery-town-author { color: var(--muted); font-size: 0.85rem; }
.public-room-count { font-weight: 800; }

.public-room-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.public-room-card-content { min-width: 0; }
.public-room-card-actions {
  justify-self: end;
  white-space: nowrap;
}

.gallery-town-card {
  width: 100%;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.gallery-town-card:hover,
.gallery-town-card:focus-visible,
.gallery-town-card.is-selected {
  border-color: #267c69;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(38, 124, 105, 0.2), 0 8px 22px rgba(35, 67, 78, 0.1);
}

.gallery-town-card.is-selected { background: #effaf5; }
.gallery-town-select-label {
  display: inline-block;
  margin-top: 7px;
  color: #286955;
  font-size: 0.8rem;
  font-weight: 900;
}

.online-state-message {
  padding: 11px 13px;
  border-radius: 12px;
  color: var(--muted);
  background: #f3f8f6;
}

.online-state-message.is-error,
.online-form-error { color: #9f3932; background: #fff1ef; }
.online-form-error { padding: 9px 11px; border-radius: 10px; font-weight: 800; }

.online-view { display: block; }
.online-view[hidden] { display: none; }
.online-view-actions { justify-content: flex-end; margin-bottom: 15px; }
.gallery-town-view { margin-top: 22px; }
.gallery-map-card { margin-top: 14px; }

.viewer-guide,
.facility-legend {
  margin: 14px 0;
  border: 1px solid #bcd8d0;
  border-radius: 14px;
  background: #f5fbf8;
}

.viewer-guide summary,
.facility-legend summary {
  padding: 11px 14px;
  color: var(--blue-dark);
  cursor: pointer;
  font-weight: 900;
}

.viewer-guide[open] summary { border-bottom: 1px solid #d5e6e0; }
.viewer-guide ol {
  padding: 0 20px 12px 36px;
  margin: 10px 0 0;
  line-height: 1.55;
}
.viewer-guide li + li { margin-top: 5px; }

.building-name-status {
  padding: 9px 12px;
  margin: 10px 0 0;
  border-radius: 11px;
  color: #264e5c;
  background: #edf7f4;
  font-weight: 900;
}

.resident-opinion-panel {
  margin-top: 16px;
  padding: 15px;
  border: 1px solid #c8ded8;
  border-radius: 16px;
  background: #fbfefc;
}
.resident-opinion-panel > h3 { margin: 0; }
.resident-opinion-panel > p { margin: 5px 0 12px; color: var(--muted); }
.gallery-resident-opinion-panel { margin-top: 18px; }

.rank-badge,
.top3-like-count {
  display: inline-block;
  padding: 4px 8px;
  margin: 0 5px 7px 0;
  border-radius: 999px;
  color: #664900;
  background: #ffe89a;
  font-size: 0.78rem;
  font-weight: 900;
}

.gallery-like-box { display: grid; justify-items: end; gap: 5px; }
.gallery-like-box span { color: var(--muted); font-size: 0.82rem; }

.public-feedback-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 18px;
  margin-top: 18px;
}

.gallery-feedback-list { display: grid; gap: 9px; }
.gallery-feedback-card dl { margin: 0; }
.gallery-feedback-card dt { color: var(--blue-dark); font-size: 0.78rem; font-weight: 900; }
.gallery-feedback-card dd { margin: 0 0 7px; white-space: pre-wrap; }

.public-feedback-form,
.management-form,
.online-dialog-form { display: grid; gap: 8px; }
.public-feedback-form textarea,
.management-form input,
.management-form select,
.online-dialog-form input,
.online-dialog-form select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 11px;
  background: white;
}

.management-guide {
  padding: 18px 20px;
  border: 2px solid #b7d9ce;
  border-radius: 18px;
  background: linear-gradient(135deg, #f1fbf5, #f3f9ff);
  box-shadow: 0 8px 22px rgba(35, 67, 78, 0.07);
}

.management-guide-kicker {
  display: inline-block;
  padding: 3px 9px;
  margin: 0 0 5px;
  border-radius: 999px;
  color: #145744;
  background: #ccefdc;
  font-size: 0.78rem;
  font-weight: 900;
}

.management-guide > summary {
  cursor: pointer;
  color: var(--blue-dark);
  font-weight: 900;
}

.management-guide > summary::marker { color: var(--green-dark); }
.management-guide-body { display: grid; gap: 11px; padding-top: 14px; }
.management-context-help h3 { margin: 0; }
.management-guide ol { margin: 0; padding-left: 23px; }
.management-guide li + li { margin-top: 6px; }
.management-guide-caution {
  padding: 10px 12px;
  margin: 0;
  border-left: 4px solid #f1ad3d;
  border-radius: 9px;
  background: #fff8e8;
}

.management-context-help {
  padding: 16px 18px;
  border: 1px solid #c6dcd7;
  border-radius: 15px;
  background: #f5faf8;
}

.management-context-help p { margin: 7px 0 0; }

.student-account-help { display: grid; gap: 10px; }
.student-account-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 9px;
}
.student-account-actions label { display: grid; gap: 5px; min-width: 130px; font-weight: 900; }
.student-account-actions input {
  width: 130px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 11px;
  background: white;
}
.student-account-sheet { display: grid; gap: 8px; }
.student-account-sheet h3,
.student-account-sheet p,
.management-subheading { margin: 0; }
.student-account-table-wrap { overflow-x: auto; }
.student-account-table { width: 100%; border-collapse: collapse; background: white; }
.student-account-table th,
.student-account-table td { padding: 10px 12px; border: 1px solid #bdd3cd; text-align: left; }
.student-account-table th { color: #174f43; background: #e5f5ec; }
.student-account-pin { font-size: 1.12rem; font-weight: 900; letter-spacing: 0.16em; }
.student-account-empty td { color: var(--muted); text-align: center; }
.management-subheading { padding-top: 6px; border-top: 2px solid #dce9e5; }

.management-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0;
}

.management-tabs button {
  padding: 9px 13px;
  border: 1px solid #b9cfca;
  border-radius: 999px;
  color: var(--ink);
  background: white;
  font-weight: 800;
}

.management-tabs button.is-active { color: white; background: var(--blue-dark); }
.management-tabs button[aria-selected="false"] { box-shadow: none; }
.management-count-badge {
  display: inline-block;
  min-width: 1.8em;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 999px;
  color: #174f43;
  background: #e5f5ec;
  font-size: 0.76rem;
  white-space: nowrap;
}
.management-tabs button.is-active .management-count-badge { color: #153c34; background: #f2fff8; }
.management-grid { display: grid; gap: 14px; }
.management-panel { display: grid; gap: 18px; }
.management-room-list-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: 18px;
}
.management-room-list-section { min-width: 0; }
.management-room-list-section > h3 { margin: 0; }
.management-room-list-section > p { margin: 4px 0 12px; color: var(--muted); }
.management-room-empty {
  padding: 18px;
  margin: 0;
  border: 2px dashed #b7d9ce;
  border-radius: 16px;
  color: #356b5a;
  background: #f5faf8;
  text-align: center;
  font-weight: 900;
}
.management-room-workspace {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 2px solid #bad8cf;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
}
.management-selected-room-heading h3 { margin: 0; font-size: clamp(1.45rem, 2.4vw, 2rem); }
.management-selected-room-heading > p:last-child { margin: 4px 0 0; color: var(--muted); }
.management-room-tabs { margin: 0; padding-bottom: 10px; border-bottom: 1px solid #d5e5df; }
.management-room-panel { display: grid; gap: 14px; }
.management-settings-summary {
  display: grid;
  gap: 5px;
  padding: 15px 17px;
  border-radius: 14px;
  background: #f5faf8;
}
.management-settings-summary p { margin: 0; }
.management-student-card { display: grid; gap: 7px; }
.management-student-card-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px 14px;
}
.management-student-card-heading h4 { margin: 0; }
.management-student-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  color: var(--muted);
}
.management-student-status span {
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf6f3;
  font-size: 0.84rem;
}
.management-student-status .management-town-detail {
  color: #145c4b;
  background: #ddf3e9;
  font-weight: 900;
}
.management-town-help { margin: 0; }
.management-room-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 0; }
.management-room-badges span {
  padding: 3px 8px;
  border-radius: 999px;
  color: #174f43;
  background: #e5f5ec;
  font-size: 0.8rem;
  font-weight: 900;
}
.management-form { align-content: start; padding: 18px; border-radius: 16px; background: #f4faf7; }
.management-form h3 { margin: 0 0 5px; }
.management-form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.management-form-row label { display: grid; gap: 5px; }
.management-form > label,
.online-dialog-form > label { display: grid; gap: 5px; }
.management-list { display: grid; align-content: start; gap: 10px; }

.online-dialog {
  width: min(560px, calc(100% - 28px));
  max-height: calc(100vh - 34px);
  padding: 22px;
  overflow: auto;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 25px 80px rgba(23, 52, 60, 0.34);
}

.online-dialog::backdrop { background: rgba(19, 47, 70, 0.48); backdrop-filter: blur(3px); }
.online-dialog h2 { margin-top: 0; }
.dialog-close-row { display: flex; justify-content: flex-end; }

.student-start-dialog { width: min(760px, calc(100% - 28px)); }
.student-start-room-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 18px;
}
.student-start-load-more {
  display: block;
  margin: -4px auto 18px;
}
.student-start-room-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid #c9ded8;
  border-radius: 15px;
  background: #fff;
}
.student-start-room-card h3 { margin: 0 0 3px; }
.student-start-room-card p { margin: 2px 0; color: var(--muted); font-size: 0.84rem; }
.local-experience-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px dashed #b9c9d4;
  border-radius: 15px;
  background: #f7fafc;
}
.local-experience-option h3 { margin: 0 0 3px; font-size: 1rem; }
.local-experience-option p { margin: 0; color: var(--muted); font-size: 0.82rem; }
.local-start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 12px;
}
@media (max-width: 1050px) {
  .home-screen,
  .drawing-layout,
  .town-workspace,
  .opinion-layout {
    grid-template-columns: 1fr;
  }

  .home-screen { min-height: auto; }
  body:has(.home-screen:not([hidden])) #grade-label { font-size: 18px; }
  .home-screen > .hero-copy > .screen-kicker { font-size: 20px; }
  .hero-art { min-height: 310px; }
  .hero-art::before { width: min(82%, 310px); }
  .hero-art img { max-height: 360px; }
  .palette-card { position: static; }
  .improvement-advisor-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .facility-options { grid-template-columns: repeat(4, minmax(90px, 1fr)); }
  .facility-button { min-width: 90px; }
  .resident-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .advice-columns { grid-template-columns: 1fr; }
  .app-header { flex-wrap: wrap; }
  .app-header-actions { max-width: min(700px, 100%); }
  .public-feedback-panel,
  .management-room-list-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  :root { --tile-size: 38px; }
  body { font-size: 16px; }
  .app-header { align-items: flex-start; width: min(100% - 24px, 1480px); }
  .app-main, .progress-shell, .app-footer { width: min(100% - 20px, 1480px); }
  .screen { padding: 22px 15px; border-radius: 21px; }
  .home-screen { gap: 10px; }
  body:has(.home-screen:not([hidden])) #grade-label { font-size: 16px; }
  .hero-art { min-height: 230px; }
  .hero-art::before { width: min(82%, 230px); }
  .home-actions .button { width: 100%; }
  .character-options { grid-template-columns: repeat(2, 1fr); }
  .feeling-options { grid-template-columns: repeat(2, 1fr); }
  .screen-actions { flex-direction: column-reverse; }
  .screen-actions .button { width: 100%; }
  .ceremony-story-card { grid-template-columns: 1fr; padding: 14px; }
  .ceremony-story-card img { max-height: 240px; }
  .ceremony-copy { text-align: center; }
  .facility-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .resident-list, .summary-grid { grid-template-columns: 1fr; }
  .happiness-comparison { grid-template-columns: 1fr auto 1fr; }
  .happiness-comparison p { grid-column: 1 / -1; }
  .improvement-comparison-heading { display: grid; }
  .improvement-comparison-heading .improvement-submit-actions,
  .improvement-comparison-heading .improvement-submit-actions .button { width: 100%; }
  .improvement-form { grid-template-columns: 1fr; }
  .improvement-form label { margin-top: 10px; }
  .warning-banner { flex-direction: column; }
  .app-header { flex-direction: column; }
  .app-header-actions { justify-content: flex-start; width: 100%; }
  .header-button-group { justify-content: flex-start; }
  .save-status-group { justify-content: flex-start; }
  .cloud-save-indicator { flex: 1 1 auto; }
  .online-session-actions { flex-wrap: wrap; }
  .improvement-advisor-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-help-steps li { grid-template-columns: 1fr; }
  .public-room-heading,
  .online-view-heading,
  .gallery-town-heading { flex-direction: column; }
  .public-room-card,
  .student-start-room-card { grid-template-columns: 1fr; }
  .public-room-card-actions,
  .public-room-card-actions .button,
  .student-start-room-card .button { justify-self: stretch; width: 100%; }
  .local-experience-option { align-items: stretch; flex-direction: column; }
  .local-experience-option .button { width: 100%; }
  .local-start-actions { flex-direction: column; }
  .local-start-actions .button { width: 100%; }
  .management-form-row { grid-template-columns: 1fr; }
  .student-account-actions > * { width: 100%; }
  .student-account-actions input { width: 100%; }
  .online-view-actions { flex-wrap: wrap; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@media print {
  body { background: white; }
  .app-header,
  .progress-shell,
  .status-message,
  .warning-banner,
  .app-footer,
  .summary-actions,
  .transfer-note { display: none !important; }
  .app-main { width: 100%; }
  .screen { display: none !important; border: 0; box-shadow: none; }
  .screen[data-screen="summary"] { display: block !important; padding: 0; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-card { break-inside: avoid; box-shadow: none; }

  body.printing-student-accounts .screen[data-screen="summary"],
  body.printing-student-accounts [data-online-view] { display: none !important; }
  body.printing-student-accounts [data-online-view="management"] {
    display: block !important;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  body.printing-student-accounts .online-view-heading,
  body.printing-student-accounts .online-view-actions,
  body.printing-student-accounts .management-guide,
  body.printing-student-accounts .management-primary-tabs,
  body.printing-student-accounts .management-room-tabs,
  body.printing-student-accounts .management-room-list-layout,
  body.printing-student-accounts .management-room-empty,
  body.printing-student-accounts .management-selected-room-heading,
  body.printing-student-accounts [data-management-primary-panel],
  body.printing-student-accounts [data-management-room-panel],
  body.printing-student-accounts .student-account-help { display: none !important; }
  body.printing-student-accounts [data-management-primary-panel="rooms"] {
    display: block !important;
  }
  body.printing-student-accounts #management-room-workspace {
    display: block !important;
    padding: 0;
    border: 0;
  }
  body.printing-student-accounts [data-management-room-panel="accounts"] { display: block !important; }
  body.printing-student-accounts .student-account-sheet { display: grid !important; }
  body.printing-student-accounts .student-account-table-wrap { overflow: visible; }
  body.printing-student-accounts .student-account-table th,
  body.printing-student-accounts .student-account-table td { padding: 8px 10px; }
}
