:root {
  --ink: #1e2b45;
  --ink-soft: #55607a;
  --paper: #eef4f8;
  --rule: #c3d8e8;
  --margin: #e2786b;
  --stamp: #cf3f33;
  --stamp-dark: #a92c22;
  --chalk: #2f5d4e;
  --chalk-dark: #24453b;
  --dirt: #d8b98a;
  --plate: #f7f2e4;
  --focus: #2f6fdb;
  --display: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --body: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--chalk-dark);
  -webkit-text-size-adjust: 100%;
  word-break: keep-all;
  overflow-wrap: anywhere;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; }

/* ------------------------------------------------ 교문 화면 */
#gate {
  min-height: 100%;
  background: var(--dirt);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.gate-art { position: relative; width: 100%; max-width: 560px; line-height: 0; }
.gate-art svg { width: 100%; height: auto; display: block; }
.plate {
  position: absolute; left: 26%; right: 26%; top: 18.2%; height: 15.4%;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0 4px;
}
#plate-name {
  font-family: var(--display);
  color: #f4f1e8;
  font-size: clamp(14px, 4.6vw, 26px);
  letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 1px rgba(255,255,255,.4);
}

.notebook {
  position: relative;
  width: min(100% - 24px, 480px);
  margin: -6px 0 32px;
  padding: 22px 20px 24px 44px;
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 31px, var(--margin) 31px, var(--margin) 33px, transparent 33px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  border-radius: 4px 4px 10px 10px;
  box-shadow: 0 2px 0 #b99a6c, 0 10px 24px rgba(60, 40, 10, .25);
}
.notebook h1 { font-size: 34px; line-height: 1.1; }
.lede { margin: 4px 0 18px; color: var(--ink-soft); }
.field { margin-bottom: 14px; flex: 1; min-width: 0; }
.field > label, .flabel, .new-school label { display: block; font-family: var(--display); font-size: 17px; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
}
textarea { resize: vertical; }
.row { display: flex; gap: 10px; }
.hint { font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; line-height: 1.5; }
.check { display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--stamp); }
.error { color: var(--stamp-dark); min-height: 1.4em; margin: 0 0 8px; font-size: 14px; }

