/* 한채마을 화면. 평평한 색면, 먹 테두리, 단단한 아래 그림자. 조각보와 색동이 신호 요소다. */
:root {
  --dan: #0e6b5c;
  --ju: #d8432b;
  --ju-d: #bb3620;
  --hwang: #f0b429;
  --cheong: #1c4e80;
  --meok: #1d1b19;
  --baek: #f7f2e4;
  --sol: #2f5d4a;
  --paper: #f7f2e4;
  --paper-2: #ece3cd;
  --paper-3: #dccfb2;
  --ink: #1d1b19;
  --ink-2: #5a5143;
  --seam: #a8987a;
  --title: 'Black Han Sans', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --body: 'Gowun Dodum', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --tab: 62px;
  --net: 0px;
  --kb: 0px;
  --saekdong: repeating-linear-gradient(90deg, #d8432b 0 14px, #f0b429 14px 28px, #0e6b5c 28px 42px, #f7f2e4 42px 56px, #1c4e80 56px 70px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  background: var(--sol);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--sol);
  color: var(--ink);
  font: 400 15px/1.6 var(--body);
  font-synthesis: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, p, ul, ol, dl, dd { margin: 0; padding: 0; font-weight: 400; }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { padding: 0; border: 0; background: none; cursor: pointer; }
input, textarea { border-radius: 0; }
summary { cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--hwang); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

#world { position: fixed; inset: 0; z-index: 0; display: block; width: 100%; height: 100%; }
#labels { position: fixed; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
#veil {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(29, 27, 25, .2), rgba(29, 27, 25, 0) 22%, rgba(29, 27, 25, 0) 72%, rgba(29, 27, 25, .22));
}
#ui { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#ui > * { pointer-events: auto; }
.noscript { position: fixed; inset: auto 16px 16px; z-index: 200; padding: 12px; border: 2px solid var(--ink); background: var(--paper); }

/* 단추 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 9px 16px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--ink);
  color: var(--ink);
  font: 400 16px/1.25 var(--title);
  text-align: center;
  text-decoration: none;
}
.btn:active:not([disabled]) { transform: translateY(2px); box-shadow: none; }
.btn[disabled] { box-shadow: none; opacity: .55; cursor: default; }
.btn.pri { background: var(--ju-d); color: #fff; }
.btn.go { background: var(--dan); color: #fff; }
.btn.blue { background: var(--cheong); color: #fff; }
.btn.yellow { background: var(--hwang); color: var(--ink); }
.btn.quiet { background: transparent; box-shadow: none; }
.btn.wide { width: 100%; }
.btn.sm { min-height: 44px; padding: 6px 12px; font-size: 15px; }
.btn svg { flex: none; width: 20px; height: 20px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn { flex: 1 1 140px; }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--hwang);
  color: var(--ink);
  font: 400 12px/1.5 var(--title);
  white-space: nowrap;
}
.tag.plain { background: var(--paper-2); }
.tag.red { background: var(--ju-d); color: #fff; }
.tag.blue { background: var(--cheong); color: #fff; }
.tag.green { background: var(--dan); color: #fff; }

/* 상단 판 */
#hud {
  position: fixed;
  top: calc(var(--sat) + 10px);
  left: calc(var(--sal) + 10px);
  right: calc(var(--sar) + 10px);
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 460px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.plate {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 8px 7px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--ink);
}
.seal {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 56px;
  border: 2px solid var(--ink);
  border-radius: 8px 7px 9px 6px;
  background: var(--ju-d);
  box-shadow: 0 2px 0 var(--ink);
  color: #fff;
  font: 400 15px/1.05 var(--title);
  writing-mode: vertical-rl;
  letter-spacing: .02em;
  transform: rotate(-3deg);
}
.seal.long { font-size: 13px; }
.seal:active { transform: rotate(-3deg) translateY(2px); box-shadow: none; }
.plate-main { flex: 1; min-width: 0; }
.plate-row { display: flex; align-items: center; gap: 6px; min-height: 26px; }
.plate-name { font: 400 19px/1.2 var(--title); white-space: nowrap; }
.plate-day { color: var(--ink-2); font: 400 13px/1.2 var(--title); white-space: nowrap; }
.tag-btn { min-height: 26px; cursor: pointer; }
.meter {
  height: 9px;
  margin-top: 3px;
  overflow: hidden;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--paper-3);
}
.meter i { display: block; width: 0; height: 100%; background: var(--saekdong); transition: width .5s; }
.plate-next { margin-top: 2px; color: var(--ink); font-size: 13px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--ink);
}
.icon-btn:active { transform: translateY(2px); box-shadow: none; }
.icon-btn.flat { border-color: transparent; background: transparent; box-shadow: none; }
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 4px 10px 4px 4px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--dan);
  box-shadow: 0 2px 0 var(--ink);
  color: #fff;
  text-align: left;
}
.chip:active { transform: translateY(2px); box-shadow: none; }
.chip-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 3px; background: var(--paper); color: var(--dan); }
.chip-text { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.chip.era { background: var(--meok); }
.chip.era .chip-mark { color: var(--meok); }

/* 하단 탭 */
#tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 24;
  display: grid;
  grid-template-columns: 1fr 1fr 84px 1fr 1fr;
  height: calc(var(--tab) + var(--sab));
  padding: 0 calc(var(--sar) + 4px) var(--sab) calc(var(--sal) + 4px);
  border-top: 2px solid var(--ink);
  background: var(--paper);
}
#tabs::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 6px;
  background: var(--saekdong);
  border-top: 1.5px solid var(--ink);
}
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  color: var(--ink-2);
  font: 400 13px/1.2 var(--title);
}
.tab[aria-current='true'] { color: var(--ink); }
.tab[aria-current='true']::after {
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 2px;
  height: 4px;
  background: var(--ju);
}
.tab-home {
  position: relative;
  align-self: start;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 74px;
  height: 74px;
  margin-top: -22px;
  border: 2px solid var(--ink);
  border-radius: 11px 9px 12px 8px;
  background: var(--ju-d);
  box-shadow: 0 3px 0 var(--ink);
  color: #fff;
  font: 400 15px/1.15 var(--title);
  transform: rotate(-2deg);
}
.tab-home svg { width: 30px; height: 30px; }
.tab-home:active { transform: rotate(-2deg) translateY(3px); box-shadow: none; }
.tab-home[aria-current='true'] { background: var(--ink); }

/* 이무기 단추 */
#imoogi {
  position: fixed;
  right: calc(var(--sar) + 12px);
  bottom: calc(var(--tab) + var(--sab) + 22px + var(--net));
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 2px solid var(--ink);
  border-radius: 50% 46% 52% 48%;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--ink);
  color: var(--dan);
}
#imoogi:active { transform: translateY(2px); box-shadow: none; }
#imoogi[aria-pressed='true'] { background: var(--dan); color: #fff; }
#sound {
  position: fixed;
  right: calc(var(--sar) + 12px);
  bottom: calc(var(--tab) + var(--sab) + 84px + var(--net));
  z-index: 14;
}
#sound[aria-pressed='true'] { background: var(--hwang); }

/* 시트: 폰은 바닥에서 올라오고 PC는 오른쪽에 붙는다 */
#sheet {
  position: fixed;
  left: var(--sal);
  right: var(--sar);
  bottom: calc(var(--tab) + var(--sab) + 6px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--sat) - var(--tab) - var(--sab) - 14px);
  max-width: 640px;
  margin: 0 auto;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: var(--paper);
  transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  will-change: transform;
}
#sheet.dragging { transition: none; }
.sheet-head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 10px 6px 6px 16px;
  background: var(--hd, var(--dan));
  color: var(--hdt, #fff);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.sheet-head::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 5px;
  width: 44px;
  height: 4px;
  margin-left: -22px;
  border-radius: 2px;
  background: currentColor;
  opacity: .7;
}
.sheet-head::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--saekdong);
  border-top: 1.5px solid var(--ink);
}
.sheet-head h2 { flex: 1; min-width: 0; font: 400 21px/1.2 var(--title); }
.sheet-head .icon-btn.flat { width: 44px; height: 44px; color: inherit; }
.c-news { --hd: var(--dan); }
.c-find { --hd: var(--cheong); }
.c-home { --hd: var(--ju-d); }
.c-market { --hd: var(--hwang); --hdt: var(--ink); }
.c-raid { --hd: var(--meok); }
.c-era { --hd: var(--sol); }
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.sheet-body:focus-visible { outline: none; }