.results { list-style: none; margin: 6px 0 0; padding: 0; max-height: 220px; overflow: auto; }
.results li button {
  width: 100%; text-align: left; border: 0; background: #fff; padding: 10px 12px;
  border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 8px;
}
.results li:first-child button { border-radius: 8px 8px 0 0; }
.results li:last-child button { border-radius: 0 0 8px 8px; border-bottom: 0; }
.results li button:hover { background: #fdf6e3; }
.results .meta { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.results .empty { padding: 10px 2px; color: var(--ink-soft); font-size: 14px; }
.picked {
  margin: 8px 0 0; padding: 8px 12px; background: #fff; border: 2px dashed var(--stamp);
  border-radius: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.picked button { border: 0; background: none; color: var(--stamp-dark); text-decoration: underline; padding: 0; }
details { margin-top: 8px; }

/* 학교 종류 */
.levels { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 12px; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.levels button { border: 0; border-left: 2px solid var(--ink); background: #fff; padding: 9px 4px; font-family: var(--display); font-size: 16px; }
.levels button:first-child { border-left: 0; }
.levels button[aria-checked="true"] { background: var(--ink); color: #fff; }

/* 내 학교 */
.my-schools { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.my-schools li { display: flex; align-items: stretch; background: #fff; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.my-schools .go { flex: 1; text-align: left; border: 0; background: none; padding: 8px 12px; }
.my-schools .go strong { font-family: var(--display); font-weight: 400; font-size: 16px; display: block; }
.my-schools .go span { font-size: 13px; color: var(--ink-soft); }
.my-schools .go[aria-pressed="true"] { background: #fdf6e3; }
.my-schools .del { border: 0; border-left: 1px solid var(--rule); background: none; padding: 0 12px; font-size: 20px; color: var(--ink-soft); }

/* 캐릭터 고르기 */
.looks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.looks button {
  display: grid; justify-items: center; gap: 2px; padding: 8px; background: #fff;
  border: 2px solid var(--ink); border-radius: 12px; font-family: var(--display); font-size: 16px;
}
.looks canvas { width: 72px; height: 84px; }
.looks button[aria-checked="true"] { border-color: var(--stamp); box-shadow: 0 0 0 3px #f6c7c2; }
summary { cursor: pointer; color: var(--ink-soft); font-size: 14px; }
.new-school { display: grid; gap: 8px; margin-top: 8px; }

.btn {
  border: 2px solid var(--ink); background: #fff; border-radius: 10px;
  padding: 8px 12px; font-family: var(--display); font-size: 16px; line-height: 1.1;
}
.btn:active { transform: translateY(1px); }
.btn-red { background: var(--stamp); border-color: var(--stamp-dark); color: #fff; }
.btn-quiet { border-color: transparent; background: transparent; text-decoration: underline; }

/* 도장 모양 입장 버튼 */
.stamp-btn {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--display); font-size: 22px; letter-spacing: 0.06em;
  color: #fff; background: var(--stamp);
  border: 3px solid var(--stamp); border-radius: 14px;
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 5px #fff;
}
.stamp-btn:disabled { opacity: .6; }

/* ------------------------------------------------ 학교 안 */
#world {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--chalk-dark);
}
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px;
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
}
.school-name {
  margin: 0; font-family: var(--display); font-size: 17px;
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.area-tabs { display: flex; gap: 4px; }
.area-tabs button, .people-btn {
  font-family: var(--display); font-size: 15px;
  border: 2px solid var(--ink); background: var(--plate); border-radius: 6px; padding: 5px 9px;
}
.area-tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.area-tabs button.locked::after { content: " 🔒"; font-size: 12px; }
.people-btn { background: #fff; }

#scene { width: 100%; height: 100%; display: block; touch-action: none; min-height: 0; }
.net {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%); grid-row: 2 / 3; grid-column: 1 / 2; z-index: 6;
  background: var(--ink); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 14px; margin: 0;
}

.tray {
  background: var(--paper);
  border-top: 3px solid var(--ink);
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
}
.emotes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.emotes button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border: 2px solid var(--ink); border-radius: 10px; background: #fff;
  font-size: 12px; font-family: var(--display);
}
.emotes button span { font-size: 22px; line-height: 1; }
.actions { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 2px; }
.actions .btn { flex: none; font-size: 15px; }

.toasts {
  position: absolute; left: 0; right: 0; top: 48px; grid-row: 2 / 3; grid-column: 1 / 2; z-index: 6;
  display: grid; justify-items: center; gap: 6px; pointer-events: none; padding: 0 12px;
}
.toast {
  pointer-events: auto;
  background: #fff; border: 2px solid var(--ink); border-radius: 10px;
  padding: 8px 12px; font-size: 14px; max-width: 420px;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .25s ease-out;
}
.toast .btn { padding: 4px 8px; font-size: 14px; }
@keyframes toast-in { from { transform: translateY(-6px); opacity: 0; } }

.pop {
  position: absolute; left: 8px; right: 8px; bottom: 140px;
  background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 8px;
  display: flex; flex-wrap: wrap; gap: 6px; max-width: 520px; margin: 0 auto;
}
.pop button { border: 2px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 15px; }

.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 88vw);
  background: var(--paper); border-left: 3px solid var(--ink);
  padding: calc(env(safe-area-inset-top) + 12px) 14px 14px; overflow: auto; z-index: 5;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer h2 { font-size: 22px; }
.drawer h3 { font-size: 17px; margin-top: 18px; }
.x { border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 4px; }
#people-list, #blocked-list { list-style: none; margin: 0; padding: 0; }
#people-list li, #blocked-list li {
  display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--rule);
}
.tag {
  font-family: var(--display); background: #fff; border: 2px solid var(--ink); border-radius: 6px;
  padding: 2px 6px; font-size: 14px;
}
.tag small { color: var(--ink-soft); font-family: var(--body); margin-left: 4px; }
.who { flex: 1; min-width: 0; }
.mini { border: 1px solid var(--ink-soft); background: #fff; border-radius: 6px; padding: 3px 8px; font-size: 13px; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--paper); border-top: 3px solid var(--ink);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
  max-width: 560px; margin: 0 auto;
  box-shadow: 0 -8px 24px rgba(0,0,0,.25);
}
.sheet h2 { font-size: 22px; margin-bottom: 6px; }
.sheet p { margin: 0 0 10px; line-height: 1.5; }
.sheet-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.seats { display: flex; gap: 8px; margin: 8px 0; }
.seat { width: 34px; height: 26px; border-radius: 4px; border: 2px solid var(--ink); background: #fff; }
.seat.on { background: #c99b68; }

.outfits { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.outfit {
  border: 2px solid var(--ink); background: #fff; border-radius: 12px; padding: 8px;
  display: grid; justify-items: center; gap: 4px; font-family: var(--display); font-size: 15px;
}
.outfit canvas { width: 72px; height: 84px; }
.outfit small { font-family: var(--body); color: var(--ink-soft); font-size: 12px; }
.outfit[aria-pressed="true"] { border-color: var(--stamp); box-shadow: 0 0 0 3px #f6c7c2; }

.modal {
  position: absolute; inset: 0; z-index: 7; background: rgba(15, 25, 20, .6);
  display: grid; place-items: center; padding: 12px;
}
.modal-box {
  width: min(100%, 900px); background: var(--paper); border: 3px solid var(--ink);
  border-radius: 14px; padding: 12px;
}
#board-canvas {
  width: 100%; aspect-ratio: 80 / 26; display: block;
  background: var(--chalk); border: 8px solid #7a5a3a; border-radius: 6px; touch-action: none;
  cursor: crosshair;
}
.board-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.chalks { display: flex; gap: 8px; }
.chalks button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--ink); }
.chalks button[aria-checked="true"] { box-shadow: 0 0 0 3px var(--stamp); }

/* ------------------------------------------------ 운동장 놀이 */
/* 3D 화면 칸 안에 띄움 (#world 격자의 가운데 줄) */
/* 시작선과 끝선을 둘 다 적어야 그 칸 안에 놓여요 */
.soccer-pill, .zone-btn { position: absolute; grid-row: 2 / 3; grid-column: 1 / 2; z-index: 2; }
.soccer-pill {
  top: 10px; left: 10px; margin: 0;
  background: rgba(255,255,255,.92); border: 2px solid var(--ink); border-radius: 999px;
  padding: 4px 12px; font-family: var(--display); font-size: 14px;
}
.zone-btn {
  bottom: 16px; left: 50%; transform: translateX(-50%);
  font-family: var(--display); font-size: 19px; color: #fff;
  background: var(--stamp); border: 3px solid var(--ink); border-radius: 999px;
  padding: 10px 22px; box-shadow: 0 4px 0 var(--ink);
  animation: zone-in .25s ease-out;
}
.zone-btn:active { transform: translate(-50%, 3px); box-shadow: 0 1px 0 var(--ink); }
@keyframes zone-in { from { transform: translate(-50%, 8px); opacity: 0; } }

/* 화면 밖에 있는 축구공을 가리키는 화살표 */
.ball-pointer {
  position: absolute; grid-row: 2 / 3; grid-column: 1 / 2; z-index: 3;
  width: 46px; height: 46px; margin: -23px 0 0 -23px; padding: 0;
  border-radius: 50%; border: 3px solid var(--ink); background: #fff;
  font-size: 22px; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 3px 0 var(--ink);
}
.ball-pointer .arrow {
  position: absolute; inset: -14px; pointer-events: none;
  transform: rotate(var(--a, 0deg));
}
.ball-pointer .arrow::before {
  content: ""; position: absolute; left: 50%; top: 0; margin-left: -8px;
  border: 8px solid transparent; border-bottom: 10px solid var(--stamp); border-top: 0;
}

/* 구령대 훈화 카드 */
.speech-card {
  position: absolute; grid-row: 2 / 3; grid-column: 1 / 2; z-index: 2;
  left: 10px; right: 10px; bottom: 12px; margin: 0 auto; max-width: 540px;
  background: #fbf8f0; border: 3px solid var(--ink); border-radius: 14px;
  padding: 10px 14px 12px; box-shadow: 0 4px 0 var(--ink);
}
.speech-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.speech-head p { margin: 0; font-family: var(--display); font-size: 15px; color: var(--stamp); }
.speech-q { margin: 0; font-family: var(--display); font-size: 19px; line-height: 1.4; }
.speech-by { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); }
.speech-tip { margin: 6px 0 0; font-size: 14px; line-height: 1.45; padding-top: 6px; border-top: 1px dashed var(--rule); }
.speech-card.fresh .speech-q, .speech-card.fresh .speech-by, .speech-card.fresh .speech-tip { animation: speech-in .4s ease-out; }
@keyframes speech-in { from { opacity: 0; transform: translateY(4px); } }

.game {
  position: absolute; inset: 0; z-index: 8; background: rgba(15, 25, 20, .6);
  display: grid; place-items: center; padding: 10px;
}
.game-box {
  width: min(100%, 420px); max-height: 100%; overflow: auto;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px 12px;
}
.game-box .drawer-head { gap: 8px; margin-bottom: 4px; }
.game-box h2 { font-size: 22px; flex: 1; }
.game-box .hint { margin: 0 0 8px; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
#game-canvas {
  display: block; margin: 0 auto;
  width: min(100%, calc((100vh - 230px) * 0.75));
  width: min(100%, calc((100dvh - 230px) * 0.75)); aspect-ratio: 3 / 4;
  transition: width .2s;
  border: 3px solid var(--ink); border-radius: 10px; touch-action: none; user-select: none; -webkit-user-select: none;
}
.game-board { margin-top: 10px; font-size: 15px; }
.game-board .game-best { font-family: var(--display); font-size: 18px; margin: 0 0 4px; }
.game-board ol { margin: 4px 0 0; padding-left: 24px; }
.game-board li { padding: 2px 0; }
.game-board li.mine { color: var(--stamp); font-weight: 700; }
#game-again { margin-top: 10px; width: 100%; }
/* 순위가 나오면 놀이 화면을 줄여서 한 화면에 다 보이게 */
.game-box.done #game-canvas { width: min(100%, calc((100vh - 400px) * 0.75), 300px); width: min(100%, calc((100dvh - 400px) * 0.75), 300px); }

/* ------------------------------------------------ 학교 시계, 단체 사진, 대항전, 급식실 */
.clock-pill {
  position: absolute; grid-row: 2 / 3; grid-column: 1 / 2; z-index: 2;
  top: 10px; right: 10px; margin: 0;
  background: rgba(30,43,69,.82); color: #fff; border-radius: 999px;
  padding: 4px 12px; font-family: var(--display); font-size: 14px; pointer-events: none;
}
.clock-pill[data-kind="assembly"], .clock-pill[data-kind="soon"] { background: var(--stamp); }
.clock-pill[data-kind="lunch"] { background: #2f7d4f; }
.clock-pill[data-kind="break"] { background: #b7791f; }
.soccer-pill { max-width: calc(100% - 200px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.photo-count {
  position: absolute; grid-row: 2 / 3; grid-column: 1 / 2; z-index: 4;
  inset: 0; display: grid; align-content: start; justify-content: center; justify-items: center; gap: 4px; pointer-events: none;
  padding: 56px 12px 0;
}
.photo-count p {
  margin: 0; background: rgba(255,255,255,.95); border: 3px solid var(--ink); border-radius: 999px;
  padding: 6px 16px; font-family: var(--display); font-size: 17px;
}
.photo-count strong {
  font-family: var(--display); font-size: 96px; line-height: 1; color: #fff;
  text-shadow: 0 4px 0 var(--ink), 0 0 18px rgba(0,0,0,.35);
  animation: count-pop .9s ease-out infinite;
}
@keyframes count-pop { from { transform: scale(1.25); } to { transform: scale(1); } }
.flash {
  position: absolute; grid-row: 2 / 3; grid-column: 1 / 2; z-index: 5; inset: 0;
  background: #fff; pointer-events: none; animation: flash .7s ease-out forwards;
}
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
.photo-box { width: min(100%, 760px); }
#photo-img { display: block; width: 100%; height: auto; border-radius: 6px; background: #1f2d4f; max-height: calc(100vh - 240px); max-height: calc(100dvh - 240px); object-fit: contain; }

.league-box { width: min(100%, 640px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: auto; }
.league-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; }
.league-tabs button {
  flex: none; font-family: var(--display); font-size: 15px;
  border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 5px 12px;
}
.league-tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.league-body h3 { font-size: 16px; margin: 10px 0 4px; }
.league-body ol { margin: 0; padding-left: 26px; }
.league-body li { padding: 4px 0; border-bottom: 1px dashed var(--rule); }
.league-body li.mine { color: var(--stamp); font-weight: 700; }
.league-body li .v { float: right; font-family: var(--display); }
.league-body .empty { color: var(--ink-soft); }
.league-mine { margin: 10px 0 4px; padding: 8px 10px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; font-size: 15px; }

#serve-canvas {
  display: block; margin: 0 auto;
  width: min(100%, calc((100vh - 260px) * 0.75));
  width: min(100%, calc((100dvh - 260px) * 0.75)); aspect-ratio: 3 / 4;
  border: 3px solid var(--ink); border-radius: 10px;
}
.serve-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 10px 0 0; min-height: 30px; }
.serve-list li { background: #fff; border: 2px solid var(--rule); border-radius: 999px; padding: 3px 10px; font-size: 14px; animation: speech-in .3s ease-out; }
#serve-done { margin-top: 10px; width: 100%; }

/* 좁은 휴대폰 화면: 학교 이름 줄과 공간 탭 줄을 나눔 */
@media (max-width: 559px) {
  .speech-card { padding: 8px 12px 10px; }
  .speech-q { font-size: 17px; }
  .speech-tip { font-size: 13px; }
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .area-tabs { order: 3; width: 100%; }
  .area-tabs button { flex: 1; padding: 5px 4px; }
}

@media (min-width: 760px) {
  .tray { display: flex; gap: 12px; align-items: center; justify-content: center; }
  .emotes { grid-template-columns: repeat(5, 76px); }
  .actions { margin-top: 0; }
  .pop { bottom: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
/* 조회 시간에는 훈화 카드가 빨간 테두리 */
.speech-card.assembly { border-color: var(--stamp); box-shadow: 0 4px 0 var(--stamp); }
.area-tabs button#tab-cafe.locked::after { content: " 🔒"; font-size: 12px; }

/* 휴대폰으로 열기 (내 컴퓨터에서 켰을 때) */
.phone-card {
  max-width: 560px; margin: 18px auto 0; padding: 16px; text-align: center;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
}
.phone-card h2 { font-size: 20px; margin: 0 0 8px; }
.phone-card img, .phone-box img { display: block; margin: 0 auto; width: 168px; height: 168px; image-rendering: pixelated; }
.phone-box { width: min(100%, 460px); text-align: center; }
.phone-box img { width: 200px; height: 200px; }
.phone-url { font-family: var(--display); font-size: 18px; margin: 8px 0 4px; word-break: break-all; }

/* 학년별 반 */
.grade-hint { margin: -4px 0 12px; font-size: 13px; }
.switch-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
.switch-list button {
  font-family: var(--display); font-size: 15px; padding: 10px 4px;
  border: 2px solid var(--ink); border-radius: 10px; background: #fff;
}
.switch-list button.empty { border-style: dashed; color: var(--ink-soft); background: transparent; }
.switch-list button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.switch-pick { align-items: flex-end; }
.switch-pick .field { flex: 1; margin: 0; }
.switch-pick .btn { flex: none; }
/* 졸업연도·학년·반 세 칸: 졸업연도 칸을 조금 넓게 */
.row .field-year { flex: 1.35; }
.row select { padding-right: 6px; }

/* 교문: 할 수 있는 것, 안내 링크 */
.features { list-style: none; margin: -8px 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.features li {
  font-size: 13px; line-height: 1; padding: 6px 9px; border-radius: 999px;
  background: #fff; border: 1.5px solid var(--rule); color: var(--ink);
}
.check span { line-height: 1.45; }
.check a, .me-links a, .site-foot a { color: var(--ink); }
.note { color: var(--chalk); font-size: 14px; margin: 0 0 6px; line-height: 1.5; }
.note:empty { display: none; }
.gate-links { text-align: center; margin: 14px 0 0; }
.link-btn { border: 0; background: none; padding: 4px; color: var(--ink-soft); text-decoration: underline; font-size: 14px; }
.site-foot {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin: 0 0 calc(env(safe-area-inset-bottom) + 24px); font-size: 13px;
}
.site-foot a { color: #4a3a22; }
.site-foot span { color: #8a7350; }

/* 교문 위에 뜨는 창 (학교 안 창과 달리 화면에 고정) */
.modal.fixed { position: fixed; }
.small-box { width: min(100%, 420px); padding: 16px; }
.small-box p { line-height: 1.5; margin: 0 0 10px; }
.code-input {
  width: 100%; font-family: var(--display); font-size: 28px; letter-spacing: .18em; text-align: center; text-transform: uppercase;
  padding: 10px 8px; border: 2px solid var(--ink); border-radius: 10px; background: #fff;
}
.small-box .btn { width: 100%; padding: 11px; font-size: 18px; }

/* 내 정보 */
.me-who { margin: 0 0 4px; font-family: var(--display); font-size: 16px; }
.code-box { margin: 10px 0 0; padding: 12px; background: #fff; border: 2px dashed var(--stamp); border-radius: 10px; text-align: center; }
.code-box strong { display: block; font-family: var(--display); font-weight: 400; font-size: 30px; letter-spacing: .16em; }
.code-box strong.expired { color: var(--ink-soft); text-decoration: line-through; }
.code-box span { font-size: 13px; color: var(--ink-soft); }
.me-links { font-size: 14px; margin: 0; }
.btn-danger { border-color: var(--stamp-dark); color: var(--stamp-dark); }
.delete-confirm { margin-top: 10px; display: grid; gap: 8px; }
.delete-confirm label { font-size: 14px; line-height: 1.5; }
.delete-confirm input { padding: 8px 10px; border: 2px solid var(--ink); border-radius: 8px; font-size: 16px; }

/* 조이스틱 (손가락으로 쓰는 기기에서만 보여요) */
.joystick {
  display: none;
  position: absolute; grid-row: 2 / 3; grid-column: 1 / 2; z-index: 3;
  left: calc(env(safe-area-inset-left) + 18px); bottom: 18px;
  width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18) 0 38%, rgba(255,255,255,.32) 39% 100%);
  border: 3px solid rgba(30,43,69,.55);
  box-shadow: 0 4px 0 rgba(30,43,69,.35);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.joystick::before, .joystick::after {
  content: ""; position: absolute; left: 50%; top: 50%; pointer-events: none;
  border: 7px solid transparent;
}
.joystick::before { margin: -60px 0 0 -7px; border-bottom: 8px solid rgba(30,43,69,.45); border-top: 0; }
.joystick::after { margin: 52px 0 0 -7px; border-top: 8px solid rgba(30,43,69,.45); border-bottom: 0; }
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%; background: #fff; border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  transition: transform .14s ease-out; pointer-events: none;
}
.joystick.on { background: radial-gradient(circle, rgba(255,255,255,.3) 0 38%, rgba(255,255,255,.48) 39% 100%); }
.joystick.on .joy-knob { transition: none; background: #fff6d8; }
#world.touch .joystick { display: block; }
/* 손가락으로 쓰는 화면: 왼손 조이스틱, 오른손 놀이 버튼, 훈화 카드는 위로, 알림은 조이스틱 위로 */
#world.touch .zone-btn { left: auto; right: calc(env(safe-area-inset-right) + 16px); bottom: 30px; transform: none; animation-name: zone-in-r; }
#world.touch .zone-btn:active { transform: translateY(3px); }
@keyframes zone-in-r { from { transform: translateY(8px); opacity: 0; } }
#world.touch .speech-card { top: 46px; bottom: auto; }
#world.touch .toasts { top: auto; bottom: 162px; }

/* 상장 */
.awards-sheet { max-height: 84%; overflow: auto; }
.aw-tier { font-family: var(--display); font-size: 17px; margin: 0 0 8px; }
.aw-have { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.aw-card {
  display: grid; justify-items: center; gap: 2px; padding: 10px 4px;
  background: #fff; border: 2px solid var(--rule); border-radius: 12px; color: var(--ink-soft);
}
.aw-card.on { border-color: var(--ink); color: var(--ink); }
.aw-card .aw-icon { font-size: 24px; line-height: 1; }
.aw-card strong { font-family: var(--display); font-weight: 400; font-size: 20px; }
.aw-card small { font-size: 12px; }
.aw-next { margin: 12px 0 4px; }
.aw-next p { margin: 6px 0 0; font-size: 14px; }
.aw-bar { height: 12px; border-radius: 999px; background: #fff; border: 2px solid var(--ink); overflow: hidden; }
.aw-bar span { display: block; height: 100%; background: linear-gradient(90deg, #e8c46a, #cf3f33); transition: width .4s ease-out; }
.awards-sheet h3 { font-size: 17px; margin: 14px 0 6px; }
.aw-today { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.aw-today li { display: grid; gap: 1px; padding: 8px 10px; background: #fff; border: 1.5px solid var(--rule); border-radius: 10px; }
.aw-today li strong { font-family: var(--display); font-weight: 400; font-size: 16px; }
.aw-today li span { font-size: 13px; color: var(--ink-soft); }
.aw-today li.done { background: #f4f9f1; }

/* 상장 받는 장면 */
.cert-wrap { width: min(100%, 440px); display: grid; gap: 10px; animation: cert-in .45s cubic-bezier(.2,.9,.3,1.2); }
@keyframes cert-in { from { transform: translateY(24px) scale(.92); opacity: 0; } }
.cert {
  position: relative; background: #fffdf4; color: #2a2a2a; text-align: center;
  padding: 26px 26px 22px; border-radius: 4px;
  border: 10px solid transparent;
  background-image: linear-gradient(#fffdf4, #fffdf4), repeating-linear-gradient(45deg, #7aa3c9 0 6px, #f3f6fa 6px 12px);
  background-origin: border-box; background-clip: padding-box, border-box;
  box-shadow: inset 0 0 0 2px #7aa3c9, 0 12px 30px rgba(0,0,0,.35);
  font-family: "AppleMyungjo", "Batang", "Nanum Myeongjo", "Noto Serif KR", serif;
}
.cert.gold {
  background-image: linear-gradient(#fffaf0, #fffaf0), repeating-linear-gradient(45deg, #c9a24a 0 6px, #f7e9c4 6px 12px);
  box-shadow: inset 0 0 0 2px #c9a24a, 0 12px 30px rgba(0,0,0,.35);
}
.cert p { margin: 0; }
.cert-no { text-align: left; font-size: 12px; color: #666; }
.cert-title { font-size: 38px; letter-spacing: .6em; margin: 8px 0 6px -0.6em !important; font-weight: 700; }
.cert-award { font-family: var(--display); font-size: 30px; color: #1f2d4f; margin-bottom: 14px !important; }
.cert.gold .cert-award { color: #9a6b12; }
.cert-to { font-size: 15px; font-weight: 700; margin-bottom: 14px !important; white-space: pre-wrap; }
.cert-body { font-size: 15px; line-height: 1.85; text-align: left; word-break: keep-all; margin-bottom: 18px !important; }
.cert-date { font-size: 14px; margin-bottom: 14px !important; }
.cert-from { font-size: 18px; font-weight: 700; display: flex; justify-content: center; align-items: center; gap: 10px; }
.cert-seal {
  display: inline-grid; place-items: center; width: 44px; height: 44px; line-height: 1.1;
  border: 2.5px solid #c8322a; color: #c8322a; border-radius: 6px; font-size: 11px; font-weight: 700;
  transform: rotate(-8deg); opacity: .85;
}
.cert-actions { justify-content: center; }

/* 매점: 아직 안 바꾼 옷, 입어 보기 */
.shop-bal { font-family: var(--display); font-size: 15px; margin: 0 0 8px; }
.outfit.locked small { color: #9a6b12; }
.shop-try { margin-top: 10px; padding: 10px 12px; background: #fff; border: 2px dashed var(--stamp); border-radius: 12px; }
.shop-try p { margin: 0; font-size: 14px; line-height: 1.5; }
#shop { max-height: 86%; overflow: auto; }