/* 패널 안쪽 */
.sec { padding: 16px 16px 18px; }
.sec + .sec { border-top: 1px dashed var(--seam); }
.sec-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font: 400 18px/1.3 var(--title); }
.sec-title .tag { font-size: 12px; }
.sec-title .right { margin-left: auto; color: var(--ink-2); font: 400 13px/1.3 var(--body); }
.lead { font: 400 17px/1.45 var(--title); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; line-height: 1.5; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.tight { gap: 6px; }
.note-box { padding: 10px 12px; border-left: 5px solid var(--hwang); background: var(--paper-2); font-size: 14px; line-height: 1.5; }
.note-box.bad { border-left-color: var(--ju); }
.note-box.good { border-left-color: var(--dan); }
.empty { padding: 18px 12px; border: 1.5px dashed var(--seam); border-radius: 4px; text-align: center; }
.empty .btn { margin-top: 10px; }

.rows > li { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 0; border-bottom: 1px dashed var(--seam); }
.rows > li:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font: 400 16px/1.35 var(--title); }
.row-sub { color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.row-go { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 0; text-align: left; }
.rank-no { flex: none; width: 34px; font: 400 17px/1 var(--title); text-align: center; }
.rank-no.top { color: var(--ju-d); }
.money { flex: none; font: 400 15px/1.2 var(--title); white-space: nowrap; }

.seg { display: flex; gap: 4px; padding: 10px 12px 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; border-bottom: 2px solid var(--ink); background: var(--paper-2); }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: var(--paper-3);
  color: var(--ink-2);
  font: 400 14px/1.2 var(--title);
  white-space: nowrap;
}
.seg button[aria-selected='true'], .seg button[aria-pressed='true'] { background: var(--paper); color: var(--ink); }
.seg.pill { padding: 0; border: 0; background: none; }
.seg.pill button { border: 2px solid var(--ink); border-radius: 4px; }
.seg.pill button[aria-pressed='true'] { background: var(--ink); color: #fff; }

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #fffdf6;
  font-size: 16px;
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
}
textarea.input { min-height: 88px; resize: none; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row .input { flex: 1; min-width: 0; }
.input-row .btn { flex: none; }

/* 방송 */
.news-row { padding: 10px 0; border-bottom: 1px dashed var(--seam); }
.news-row:last-child { border-bottom: 0; }
.news-row time { color: var(--ink-2); font-size: 13px; }
.news-row h4 { font: 400 16px/1.4 var(--title); }
.news-row p { margin-top: 2px; font-size: 14px; line-height: 1.55; white-space: pre-line; }
.poll-title { margin-bottom: 10px; font: 400 18px/1.4 var(--title); }
.poll-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.poll-choices .btn { min-height: 64px; flex-direction: column; gap: 2px; }
.poll-choices .btn small { font: 400 12px/1.2 var(--body); opacity: .85; }
.poll-choices .btn[aria-pressed='true'] { background: var(--cheong); color: #fff; }
.chief { display: flex; gap: 12px; align-items: flex-start; }
.chief-face { flex: none; width: 58px; height: 58px; }
.chief-say { position: relative; flex: 1; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 4px; background: #fffdf6; font-size: 15px; }
.cmd-write { display: inline-block; padding: 1px 8px; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--hwang); font: 400 14px/1.5 var(--title); }
details.fold { border-bottom: 1px dashed var(--seam); }
details.fold:last-child { border-bottom: 0; }
details.fold summary { display: flex; align-items: center; min-height: 48px; padding: 8px 22px 8px 0; font: 400 15px/1.4 var(--title); list-style: none; position: relative; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::after { content: '+'; position: absolute; right: 4px; font: 400 20px/1 var(--title); }
details.fold[open] summary::after { content: '\2212'; }
details.fold > :not(summary) { padding-bottom: 12px; font-size: 14px; line-height: 1.55; }

/* 찾기 */
.mark-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.mark-grid .btn { justify-content: flex-start; font-size: 15px; }

/* 내 집 */
.home-top { padding: 14px 16px 12px; background: var(--paper-2); }
.home-addr { font: 400 22px/1.25 var(--title); }
.home-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; font-size: 15px; }
.home-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 10px; font-size: 14px; }
.home-stats b { font: 400 18px/1.2 var(--title); }
.step-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 10px; }
.step { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 2px; border: 2px solid var(--ink); border-radius: 3px; background: var(--paper-3); color: var(--ink-2); font: 400 12px/1.15 var(--title); text-align: center; }
.step.on { background: var(--dan); color: #fff; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 92px;
  padding: 8px 4px 6px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--ink);
}
.swatch:active:not([disabled]) { transform: translateY(2px); box-shadow: none; }
.swatch[aria-pressed='true'] { background: var(--paper-3); box-shadow: inset 0 0 0 2px var(--dan); }
.swatch[disabled] { box-shadow: none; opacity: .6; }
.swatch-house { display: block; width: 44px; height: 34px; }
.swatch-name { font: 400 13px/1.2 var(--title); }
.swatch-cost { color: var(--ink-2); font-size: 12px; line-height: 1.2; }
.pick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 48px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 4px; background: var(--paper); box-shadow: 0 2px 0 var(--ink); text-align: left; }
.pick:active:not([disabled]) { transform: translateY(2px); box-shadow: none; }
.pick[disabled] { box-shadow: none; opacity: .6; cursor: default; }
.pick[aria-pressed='true'] { background: var(--ink); color: #fff; }
.pick[aria-pressed='true'] .pick-sub { color: #e8dfca; }
.pick-name { font: 400 15px/1.3 var(--title); }
.pick-sub { color: var(--ink-2); font-size: 12px; line-height: 1.4; }
.pick.side-uijeok[aria-pressed='true'] { background: #a92a20; }
.pick.side-pojol[aria-pressed='true'] { background: var(--cheong); }
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; }
.stat-grid div { padding: 6px 2px; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--paper-2); }
.stat-grid b { display: block; font: 400 18px/1.2 var(--title); }
.stat-grid span { font-size: 12px; }
.rar-common { color: var(--ink-2); }
.rar-rare { color: var(--cheong); }
.rar-legend { color: var(--ju-d); }
.story-row { padding: 10px 12px; border-left: 4px solid var(--dan); background: var(--paper-2); font-size: 14px; line-height: 1.6; white-space: pre-line; }
.story-row time { display: block; color: var(--ink-2); font-size: 12px; }

/* 로그인 */
.code-box { display: flex; align-items: center; justify-content: center; min-height: 76px; padding: 8px; border: 2px solid var(--ink); border-radius: 4px; background: #fffdf6; font: 400 34px/1.1 var(--title); letter-spacing: .04em; user-select: all; -webkit-user-select: all; }
.steps { counter-reset: st; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; counter-increment: st; font-size: 14px; line-height: 1.5; }
.steps li::before { content: counter(st); flex: none; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 3px; background: var(--ink); color: #fff; font: 400 14px/1 var(--title); }
.waiting { display: flex; align-items: center; gap: 8px; }
.waiting i { flex: none; width: 10px; height: 10px; border-radius: 2px; background: var(--dan); animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* 장터 */
.left-bar { height: 6px; margin-top: 4px; overflow: hidden; border: 1px solid var(--ink); background: var(--paper-3); }
.left-bar i { display: block; height: 100%; background: var(--ju-d); }

/* 토벌 */
.monster { display: flex; gap: 14px; align-items: center; }
.monster-mask { flex: none; width: 116px; height: 116px; }
.monster-mask svg { display: block; width: 100%; height: 100%; }
.monster-name { font: 400 22px/1.25 var(--title); }
.monster-line { margin-top: 4px; font-size: 14px; line-height: 1.5; }
.tier { display: inline-flex; gap: 3px; vertical-align: middle; }
.tier i { width: 10px; height: 10px; border: 1.5px solid var(--ink); border-radius: 2px; }
.tier i.on { background: var(--ju-d); }
.team-bar { display: flex; height: 14px; overflow: hidden; border: 1.5px solid var(--ink); border-radius: 2px; background: var(--paper-3); }
.team-bar i { display: block; height: 100%; }
.team-bar .r-shield, .team-key .r-shield { background: var(--cheong); }
.team-bar .r-hand, .team-key .r-hand { background: var(--dan); }
.team-bar .r-club, .team-key .r-club { background: var(--ju-d); }
.team-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 13px; }
.team-key span { display: inline-flex; align-items: center; gap: 5px; }
.team-key i { width: 11px; height: 11px; border: 1px solid var(--ink); }
.raid-log { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-left: 4px solid var(--ink); background: var(--paper-2); font-size: 14px; line-height: 1.5; }
.result { display: inline-flex; padding: 0 8px; border-radius: 3px; color: #fff; font: 400 14px/1.6 var(--title); }
.result.win { background: var(--dan); }
.result.lose { background: var(--ju-d); }
.result.none { background: var(--ink-2); }

/* 시대 */
.era-row { display: flex; gap: 12px; align-items: stretch; width: 100%; min-height: 72px; padding: 10px 0; border-bottom: 1px dashed var(--seam); text-align: left; }
.era-row:last-child { border-bottom: 0; }
.era-mark { flex: none; display: flex; align-items: center; justify-content: center; width: 46px; border: 2px solid var(--ink); border-radius: 7px 6px 8px 5px; background: var(--paper-3); color: var(--ink-2); font: 400 13px/1.1 var(--title); writing-mode: vertical-rl; }
.era-row.now .era-mark { background: var(--ju-d); color: #fff; }
.era-row.past .era-mark { background: var(--dan); color: #fff; }
.era-row[aria-pressed='true'] { background: var(--paper-2); }

/* 집 카드 */
#card {
  position: fixed;
  left: calc(var(--sal) + 10px);
  right: calc(var(--sar) + 10px);
  bottom: calc(var(--tab) + var(--sab) + 20px + var(--net));
  z-index: 22;
  max-width: 460px;
  margin: 0 auto;
  padding: 12px 8px 12px 14px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--ink);
}
.card-top { display: flex; align-items: flex-start; gap: 6px; }
.card-main { flex: 1; min-width: 0; }
.card-addr { color: var(--ink-2); font-size: 13px; line-height: 1.35; }
.card-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: 400 21px/1.25 var(--title); }
.card-line { margin-top: 4px; font-size: 14px; line-height: 1.5; }
.card-act { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 6px 0 0; }
.card-act .btn { flex: 1 1 130px; }
body.card-on #imoogi, body.card-on #sound { display: none; }

/* 입장 카드 */
#entry {
  position: fixed;
  left: calc(var(--sal) + 12px);
  right: calc(var(--sar) + 12px);
  bottom: calc(var(--sab) + 12px);
  z-index: 30;
  max-width: 440px;
  max-height: calc(100dvh - var(--sat) - var(--sab) - 24px);
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
}
.pj-strip { display: block; width: 100%; height: 100%; }
.pj-strip polygon { stroke: var(--baek); stroke-width: 2; }
.entry-strip { height: 66px; overflow: hidden; border-bottom: 2px solid var(--ink); }
.entry-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; }
.entry-brand { display: flex; align-items: center; gap: 8px; }
.entry-brand strong { font: 400 15px/1.2 var(--title); }
.entry-hook { font: 400 clamp(30px, 9.2vw, 38px)/1.14 var(--title); letter-spacing: -.01em; }
.entry-hook span { display: block; }
.entry-sub { font-size: 15px; line-height: 1.5; }
.entry-nums { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.entry-nums div { display: flex; align-items: baseline; gap: 4px; font-size: 13px; }
.entry-nums b { font: 400 22px/1.2 var(--title); }
body.entry-on #hud, body.entry-on #tabs, body.entry-on #imoogi, body.entry-on #sound { visibility: hidden; }

/* 집문서 */
#deed { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: calc(var(--sat) + 10px) 12px calc(var(--sab) + 12px); overflow-y: auto; background: rgba(29, 27, 25, .95); }
#deed .deed-img { display: block; width: auto; max-width: 100%; height: auto; max-height: calc(100dvh - var(--sat) - var(--sab) - 170px); border: 2px solid var(--ink); }
#deed .deed-bar { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; max-width: 440px; }
#deed .deed-bar .btn { flex: 1 1 120px; }
#deed .deed-hint { max-width: 440px; color: var(--baek); font-size: 14px; text-align: center; }

/* 안내 띠 */
#toasts { position: fixed; left: 12px; right: 12px; top: calc(var(--sat) + 12px); z-index: 70; display: flex; justify-content: center; pointer-events: none; }
.toast { max-width: 460px; padding: 10px 14px; border: 2px solid var(--ink); border-radius: 4px; background: var(--ink); box-shadow: 0 2px 0 var(--hwang); color: #fff; font-size: 15px; line-height: 1.45; }
.toast.bad { background: #8f2413; }
.toast.good { background: var(--dan); }
body.offline { --net: 32px; }
#net { position: fixed; left: 0; right: 0; bottom: calc(var(--tab) + var(--sab) + 8px); z-index: 26; padding: 4px 12px; background: var(--meok); color: #fff; font-size: 13px; text-align: center; }

/* 로딩 조각보 */
#loader { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; overflow: hidden; background: var(--baek); }
.pj { position: absolute; inset: 0; width: 100%; height: 100%; }
.pj polygon { stroke: var(--baek); stroke-width: 3.5; opacity: 0; transform-box: fill-box; transform-origin: center; animation: pj-in .44s cubic-bezier(.2, .9, .3, 1.15) forwards; }
.d0 { --d: 0; } .d1 { --d: 1; } .d2 { --d: 2; } .d3 { --d: 3; } .d4 { --d: 4; } .d5 { --d: 5; }
.d6 { --d: 6; } .d7 { --d: 7; } .d8 { --d: 8; } .d9 { --d: 9; } .d10 { --d: 10; } .d11 { --d: 11; }
.pj polygon { animation-delay: calc(var(--d) * 96ms); }
@keyframes pj-in { from { opacity: 0; transform: scale(.72); } to { opacity: 1; transform: scale(1); } }
@keyframes pj-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.8); } }
#loader.lift { background: transparent; pointer-events: none; }
#loader.lift .pj polygon { opacity: 1; animation: pj-out .32s ease-in forwards; animation-delay: calc((11 - var(--d)) * 38ms); }
#loader.lift .loader-plate { opacity: 0; transition: opacity .18s; }
.loader-plate {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: min(320px, 100%);
  padding: 18px 20px 20px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  text-align: center;
}
.loader-title { font: 400 30px/1.2 var(--title); }
.loader-msg { font-size: 15px; line-height: 1.5; }
.loader-plate .btn { margin-top: 10px; }

/* 옆 패널 배치: PC와 가로로 눕힌 폰 */
@media (min-width: 960px), (min-width: 560px) and (max-height: 480px) {
  :root { --panel: min(420px, 48vw); --imoogi-room: 70px; }
  #sheet {
    top: calc(var(--sat) + 12px);
    right: calc(var(--sar) + 12px);
    bottom: calc(var(--sab) + 12px);
    left: auto;
    width: var(--panel);
    max-width: none;
    height: auto;
    margin: 0;
    border-bottom: 2px solid var(--ink);
    border-radius: 12px 4px 4px 4px;
    box-shadow: 0 3px 0 var(--ink);
  }
  .sheet-head { touch-action: auto; padding-top: 8px; }
  .sheet-head::before { display: none; }
  #tabs {
    left: 50%;
    right: auto;
    bottom: calc(var(--sab) + 12px);
    width: min(460px, calc(100vw - 2 * var(--imoogi-room) - 40px));
    height: var(--tab);
    padding: 0 6px;
    border: 2px solid var(--ink);
    border-radius: 6px;
    box-shadow: 0 3px 0 var(--ink);
    transform: translateX(-50%);
    transition: left .26s cubic-bezier(.2, .8, .2, 1), width .26s cubic-bezier(.2, .8, .2, 1);
  }
  #tabs::before { display: none; }
  body.panel-open #tabs {
    --room: calc(100vw - var(--panel) - 36px - var(--imoogi-room));
    left: calc(12px + var(--room) / 2);
    width: min(460px, var(--room));
  }
  #imoogi { bottom: calc(var(--sab) + 18px + var(--net)); right: calc(var(--sar) + 16px); transition: right .26s cubic-bezier(.2, .8, .2, 1); }
  body.panel-open #imoogi { right: calc(var(--panel) + 36px); }
  #sound { bottom: calc(var(--sab) + 80px + var(--net)); right: calc(var(--sar) + 16px); }
  body.panel-open #sound { right: calc(var(--panel) + 36px); }
  #hud { width: 420px; right: auto; }
  body.panel-open #hud { width: min(420px, calc(100vw - var(--panel) - var(--sal) - var(--sar) - 40px)); }
  #card { left: calc(var(--sal) + 16px); right: auto; bottom: calc(var(--sab) + 90px + var(--net)); width: 340px; margin: 0; }
  #entry { left: calc(var(--sal) + 40px); right: auto; bottom: 50%; width: 420px; margin: 0; transform: translateY(50%); }
  #net { left: calc(var(--sal) + 16px); right: auto; bottom: calc(var(--sab) + 84px); }
}

/* 가로로 눕힌 폰은 높이가 모자란다 */
@media (max-height: 480px) {
  :root { --tab: 52px; }
  .chip { display: none; }
  .tab-home { width: 62px; height: 62px; margin-top: -12px; }
  .tab-home svg { width: 24px; height: 24px; }
  #entry { top: calc(var(--sat) + 8px); bottom: calc(var(--sab) + 8px); transform: none; }
  .entry-strip { display: none; }
  .entry-hook { font-size: 26px; }
  /* 패널을 연 가로 폰은 탭 자리가 좁아 이무기와 소리 단추를 잠시 숨긴다 */
  body.panel-open { --imoogi-room: 0px; }
  body.panel-open #imoogi, body.panel-open #sound { display: none; }
  #card { bottom: calc(var(--sab) + 72px + var(--net)); max-height: calc(100dvh - var(--sat) - var(--sab) - 176px); overflow-y: auto; overscroll-behavior: contain; }
}

/* 작은 폰 */
@media (max-width: 350px) {
  .seal { width: 46px; height: 50px; font-size: 13px; }
  .plate { gap: 6px; }
  .plate-name { font-size: 17px; }
  .pick-grid { grid-template-columns: 1fr; }
}

/* 키보드가 올라오면 탭을 치우고 시트를 키보드 위에 붙인다 */
body.kb #tabs, body.kb #imoogi, body.kb #sound, body.kb #net { display: none; }
body.kb #sheet { bottom: var(--kb); height: calc(100dvh - var(--kb) - var(--sat) - 8px); }
body.kb #card { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .pj polygon { opacity: 1; animation: none; }
  #loader.lift { opacity: 0; transition: opacity .2s !important; }
  #loader.lift .pj polygon { animation: none; }
  .waiting i { animation: none; }
}

/* 뒤늦게 더한 세부 */
.tag-btn { position: relative; }
.tag-btn::after { content: ''; position: absolute; inset: -11px -6px; }
.era-mark.long { font-size: 11px; }
.sheet-head h2:focus { outline: none; }
.row-title, .row-sub { display: block; }
.home-top .btn-row { margin-top: 2px; }
.home-top .note-box { margin-bottom: 10px; }
.sec-title .right { margin-left: auto; }
.swatch span { display: block; }
#ui[hidden] { display: none; }
.tab span, .tab-home span { display: inline-flex; }

.c-home .seg { position: sticky; top: 0; z-index: 2; }
@media (max-width: 374px), (min-width: 560px) and (max-height: 480px) { .seg-more { display: none; } }
/* 가로로 눕힌 폰의 좁은 옆 패널에서도 내 집 다섯 칸이 한 줄에 들어가게 한다 */
@media (min-width: 560px) and (max-height: 480px) {
  .seg:not(.pill) { padding: 8px 6px 0; }
  .seg button { min-width: 44px; padding: 6px 4px; font-size: 13px; }
}

/* 아주 작은 가로 폰 */
@media (max-width: 600px) and (max-height: 480px) {
  .tab-home { width: 52px; }
  #tabs { grid-template-columns: 1fr 1fr 58px 1fr 1fr; padding: 0 2px; }
}

.wait-line { margin: 8px 0; }
