/* 고을고을 game skin: sea-blue world, cream cards with dark wood outlines,
   chunky bevelled buttons, one rounded display font. */
:root {
  --sea: #8fd3f4;
  --sea-deep: #6fc0ea;
  --ink: #3b2a1a;
  --card: #fff8e6;
  --card-2: #ffefc9;
  --soft: #8a7259;
  --free: #f5ecd3;
  --me: #69c35a;
  --r1: #ff8a4c;
  --r2: #4f9cf0;
  --r3: #b67ae8;
  --r4: #2fb5a6;
  --r5: #f06aa6;
  --r6: #c9a227;
  --gold: #ffc93c;
  --gold-dark: #d99a12;
  --green: #6cc04a;
  --green-dark: #3f8a2c;
  --red: #ff6b5c;
  --red-dark: #c4433a;
  --line: 3px solid var(--ink);
  --font: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2e5a73;
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button,
input,
label {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
[hidden] {
  display: none !important;
}

/* Portrait stage, centred like a phone screen on wide displays. */
.stage {
  position: relative;
  width: min(100vw, 480px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, #ffffff40 0 2px, transparent 3px) 0 0 / 46px 46px,
    radial-gradient(circle at 70% 60%, #ffffff30 0 2px, transparent 3px) 0 0 / 62px 62px,
    linear-gradient(var(--sea), var(--sea-deep));
  box-shadow: 0 0 60px #0006;
}

/* ── World ─────────────────────────────────────────────────────────────── */
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.district {
  stroke: #fff;
  stroke-opacity: 0.85;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  transition: fill 0.3s;
}
.district:focus {
  outline: none;
}
.free {
  fill: var(--free);
}
.o0 {
  fill: var(--me);
}
.o1 {
  fill: var(--r1);
}
.o2 {
  fill: var(--r2);
}
.o3 {
  fill: var(--r3);
}
.district.near {
  stroke: #fff;
  stroke-opacity: 1;
  stroke-width: 2.5;
  stroke-dasharray: 5 3;
  animation: march 1.2s linear infinite;
}
.district.free.near {
  fill: #fff6c2;
}
@keyframes march {
  to {
    stroke-dashoffset: -16;
  }
}
.district:hover {
  filter: brightness(1.06);
}
.district.selected {
  stroke: var(--ink);
  stroke-width: 3.5;
  stroke-dasharray: none;
  animation: none;
}
.district.pop {
  animation: pop 0.7s ease-out;
}
@keyframes pop {
  0% {
    filter: brightness(1.8);
  }
  100% {
    filter: none;
  }
}
.names text {
  display: none;
  font-size: var(--label);
  text-anchor: middle;
  dominant-baseline: middle;
  fill: var(--ink);
  paint-order: stroke;
  stroke: #fff;
  stroke-width: calc(var(--label) / 3.5);
  stroke-linejoin: round;
  pointer-events: none;
}
.zoomed .names text.fits,
.names text.selected {
  display: block;
}
.marks {
  pointer-events: none;
}
.capital path:first-child {
  stroke: #fff;
  stroke-width: 5;
}
.capital.o1 {
  fill: var(--r1);
}
.capital.o2 {
  fill: var(--r2);
}
.capital.o3 {
  fill: var(--r3);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  --face: #fff;
  --edge: #c9b58f;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 20px 12px;
  border: var(--line);
  border-radius: 16px;
  background: var(--face);
  box-shadow:
    inset 0 -5px 0 var(--edge),
    0 4px 0 var(--ink);
  font-size: 19px;
  transition: transform 0.06s;
}
.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    inset 0 -2px 0 var(--edge),
    0 1px 0 var(--ink);
}
.btn:disabled {
  filter: grayscale(0.8);
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-green {
  --face: var(--green);
  --edge: var(--green-dark);
  color: #fff;
  text-shadow: 0 2px 0 var(--green-dark);
}
.btn-gold {
  --face: var(--gold);
  --edge: var(--gold-dark);
}
.btn-red {
  --face: var(--red);
  --edge: var(--red-dark);
  color: #fff;
}
.btn-plain {
  --face: #fff;
}
.btn .glyph,
.btn svg {
  width: 26px;
  height: 26px;
}
.wide {
  width: 100%;
}
.big {
  width: 220px;
  min-height: 60px;
  font-size: 24px;
}
.round {
  width: 46px;
  height: 46px;
  padding: 6px;
  border: var(--line);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 3px 0 var(--ink);
  position: relative;
}
.round:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
.glyph {
  width: 100%;
  height: 100%;
  display: block;
}
button:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 2px;
}

/* ── HUD (anchored to the top edge) ────────────────────────────────────── */
.hud {
  position: absolute;
  inset: 0 0 auto;
  padding: calc(10px + var(--top-safe, env(safe-area-inset-top))) 10px 0;
  background: linear-gradient(#2e5a7366, transparent);
  pointer-events: none;
  z-index: 2;
}
.hud > * {
  pointer-events: auto;
}
.resources {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1.15fr 1fr;
  gap: 6px;
}
.res {
  position: relative;
  height: 38px;
  padding: 0 6px 0 30px;
  border: var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 17px;
  margin-left: 10px;
}
.res-icon {
  position: absolute;
  left: -12px;
  top: 50%;
  width: 40px;
  height: 40px;
  transform: translateY(-50%);
  filter: drop-shadow(0 2px 0 #3b2a1a55);
}
.res b {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}
.res i {
  position: absolute;
  right: 4px;
  bottom: -17px;
  font-style: normal;
  font-size: 12px;
  padding: 0 5px;
  border-radius: 6px;
  background: #fff8e6e6;
  color: var(--soft);
}
.res i.up {
  color: #2f8a24;
}
.res i.down {
  color: var(--red-dark);
}
.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}
.spacer {
  flex: 1;
}
.ribbon {
  position: relative;
  padding: 4px 18px 6px 14px;
  background: var(--ink);
  color: #fff;
  font-size: 18px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 50%, 100% 100%, 0 100%);
  box-shadow: 0 3px 0 #0003;
}
#questButton::after {
  content: attr(data-badge);
  position: absolute;
  right: -8px;
  top: -6px;
  padding: 0 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
}
/* Fixed spot under the HUD so it never moves when the panel resizes. */
.zoom {
  position: absolute;
  right: 10px;
  top: calc(124px + var(--top-safe, env(safe-area-inset-top)));
  z-index: 2;
}

/* ── Bottom panel ──────────────────────────────────────────────────────── */
.panel {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(8px + var(--bottom-safe, env(safe-area-inset-bottom)));
  padding: 14px 14px 76px;
  border: var(--line);
  border-radius: 22px;
  background: linear-gradient(var(--card), var(--card-2));
  box-shadow: 0 5px 0 var(--ink);
  z-index: 2;
}
.banner {
  display: inline-block;
  margin: -32px 0 6px;
  padding: 4px 18px 6px;
  border: var(--line);
  border-radius: 12px;
  background: var(--gold);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 22px;
  font-weight: 400;
}
.panel > .banner,
.panel-head {
  align-self: flex-start;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: -32px;
  margin-bottom: 8px;
}
.panel-head .banner {
  margin: 0;
}
.tag {
  margin-top: 26px;
  padding: 2px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--free);
  font-size: 14px;
}
.tag.o0,
.tag.o1,
.tag.o2,
.tag.o3 {
  color: #fff;
  text-shadow: 0 1px 0 #0004;
}
.tag.o0 {
  background: var(--me);
}
.tag.o1 {
  background: var(--r1);
}
.tag.o2 {
  background: var(--r2);
}
.tag.o3 {
  background: var(--r3);
}
.close {
  margin: 26px 0 0 auto;
  width: 34px;
  height: 34px;
  border: var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 15px;
  line-height: 1;
}
.hint {
  margin: 6px 0 10px;
  color: var(--soft);
  font-size: 16px;
}
.reason {
  margin: 8px 0 0;
  text-align: center;
  color: var(--red-dark);
  font-size: 15px;
}
.chips {
  display: flex;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 12px 3px 4px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-size: 16px;
}
.chip .glyph {
  width: 26px;
  height: 26px;
}
.chip b {
  font-weight: 400;
  font-size: 19px;
}

.slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.slot {
  aspect-ratio: 1;
  padding: 0;
  border: var(--line);
  border-radius: 16px;
  background: #b9e08f;
  box-shadow:
    inset 0 -6px 0 #8cc063,
    0 3px 0 var(--ink);
  display: grid;
  place-items: center;
}
.slot.empty {
  background: #e6d9b5;
  box-shadow:
    inset 0 -6px 0 #cdbb8d,
    0 3px 0 var(--ink);
}
.slot.empty .goeul-icon {
  opacity: 0.6;
}
.slot.on {
  outline: 4px solid var(--gold);
  outline-offset: 2px;
  transform: translateY(-2px);
}
.goeul-icon {
  width: 82%;
  height: 82%;
}
.builds {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.build {
  display: grid;
  justify-items: center;
  gap: 0;
  padding: 4px 2px 6px;
  border: var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
  line-height: 1.15;
}
.build:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
.build:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.build .ico {
  width: 40px;
  height: 40px;
}
.build .ico .goeul-icon {
  width: 100%;
  height: 100%;
}
.build b {
  font-weight: 400;
  font-size: 16px;
}
.build small {
  font-size: 12px;
  color: var(--soft);
}
.price {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
  font-size: 15px;
}
.price .glyph {
  width: 16px;
  height: 16px;
}
.link {
  display: block;
  margin: 10px auto 0;
  border: 0;
  background: none;
  color: var(--red-dark);
  font-size: 15px;
  text-decoration: underline;
}

/* The turn button docks inside the panel's bottom edge. */
.turn {
  position: absolute;
  right: 22px;
  bottom: calc(22px + var(--bottom-safe, env(safe-area-inset-bottom)));
  left: 22px;
  min-height: 52px;
  font-size: 22px;
  z-index: 3;
}
.turn.warn {
  animation: nudge 1.2s ease-in-out infinite;
}
@keyframes nudge {
  50% {
    transform: translateY(-3px);
  }
}

/* ── Title screen ──────────────────────────────────────────────────────── */
.title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(64px + var(--top-safe, env(safe-area-inset-top))) 20px calc(56px + var(--bottom-safe, env(safe-area-inset-bottom)));
  background: linear-gradient(#ffffff00 40%, #2e5a7399);
  z-index: 4;
  pointer-events: none;
}
.title-screen > * {
  pointer-events: auto;
}
.logo {
  position: relative;
  display: grid;
  justify-items: center;
  animation: bob 3s ease-in-out infinite;
}
.logo-text {
  font-size: 68px;
  line-height: 1;
  color: var(--gold);
  letter-spacing: 1px;
  -webkit-text-stroke: 10px var(--ink);
  paint-order: stroke fill;
  text-shadow:
    0 6px 0 var(--ink),
    0 10px 18px #0005;
}
.logo-sprout {
  width: 64px;
  height: 40px;
  margin-bottom: -12px;
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Cpath d='M32 38V18' stroke='%233b2a1a' stroke-width='9' stroke-linecap='round'/%3E%3Cpath d='M32 38V18' stroke='%2369c35a' stroke-width='4' stroke-linecap='round'/%3E%3Cellipse cx='19' cy='17' rx='14' ry='8' transform='rotate(25 19 17)' fill='%2369c35a' stroke='%233b2a1a' stroke-width='3.5'/%3E%3Cellipse cx='45' cy='12' rx='14' ry='8' transform='rotate(-25 45 12)' fill='%2398dd6e' stroke='%233b2a1a' stroke-width='3.5'/%3E%3C/svg%3E");
}
.logo-sub {
  margin-top: 14px;
  padding: 4px 16px 6px;
  border: var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 18px;
}
@keyframes bob {
  50% {
    transform: translateY(-6px);
  }
}
.title-actions {
  display: grid;
  gap: 14px;
  justify-items: center;
}

/* ── Feedback ──────────────────────────────────────────────────────────── */
.toast {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 8px 18px 10px;
  border: var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 18px;
  text-align: center;
  z-index: 6;
  animation: rise 0.25s ease-out;
}
.toast.good {
  background: var(--gold);
}
.toast.bad {
  background: #ffe1dc;
}
@keyframes rise {
  from {
    transform: translate(-50%, 10px) scale(0.9);
    opacity: 0;
  }
}
.floaters {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 7;
}
.floater {
  position: fixed;
  transform: translateX(-50%);
  font-size: 22px;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  animation: float 1.3s ease-out forwards;
}
.floater.up {
  color: #9cf06f;
}
.floater.down {
  color: var(--red);
}
@keyframes float {
  to {
    transform: translate(-50%, 40px);
    opacity: 0;
  }
}

/* ── Dialogs ───────────────────────────────────────────────────────────── */
.card-dialog {
  width: min(400px, calc(100vw - 32px));
  max-height: 84dvh;
  padding: 32px 18px 18px;
  border: var(--line);
  border-radius: 24px;
  background: linear-gradient(var(--card), var(--card-2));
  box-shadow: 0 6px 0 var(--ink);
  color: var(--ink);
  font-family: var(--font);
  overflow: visible;
  text-align: center;
}
.card-dialog[open] {
  animation: rise-in 0.22s ease-out;
}
@keyframes rise-in {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}
.card-dialog::backdrop {
  background: #1d3a4bb3;
}
.card-dialog .banner {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  white-space: nowrap;
}
.card-dialog h3 {
  margin: 16px 0 8px;
  font-weight: 400;
  font-size: 17px;
  color: var(--soft);
}
.deltas {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.delta {
  display: grid;
  justify-items: center;
  padding: 6px 2px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
}
.delta span {
  width: 32px;
  height: 32px;
}
.delta b {
  font-weight: 400;
  font-size: 20px;
}
.delta small {
  color: var(--soft);
}
.up {
  color: #2f8a24;
}
.down {
  color: var(--red-dark);
}
.events {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 34dvh;
  overflow: auto;
  text-align: left;
  font-size: 16px;
}
.events li {
  padding: 6px 10px;
  border-radius: 10px;
  background: #fff;
}
.events li.bad {
  background: #ffe1dc;
}
.rank {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  gap: 4px;
}
.rank li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 10px;
  background: #ffffffaa;
  text-align: left;
  border-left: 8px solid var(--free);
}
.rank li.o0 {
  border-color: var(--me);
}
.rank li.o1 {
  border-color: var(--r1);
}
.rank li.o2 {
  border-color: var(--r2);
}
.rank li.o3 {
  border-color: var(--r3);
}
.rank li.me {
  background: #fff;
  outline: 2px solid var(--ink);
}
.rank em {
  font-style: normal;
}
.quests {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.quests li {
  display: grid;
  grid-template-columns: 30px 1fr 64px;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  text-align: left;
}
.q-icon {
  grid-row: span 2;
  width: 30px;
  height: 30px;
}
.quests b {
  grid-row: span 2;
  text-align: right;
  font-weight: 400;
}
.quests progress {
  width: 100%;
  height: 10px;
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 99px;
  background: var(--free);
  overflow: hidden;
}
.quests progress::-webkit-progress-bar {
  background: var(--free);
}
.quests progress::-webkit-progress-value {
  background: var(--green);
}
.quests progress::-moz-progress-bar {
  background: var(--green);
}
.quests .done {
  background: #fff6c2;
}
.menu-actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.menu-actions input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.menu-actions label:focus-within {
  outline: 4px solid var(--gold);
}
.credit {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--soft);
  font-family: system-ui, sans-serif;
}
body:not([data-mode="play"]) .panel {
  padding-bottom: 18px;
}

/* ── Traits, tax and specialties ───────────────────────────────────────── */
.trait {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 10px 2px 3px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-size: 15px;
}
.trait .glyph {
  width: 24px;
  height: 24px;
}
.trait.off {
  opacity: 0.35;
  filter: grayscale(1);
}
.chip.plain {
  padding: 3px 12px;
}
.chips {
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.set,
.tax {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
}
.set .trait {
  padding-right: 7px;
  font-size: 13px;
}
.set-label {
  width: 46px;
  flex: none;
  color: var(--soft);
  font-size: 15px;
}
.seg {
  flex: 1;
  min-height: 40px;
  border: var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 16px;
}
.seg.on {
  background: var(--gold);
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
.yield {
  margin: 4px 0 10px;
  font-size: 14px;
  color: var(--soft);
}
.btn .goeul-icon {
  width: 30px;
  height: 30px;
}
.builds.five {
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.builds.five .build .ico {
  width: 34px;
  height: 34px;
}
.builds.five .build small {
  font-size: 10px;
}
.price em {
  font-style: normal;
  font-size: 11px;
  color: var(--red-dark);
}

/* ── Village (읍면동 layer) ────────────────────────────────────────────── */
.district.inside {
  fill: var(--me);
  stroke: var(--ink);
  stroke-width: 3;
}
.dong {
  fill: #8fd27d;
  stroke: #fff;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}
.dong.built {
  fill: #b9e08f;
}
.dong:hover {
  filter: brightness(1.05);
}
.dong.on {
  stroke: var(--ink);
  stroke-width: 3;
}
.village text {
  font-size: var(--dong-label);
  text-anchor: middle;
  dominant-baseline: middle;
  fill: var(--ink);
  paint-order: stroke;
  stroke: #fff;
  stroke-width: calc(var(--dong-label) / 3.5);
  stroke-linejoin: round;
  pointer-events: none;
}
.village text.on {
  font-weight: 700;
}
.dong-icons {
  pointer-events: none;
}

/* ── Event card ────────────────────────────────────────────────────────── */
.event-art {
  width: 84px;
  height: 84px;
  margin: 4px auto 6px;
  animation: bob 2.4s ease-in-out infinite;
}
.event-title {
  margin: 0 0 14px;
  font-size: 21px;
}
.event-choices {
  display: grid;
  gap: 10px;
}
.event-choices .btn {
  font-size: 17px;
}
.blocker {
  font-size: 13px;
}

/* ── War and troops ────────────────────────────────────────────────────── */
.district.enemy {
  stroke: #c4433a;
  stroke-width: 1.8;
}
.troop circle {
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.troop.o0 circle {
  fill: #e6f6d8;
}
.troop.o1 circle,
.troop.o2 circle,
.troop.o3 circle {
  fill: #ffe1dc;
}
.troop text {
  text-anchor: middle;
  dominant-baseline: central;
  fill: var(--ink);
  font-family: var(--font);
}
.chip.war {
  background: #ffe1dc;
  color: var(--red-dark);
}
.battle {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  text-align: center;
}
.battle span {
  display: grid;
  padding: 4px 0;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
}
.battle .win {
  background: #e6f6d8;
}
.battle small {
  color: var(--soft);
  font-size: 12px;
}
.battle b {
  font-weight: 400;
  font-size: 26px;
}
.battle .vs {
  border: 0;
  background: none;
  font-size: 18px;
  color: var(--red-dark);
}
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.row2 .btn {
  font-size: 17px;
  padding: 8px 10px 10px;
}
.builds.six {
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.builds.six .build {
  grid-template-columns: 34px 1fr;
  grid-template-areas: "ico name" "ico effect" "ico price";
  justify-items: start;
  text-align: left;
  padding: 4px 6px;
  column-gap: 4px;
}
.builds.six .build .ico {
  grid-area: ico;
  width: 34px;
  height: 34px;
  align-self: center;
}
.builds.six .build b {
  grid-area: name;
  font-size: 15px;
}
.builds.six .build small {
  grid-area: effect;
  font-size: 10.5px;
}
.builds.six .build .price {
  grid-area: price;
  font-size: 13px;
  margin: 0;
}

/* ── 방침 ──────────────────────────────────────────────────────────────── */
.focus-row {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}
.focus-now {
  flex: 1;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
}
.focus-now em {
  font-style: normal;
  color: var(--soft);
  font-size: 14px;
}
.focus-now.pick {
  background: var(--gold);
  animation: nudge 1.6s ease-in-out infinite;
}
.dialog-hint {
  margin: 0 0 10px;
  color: var(--soft);
  font-size: 14px;
}
.focus-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.focus-path {
  display: grid;
  grid-template-rows: auto repeat(3, 76px);
  gap: 6px;
}
.focus-path h3 {
  margin: 0;
  font-size: 15px;
}
/* Every card is the same size: name, effect, turns, one line each. */
.focus-card {
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  align-items: center;
  height: 76px;
  min-width: 0;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #f1ead6;
  font-size: 15px;
  line-height: 1;
  opacity: 0.55;
}
.focus-card > * {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.focus-card b {
  font-weight: 400;
}
.focus-card small {
  font-size: 13px;
  color: var(--soft);
}
.focus-card em {
  font-style: normal;
  font-size: 12px;
  color: var(--soft);
}
.focus-card.ready {
  opacity: 1;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
}
.focus-card.running {
  opacity: 1;
  background: var(--gold);
}
.focus-card.done {
  opacity: 1;
  background: #e6f6d8;
}

/* ── Result ────────────────────────────────────────────────────────────── */
.score {
  display: grid;
  margin: 0 0 8px;
}
.score small {
  color: var(--soft);
}
.score b {
  font-weight: 400;
  font-size: 44px;
  line-height: 1.1;
}
.score em {
  font-style: normal;
  color: var(--red-dark);
}
.rank small {
  color: var(--soft);
  font-size: 12px;
}
.rank li.gone {
  opacity: 0.45;
  text-decoration: line-through;
}
#specialties {
  justify-content: center;
  flex-wrap: wrap;
  margin: 0;
}

/* ── Hometown ──────────────────────────────────────────────────────────── */
.hometown {
  margin: 0;
  padding: 4px 14px 6px;
  border: var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 17px;
}
.link.light {
  margin: 0;
  color: #fff;
  text-shadow: 0 1px 2px #0006;
}
.dong-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 168px;
  overflow: auto;
  margin: 0 0 10px;
}
.dong-chip {
  padding: 4px 10px 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-size: 15px;
}
.dong-chip.on {
  background: var(--gold);
}
.dong.pickable {
  fill: #e9f6dc;
}
.dong.mine {
  stroke: #e0a91f;
  stroke-width: 3;
}
.village text.mine {
  font-weight: 700;
  fill: #8a5a00;
}
.mine-tag {
  font-size: 13px;
  color: #8a5a00;
}

/* ── Guides ─────────────────────────────────────────────────────────────── */
.tip {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff6c2;
  font-size: 14px;
  line-height: 1.4;
}
.tip::before {
  content: "💡";
  position: absolute;
  left: -10px;
  top: -12px;
  font-size: 18px;
}
.tip-ok {
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
}
.chip small {
  font-size: 12px;
  color: var(--soft);
  margin-right: 2px;
}
.tax-note {
  margin: 6px 0 0 51px;
  font-size: 13px;
  color: var(--soft);
}
.tax-note b {
  font-weight: 400;
  color: var(--red-dark);
}
.round.help {
  font-size: 24px;
  line-height: 1;
}
.help-dialog {
  text-align: left;
}
.help-body {
  max-height: 58dvh;
  overflow: auto;
  margin-bottom: 8px;
  padding-right: 4px;
}
.help-body section {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
}
.help-body h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 16px;
}
.help-body p,
.help-body ol {
  margin: 4px 0;
  font-size: 14px;
  line-height: 1.5;
  font-family: system-ui, "Malgun Gothic", sans-serif;
}
.help-body ol {
  padding-left: 20px;
}
.help-body b {
  font-weight: 700;
}
#resetTips {
  margin: 0 auto 10px;
  color: var(--soft);
}

/* ── Search ─────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 2px 0 8px;
  padding: 8px 12px;
  border: var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--soft);
  font-size: 16px;
  text-align: left;
}
.search-bar span {
  width: 24px;
  height: 24px;
}
.search-input {
  width: 100%;
  padding: 12px 14px;
  border: var(--line);
  border-radius: 14px;
  font: inherit;
  font-size: 18px;
  background: #fff;
}
.search-results {
  list-style: none;
  margin: 10px 0;
  padding: 0;
  max-height: 46dvh;
  overflow: auto;
  display: grid;
  gap: 6px;
  text-align: left;
}
.search-hit {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label tag" "sub tag";
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  text-align: left;
}
.search-hit b {
  grid-area: label;
  font-weight: 400;
  font-size: 17px;
}
.search-hit small {
  grid-area: sub;
  color: var(--soft);
  font-size: 13px;
}
.search-hit .tag {
  grid-area: tag;
  margin: 0;
}
.search-empty {
  padding: 12px;
  color: var(--soft);
  text-align: center;
}

/* ── 현황판 ─────────────────────────────────────────────────────────────── */
.board-body {
  max-height: 62dvh;
  overflow: auto;
  margin-bottom: 10px;
  text-align: left;
}
.board h3 {
  margin: 12px 0 6px;
  color: var(--ink);
}
.board h3 small {
  color: var(--soft);
  font-size: 12px;
}
.stand-bar {
  display: flex;
  height: 22px;
  border: var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--free);
}
.stand-bar span.o0 { background: var(--me); }
.stand-bar span.o1 { background: var(--r1); }
.stand-bar span.o2 { background: var(--r2); }
.stand-bar span.o3 { background: var(--r3); }
.stand-bar span.free { background: var(--free); }
.stand-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
  font-size: 13px;
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
}
.legend.o0 i { background: var(--me); }
.legend.o1 i { background: var(--r1); }
.legend.o2 i { background: var(--r2); }
.legend.o3 i { background: var(--r3); }
.legend.free i { background: var(--free); }
.realms {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  font-size: 15px;
}
.realms th {
  color: var(--soft);
  font-weight: 400;
  font-size: 12px;
  text-align: right;
}
.realms th:nth-child(2) {
  text-align: left;
}
.realms td {
  padding: 6px 6px;
  background: #ffffffcc;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.realms td:first-child {
  border-radius: 10px 0 0 10px;
  border-left: 8px solid var(--free);
  text-align: center;
}
.realms td:last-child {
  border-radius: 0 10px 10px 0;
}
.realms td:nth-child(2) {
  text-align: left;
}
.realms tr.o0 td:first-child { border-left-color: var(--me); }
.realms tr.o1 td:first-child { border-left-color: var(--r1); }
.realms tr.o2 td:first-child { border-left-color: var(--r2); }
.realms tr.o3 td:first-child { border-left-color: var(--r3); }
.realms tr.me td {
  background: #fff;
}
.realms tr.gone {
  opacity: 0.45;
}
.realm-name {
  display: block;
}
.realms small {
  font-size: 11px;
  color: var(--soft);
}
.realms small.war {
  color: var(--red-dark);
}
.my-stats {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
}

/* ── Readability: bigger text on the most used buttons ─────────────────── */
.builds.six .build b { font-size: 17px; }
.builds.six .build small { font-size: 12px; }
.builds.six .build .price { font-size: 15px; }
.price em { font-size: 12px; }
.chip { font-size: 17px; }
.seg { font-size: 18px; }
.focus-now { font-size: 17px; }
.hint { font-size: 15px; }
.board-body {
  overflow-x: hidden;
  padding-right: 6px;
}
.realms th,
.realms td {
  padding: 6px 5px;
}
.realms th:last-child,
.realms td:last-child {
  padding-right: 10px;
}
.board-body:focus,
.help-body:focus {
  outline: none;
}

/* ── Calmer map lines: no dashes; claimable land is a soft fill ────────── */
.district {
  stroke-width: 0.7;
}
.district.near {
  stroke: #fff;
  stroke-width: 0.7;
  stroke-dasharray: none;
  animation: none;
}
.district.free.near {
  fill: #fff3b0;
}
.district.near:not(.free) {
  filter: saturate(1.15);
}
.district.enemy {
  stroke: #c4433a;
  stroke-width: 1.1;
  stroke-dasharray: none;
}
/* Selection is the outline only: a thick gold line with a dark edge. */
/* (No filters on map paths: at map scale they blur into a big dark halo.) */
.district.selected {
  stroke: #fff;
  stroke-width: 1;
}
.sel-edge,
.sel-line {
  fill: none;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  pointer-events: none;
}
.sel-edge {
  stroke: #3b2a1a;
  stroke-width: 6.5;
}
.sel-line {
  stroke: #ffc21a;
  stroke-width: 3.5;
}
.dong.on,
.dong.pickable.on,
.dong.mine.on {
  stroke: #ffc21a;
  stroke-width: 4;
}
.troop circle {
  stroke-width: 1.2;
}

/* ── Difficulty ─────────────────────────────────────────────────────────── */
.diff-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.diff-card {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  text-align: left;
}
.diff-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
.diff-card b {
  font-weight: 400;
  font-size: 22px;
}
.diff-card small {
  font-size: 15px;
  color: var(--ink);
}
.diff-card em {
  font-style: normal;
  font-size: 13px;
  color: var(--soft);
}
.diff-card.last {
  background: var(--gold);
}

/* ── 고을 관리 ─────────────────────────────────────────────────────────── */
.manage-open {
  margin: 6px 0 2px;
  font-size: 17px;
  min-height: 44px;
  padding: 6px 12px 8px;
}
.manage-open .goeul-icon {
  width: 26px;
  height: 26px;
}
.manage-body {
  max-height: 62dvh;
  overflow: auto;
  overflow-x: hidden;
  padding-right: 4px;
  margin-bottom: 10px;
  text-align: left;
}
.manage-body:focus {
  outline: none;
}
.manage-box {
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 14px;
  background: #fff;
}
.manage-box h3,
.manage h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 17px;
}
.manage h3 small {
  color: var(--soft);
  font-size: 12px;
}
.manage-info {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--soft);
}
.realm-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
.realm-list li {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 12px;
  background: #ffffffcc;
  font-size: 15px;
}
.realm-list li.front {
  box-shadow: inset 4px 0 0 var(--red);
}
.rl-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rl-name i {
  width: 20px;
  height: 20px;
  flex: none;
}
.rl-name small {
  color: var(--soft);
}
.rl-stat {
  font-size: 13px;
  color: var(--soft);
  white-space: nowrap;
}
.rl-btn {
  padding: 4px 9px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
}
.rl-btn:disabled {
  opacity: 0.4;
}

/* ── Attack effects ────────────────────────────────────────────────────── */
.fx {
  pointer-events: none;
}
.fx .arrow {
  fill: none;
  stroke: #ff5a3c;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0.85;
  animation: shoot 0.65s cubic-bezier(0.5, 0, 0.7, 1) forwards;
}
@keyframes shoot {
  to {
    stroke-dashoffset: 0;
  }
}
.fx .arrow.edge {
  stroke: #3b2a1a;
  opacity: 0.9;
  filter: none;
}
.fx .burst {
  fill: #fff6c2;
  stroke: #ff5a3c;
  animation: burst 0.6s ease-out forwards;
}
@keyframes burst {
  to {
    r: var(--burst);
    opacity: 0;
  }
}
.fx .token text,
.fx .clash-label,
.fx .loss {
  font-family: "Jua", sans-serif;
  text-anchor: middle;
  paint-order: stroke fill;
}
.fx .token text {
  fill: #fff;
  stroke: #3b2a1a;
  stroke-width: 0.6px;
}
.fx .token.arrived {
  animation: token-out 0.4s ease-in forwards;
}
@keyframes token-out {
  to {
    opacity: 0;
  }
}
.fx .clash-label {
  fill: #fff;
  stroke: #3b2a1a;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  animation: clash-pop 1.3s ease-out forwards;
}
@keyframes clash-pop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  15% {
    transform: scale(1.25);
    opacity: 1;
  }
  30% {
    transform: scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(-30%);
    opacity: 0;
  }
}
.fx .loss {
  fill: #ff4d3d;
  stroke: #fff;
  stroke-linejoin: round;
  transform-box: fill-box;
  animation: loss-rise 1.3s ease-out forwards;
}
@keyframes loss-rise {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-160%);
    opacity: 0;
  }
}
.stage.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@media (prefers-reduced-motion: reduce) {
  .stage.shake,
  .fx .arrow,
  .fx .burst,
  .fx .clash-label,
  .fx .loss {
    animation: none;
  }
}

/* ── Unavailable buttons stay tappable and explain why ─────────────────── */
.btn.off,
.build.off,
.focus-card.off,
.rl-btn.off,
button.off {
  opacity: 0.45;
  filter: grayscale(0.7);
}
.btn.gather {
  margin-top: 6px;
  font-size: 16px;
  min-height: 42px;
}
.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 6px;
}
.row3 .btn {
  font-size: 17px;
  padding: 8px 6px 10px;
  min-height: 46px;
}
.row3 .btn .glyph,
.row3 .btn .goeul-icon {
  width: 22px;
  height: 22px;
}

/* ── Push-style notices ────────────────────────────────────────────────── */
.toast {
  display: none !important;
}
.notices {
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(8px + var(--top-safe, env(safe-area-inset-top)));
  z-index: 20;
  display: grid;
  gap: 5px;
  pointer-events: none;
  transition: top 0.2s;
}
.notice {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: #fffdf6f2;
  box-shadow: 0 4px 12px #0003;
  font-size: 15px;
  line-height: 1.3;
  pointer-events: auto;
  animation: notice-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.notice.good {
  background: #fff3c4;
}
.notice.bad {
  background: #ffe6e1;
}
.notice-icon {
  width: 24px;
  height: 24px;
}
.notice.leaving {
  animation: notice-out 0.4s ease-in forwards;
}
@keyframes notice-in {
  from {
    transform: translateY(-120%);
    opacity: 0;
  }
}
@keyframes notice-out {
  to {
    transform: translateY(-120%);
    opacity: 0;
  }
}

/* 법정동 and 리 inside the chosen 읍면동 */
.legal {
  flex-basis: 100%;
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.35;
  color: #7a6450;
}

/* ── HUD: turn ribbon with season progress, compact numbers ────────────── */
#week {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 4px 22px 7px 12px;
  line-height: 1.05;
  background:
    linear-gradient(90deg, var(--gold) var(--season, 0%), #ffffff33 var(--season, 0%)) left bottom / 100% 4px no-repeat,
    var(--ink);
}
#week b {
  font-weight: 400;
  font-size: 19px;
}
#week small {
  font-size: 11px;
  opacity: 0.8;
}
.res b small {
  font-size: 11px;
  color: var(--soft);
  margin-left: 1px;
}
.mine-chip {
  background: var(--gold);
  font-size: 14px;
}
.legal {
  margin: -2px 2px 6px;
}

/* ── Lots (부지) inside one 읍면동 ───────────────────────────────────────── */
.lot-info {
  margin: 0 2px 6px;
  font-size: 14px;
  color: var(--soft);
}
.lots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.lot {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 2px 5px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
  font: inherit;
}
.lot .ico {
  width: 30px;
  height: 30px;
}
.lot .plus {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-size: 24px;
  color: var(--soft);
}
.lot small {
  font-size: 13px;
}
.lot.empty {
  background: #f7f1e1;
  border-style: dashed;
}
.lot.on {
  border-color: #e0a20f;
  box-shadow: 0 0 0 3px #ffc21a, 0 3px 0 var(--ink);
}
.dong.built.full {
  fill: #a6d77f;
}
.ask-text {
  margin: 4px 4px 14px;
  font-size: 17px;
  line-height: 1.45;
}

/* Village names that would overlap are hidden (the chosen one always shows). */
.village text {
  display: none;
}
.village text.show,
.village text.on {
  display: block;
}

/* Panel titles never break a place name over two lines. */
.panel-head {
  flex-wrap: wrap;
  row-gap: 4px;
}
.panel .banner {
  white-space: nowrap;
  max-width: calc(100% - 64px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fold toggle on the strategy panel */
.fold {
  margin-left: auto;
  margin-top: 26px;
  padding: 3px 12px 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  box-shadow: 0 2px 0 var(--ink);
}

/* ── Text layout: Korean words never split; nothing spills out of boxes ── */
body,
button,
input,
dialog {
  word-break: keep-all;
  overflow-wrap: break-word;
}
p,
li,
.tip-text,
.hint,
.reason {
  text-wrap: pretty;
}
.tip-steps {
  margin: 4px 0 0;
  padding-left: 20px;
}
.tip-steps li {
  margin: 1px 0;
}
.tip-steps li::marker {
  font-weight: 700;
}

/* The home status chips (땅, 병력, 명령) stay on one row */
.panel .chips.status {
  flex-wrap: nowrap;
  gap: 5px;
}
.panel .chips.status .chip {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  padding: 3px 8px 3px 4px;
  font-size: 15px;
  white-space: nowrap;
}
.panel .chips.status .chip .glyph {
  width: 22px;
  height: 22px;
}

/* Short button labels never wrap */
.row2 .btn,
.row3 .btn,
.rl-btn,
.seg,
.fold,
.lot small {
  white-space: nowrap;
}
.row2 .btn {
  font-size: 16px;
}

/* 고을 관리 list: name on its own line, numbers and buttons below */
.realm-list li {
  grid-template-columns: auto auto 1fr auto;
  row-gap: 4px;
}
.realm-list .rl-name {
  grid-column: 1 / -1;
}
.realm-list li > :nth-child(4) {
  justify-self: end;
}

/* Narrow phones: build cards stack icon, name, effect and price */
@media (max-width: 400px) {
  .builds.six .build {
    grid-template-columns: 1fr;
    grid-template-areas: "ico" "name" "effect" "price";
    justify-items: center;
    text-align: center;
    padding: 5px 3px;
    row-gap: 1px;
  }
  .builds.six .build .ico {
    width: 28px;
    height: 28px;
  }
  .builds.six .build b {
    font-size: 15px;
  }
  .builds.six .build small {
    font-size: 11px;
    line-height: 1.2;
  }
  .builds.six .build .price {
    font-size: 13px;
  }
  .row3 .btn {
    font-size: 15px;
    padding-inline: 4px;
  }
}

/* Close buttons say what they do */
.close.labeled {
  width: auto;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
}
.diff-card {
  position: relative;
}
.diff-go {
  justify-self: end;
  margin-top: 4px;
  padding: 3px 10px 4px;
  border-radius: 999px;
  background: var(--green, #69c35a);
  color: #fff;
  font-size: 14px;
}
.diff-last {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gold);
  font-size: 12px;
  vertical-align: middle;
}

/* Turn ribbon and resources fit the narrowest phones */
#week small {
  white-space: nowrap;
}
.res {
  min-width: 0;
}
@media (max-width: 360px) {
  .hud {
    padding-inline: 6px;
  }
  .resources {
    gap: 3px;
    grid-template-columns: 1.15fr 1fr 1.25fr 0.9fr;
  }
  .res {
    height: 34px;
    margin-left: 8px;
    padding: 0 5px 0 22px;
    font-size: 14px;
  }
  .res-icon {
    left: -10px;
    width: 32px;
    height: 32px;
  }
  .res b small {
    font-size: 10px;
  }
  #week b {
    font-size: 17px;
  }
}
.chip .glyph {
  flex: none;
}

/* ── Beginner tutorial ─────────────────────────────────────────────────── */
.coach {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}
.coach[hidden],
.coach-hole[hidden] {
  display: none;
}
.coach-hole {
  position: fixed;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px #1b2a3499;
  outline: 3px solid #ffc21a;
  animation: coach-pulse 1.4s ease-in-out infinite;
  transition: left 0.25s, top 0.25s, width 0.25s, height 0.25s;
}
.coach:has(.coach-hole[hidden]) {
  background: #1b2a3499;
}
@keyframes coach-pulse {
  50% {
    outline-color: #fff3b0;
    outline-offset: 3px;
  }
}
.coach-card {
  position: fixed;
  left: 12px;
  right: 12px;
  max-width: 440px;
  margin: 0 auto;
  padding: 10px 14px 12px;
  border: var(--line);
  border-radius: 18px;
  background: #fffdf6;
  box-shadow: 0 6px 0 var(--ink), 0 10px 30px #0005;
  pointer-events: auto;
}
.coach-card.center {
  top: 50%;
  transform: translateY(-50%);
}
.coach-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.coach-step {
  font-size: 13px;
  color: var(--soft);
}
.coach-skip {
  padding: 3px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 13px;
}
.coach-text {
  margin: 2px 0 8px;
  font-size: 17px;
  line-height: 1.45;
}
.coach-next {
  width: 100%;
}
@media (prefers-reduced-motion: reduce) {
  .coach-hole {
    animation: none;
    transition: none;
  }
}

/* First-run play-log notice on the title screen */
.stats-notice {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(10px + var(--bottom-safe, env(safe-area-inset-bottom)));
  max-width: 440px;
  margin: 0 auto;
  padding: 10px 12px;
  border: var(--line);
  border-radius: 16px;
  background: #fffdf6f2;
  box-shadow: 0 4px 0 var(--ink);
  pointer-events: auto;
  font-size: 14px;
  line-height: 1.45;
}
.stats-notice p {
  margin: 0 0 8px;
}
.stats-notice .btn {
  font-size: 15px;
  min-height: 38px;
}
.stats-notice[hidden] {
  display: none;
}
.title-actions .small {
  font-size: 13px;
  opacity: 0.85;
}
.danger-text {
  color: var(--red-dark, #b3261e);
}
/* Unused orders shown under the 다음 턴 button */
#next[data-hint]:not([data-hint=""])::after {
  content: attr(data-hint);
  position: absolute;
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  padding: 1px 10px 2px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}
.title-screen.with-notice {
  padding-bottom: calc(150px + var(--bottom-safe, env(safe-area-inset-bottom)));
}

/* Short texts: even line lengths, no lone word on the last line */
.stats-notice p,
.coach-text,
.notice-text,
.event-title,
.ask-text,
.hint,
.reason,
.dialog-hint,
.tip-text,
.lot-info,
.legal,
.manage-info,
.diff-card small,
.score + *,
.report li,
.events li {
  text-wrap: balance;
}
.nowrap {
  white-space: nowrap;
}

/* 이어하기: where the saved game stands */
#continue {
  flex-direction: column;
  gap: 0;
  line-height: 1.15;
}
.continue-sub {
  font-size: 14px;
  opacity: 0.8;
}

/* Turn banner */
.turn-banner {
  position: absolute;
  left: 50%;
  top: 38%;
  z-index: 6;
  display: grid;
  justify-items: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: turn-pop 1.3s ease-out forwards;
}
.turn-banner b {
  font-weight: 400;
  font-size: 56px;
  line-height: 1;
  color: var(--gold);
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink), 0 10px 18px #0005;
}
.turn-banner small {
  margin-top: 6px;
  padding: 2px 12px 4px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-size: 16px;
}
@keyframes turn-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -62%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .turn-banner {
    animation-duration: 0.01s;
  }
}

/* Recommended building */
.build.rec {
  position: relative;
  box-shadow: 0 0 0 3px var(--gold), 0 3px 0 var(--ink);
}
.build.rec::before {
  content: "추천";
  position: absolute;
  top: -9px;
  right: 6px;
  padding: 0 7px 1px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--gold);
  font-size: 11px;
  line-height: 1.4;
}
/* The unused-orders hint sits inside the button, under its label */
#next[data-hint]:not([data-hint=""]) {
  padding-bottom: 20px;
}
#next[data-hint]:not([data-hint=""])::after {
  top: auto;
  bottom: 6px;
  padding: 0;
  background: none;
  color: var(--ink);
  opacity: 0.75;
  font-size: 13px;
}

/* Tutorial, lighter: no dimming while the player is doing something */
.coach:not(.dim) .coach-hole {
  box-shadow: 0 0 0 4px #fff8, 0 0 18px 6px #ffc21a99;
}
.coach:not(.dim):has(.coach-hole[hidden]) {
  background: none;
}
.coach.dim .coach-hole {
  box-shadow: 0 0 0 9999px #1b2a3477;
}

/* Title notice: one wide button, and a soft exit instead of a jump */
.stats-notice .row2.single {
  grid-template-columns: 1fr;
}
.title-screen {
  transition: padding-bottom 0.35s ease;
}
.stats-notice {
  transition: opacity 0.25s, transform 0.25s;
}
.stats-notice.leaving {
  opacity: 0;
  transform: translateY(12px);
}

/* Guide words that link: read as text, with a gold underline */
button.go {
  display: inline;
  margin: 0;
  padding: 0 1px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-decoration: underline 2px #e0a20f;
  text-underline-offset: 3px;
  cursor: pointer;
  min-height: 0;
  box-shadow: none;
}
button.go:active {
  background: #ffc21a55;
}
.flash {
  animation: flash-ring 1.2s ease-out;
}
@keyframes flash-ring {
  0%,
  60% {
    box-shadow: 0 0 0 4px #ffc21a, 0 0 18px 6px #ffc21a99;
  }
}

/* Map image dialog */
.mapshot-img {
  display: block;
  width: 100%;
  max-height: 58vh;
  aspect-ratio: 1080 / 1350;
  object-fit: contain;
  margin: 4px 0 12px;
  border: var(--line);
  border-radius: 16px;
  background: #8fd3f4;
}
.mapshot-dialog .row2 {
  margin-bottom: 8px;
}
/* Icons wrapped as elements (no HTML strings) keep their old size */
.chip .chip-glyph,
.price .coin {
  display: contents;
  font-style: normal;
}

/* No CSS filters on map shapes: on the scaled map they blur into a big dark
   circle. Hover and the capture flash use opacity instead. */
.district:hover,
.dong:hover,
.district.near:not(.free) {
  filter: none;
}
.district:hover,
.dong:hover {
  opacity: 0.88;
}
.district.pop {
  animation: pop-fade 0.7s ease-out;
}
@keyframes pop-fade {
  0% {
    opacity: 0.35;
  }
  100% {
    opacity: 1;
  }
}

/* The browser's focus ring on a scaled SVG shape turns into a big dark
   circle; map shapes show keyboard focus with a gold line instead. */
#map path:focus,
#map path:focus-visible {
  outline: none;
}
#map path:focus-visible {
  stroke: #ffc21a;
  stroke-width: 3;
}

/* ── Map play: a bubble beside the chosen land, round buttons below ───── */
.panel.pop {
  right: auto;
  bottom: auto;
  width: min(300px, calc(100vw - 20px));
  padding: 10px 12px 12px;
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  overflow: visible;
}
.panel.pop::before {
  content: "";
  position: absolute;
  left: calc(var(--tail, 50%) - 9px);
  top: -11px;
  width: 16px;
  height: 16px;
  background: var(--card);
  border-left: var(--line);
  border-top: var(--line);
  transform: rotate(45deg);
}
.panel.pop.above::before {
  top: auto;
  bottom: -11px;
  background: var(--card-2);
  border: 0;
  border-right: var(--line);
  border-bottom: var(--line);
}
.panel.pop.no-tail::before {
  display: none;
}
.panel.pop .panel-head {
  margin: 0 0 6px;
  gap: 6px;
  flex-wrap: wrap;
}
.panel.pop .banner {
  margin: 0;
  padding: 1px 10px 3px;
  font-size: 18px;
  box-shadow: 0 2px 0 var(--ink);
}
.panel.pop .tag {
  margin-top: 0;
  font-size: 13px;
}
.panel.pop .close.labeled {
  margin-left: auto;
  font-size: 13px;
}
.panel.pop .chips {
  gap: 4px;
  margin-bottom: 6px;
}
.panel.pop .chip,
.panel.pop .trait {
  font-size: 13px;
}
.panel.pop .btn {
  min-height: 44px;
  font-size: 17px;
}
.panel.pop .row3 .btn {
  font-size: 15px;
}
.panel.pop .battle {
  margin: 4px 0 8px;
}
.panel.pop .hint,
.panel.pop .reason,
.panel.pop .yield,
.panel.pop .tip {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
}
.panel.pop .tip {
  margin: 0 0 8px;
}

/* 다음 턴: a round button in the bottom right corner on the map */
body[data-mode="play"] #next.turn {
  left: auto;
  right: 14px;
  bottom: calc(14px + var(--bottom-safe, env(safe-area-inset-bottom)));
  width: 78px;
  height: 78px;
  min-height: 0;
  padding: 0 6px;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1.1;
  white-space: normal;
  word-break: keep-all;
}
body[data-mode="play"] #next[data-hint]:not([data-hint=""]) {
  padding-bottom: 0;
}
body[data-mode="play"] #next[data-hint]:not([data-hint=""])::after {
  top: -14px;
  bottom: auto;
  padding: 1px 8px 2px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  opacity: 1;
  font-size: 12px;
}

/* 고을: round button in the bottom left corner (방침, 세금, 군대, 마을) */
.realm-btn {
  position: absolute;
  left: 14px;
  bottom: calc(14px + var(--bottom-safe, env(safe-area-inset-bottom)));
  z-index: 3;
  width: 64px;
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: var(--line);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.realm-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
.realm-btn .realm-icon {
  width: 28px;
  height: 28px;
}
.realm-btn .realm-icon svg {
  width: 100%;
  height: 100%;
}
.realm-btn small {
  font-size: 13px;
  line-height: 1;
}
.policy-box .chips.status {
  margin-bottom: 8px;
}
body[data-mode="play"] #next.turn > span {
  display: none;
}
/* A lighter bubble: one line per fact, thin chips, compact numbers */
.panel.pop {
  width: min(272px, calc(100vw - 20px));
}
.panel.pop .chip,
.panel.pop .trait {
  padding: 1px 7px;
  border-width: 1.5px;
}
.panel.pop .battle span {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 2px 0;
  border-width: 1.5px;
  border-radius: 10px;
}
.panel.pop .battle b {
  font-size: 20px;
}
.panel.pop .battle .vs {
  font-size: 14px;
}
.panel.pop .close.labeled {
  padding: 2px 8px;
}

/* Opening motion: the bubble grows out of its tail */
.panel.pop.enter {
  animation: pop-in 0.24s cubic-bezier(0.2, 1.5, 0.4, 1);
  transform-origin: var(--tail, 50%) 0;
}
.panel.pop.above.enter {
  transform-origin: var(--tail, 50%) 100%;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.82) translateY(-4px);
  }
}
/* The picked land's outline lands with a bounce */
.sel-line {
  animation: sel-line 0.5s ease-out both;
}
.sel-edge {
  animation: sel-edge 0.5s ease-out both;
}
@keyframes sel-line {
  0% {
    stroke-width: 10;
    stroke-opacity: 0.2;
  }
  55% {
    stroke-width: 2.5;
  }
}
@keyframes sel-edge {
  0% {
    stroke-width: 14;
    stroke-opacity: 0;
  }
  55% {
    stroke-width: 5;
  }
}
/* The picked 읍면동 lights up the same way */
.dong.on {
  animation: dong-pick 0.45s ease-out;
}
@keyframes dong-pick {
  0% {
    stroke-width: 10;
    stroke-opacity: 0.3;
  }
}
/* The village bubble: small lot cards and a 3×2 grid of buildings */
.panel.pop .lot-info,
.panel.pop .legal {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--soft);
}
.panel.pop .lots {
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 6px;
}
.panel.pop .lot {
  padding: 3px 2px;
  border-width: 2px;
  border-radius: 10px;
  box-shadow: 0 2px 0 var(--ink);
}
.panel.pop .lot .ico,
.panel.pop .lot .plus {
  width: 22px;
  height: 22px;
  font-size: 18px;
}
.panel.pop .lot small {
  font-size: 11px;
}
.panel.pop .builds.six {
  margin-top: 6px;
  gap: 5px;
}
.panel.pop .builds.six .build {
  grid-template-columns: 1fr;
  grid-template-areas: "ico" "name" "effect" "price";
  justify-items: center;
  text-align: center;
  padding: 4px 2px;
  border-width: 2px;
  border-radius: 11px;
  box-shadow: 0 2px 0 var(--ink);
}
.panel.pop .builds.six .build small {
  font-size: 10.5px;
  line-height: 1.2;
}
.panel.pop .builds.six .build .ico {
  width: 26px;
  height: 26px;
}
.panel.pop .builds.six .build b {
  font-size: 14px;
}
.panel.pop .builds.six .build .price {
  font-size: 12px;
}
.realm-btn[data-view="true"] .realm-icon {
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
}
/* Close (✕) in the bubble: a small round button that never wraps the row */
.panel.pop .close.labeled.x {
  width: 32px;
  height: 32px;
  padding: 0;
  margin-left: auto;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  flex: none;
}
.panel.pop .panel-head {
  flex-wrap: nowrap;
}
.panel.pop .panel-head .chip,
.panel.pop .panel-head .tag {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
/* Village name label under the HUD */
.village-bar {
  position: absolute;
  left: 50%;
  top: calc(118px + var(--top-safe, env(safe-area-inset-top)));
  transform: translateX(-50%);
  z-index: 2;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 5px 14px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.village-bar {
  left: 12px;
  transform: none;
  max-width: calc(100% - 84px);
}
/* Bubble, trimmed: facts in one small line, odds in one line */
.panel.pop {
  width: min(256px, calc(100vw - 20px));
  padding: 8px 10px 10px;
}
.panel.pop .banner {
  font-size: 17px;
}
.panel.pop .facts,
.panel.pop .legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 2px;
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--soft);
  white-space: pre-wrap;
}
.facts-trait {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--ink);
}
.facts-trait svg {
  width: 15px;
  height: 15px;
}
.facts-war {
  color: var(--red-dark);
}
.panel.pop .odds {
  margin: 0 0 6px;
  font-size: 14px;
  text-align: center;
  white-space: pre-wrap;
}
.panel.pop .odds b {
  font-weight: 400;
  font-size: 19px;
}
.panel.pop .odds.win b:first-child {
  color: var(--green-dark);
}
.panel.pop .btn {
  min-height: 42px;
  font-size: 16px;
}
.panel.pop .row3 {
  gap: 5px;
}
.panel.pop .row3 .btn {
  font-size: 14px;
  padding-inline: 2px;
}
.panel.pop .builds.six .build .ico {
  width: 22px;
  height: 22px;
}
.panel.pop .builds.six .build {
  padding: 3px 2px;
}
/* 다음 턴 always on one line */
body[data-mode="play"] #next.turn {
  white-space: nowrap;
  font-size: 16px;
  padding: 0;
}
.panel.pop .btn + .facts,
.panel.pop .btn + .reason,
.panel.pop .row3 + .hint {
  margin: 9px 0 0;
}
.panel.pop .panel-head .banner {
  flex: none;
  max-width: 62%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Bubble head: no spare space above or below the name row */
.panel.pop {
  padding-top: 7px;
}
.panel.pop .panel-head {
  align-items: center;
  min-height: 0;
  margin: 0 0 5px;
}
.panel.pop .panel-head .banner {
  padding: 0 9px 2px;
  line-height: 1.35;
  box-shadow: 0 2px 0 var(--ink);
}
.panel.pop .panel-head .tag,
.panel.pop .panel-head .chip {
  padding: 1px 8px;
  line-height: 1.35;
}
.panel.pop .close.labeled.x {
  width: 28px;
  height: 28px;
  box-shadow: 0 2px 0 var(--ink);
}
.panel.pop .panel-head .close,
.panel.pop .panel-head .banner {
  margin-top: 0;
  margin-bottom: 0;
}

/* Realms that rise later */
.o4 { fill: var(--r4); }
.o5 { fill: var(--r5); }
.o6 { fill: var(--r6); }
.capital.o4 { fill: var(--r4); }
.capital.o5 { fill: var(--r5); }
.capital.o6 { fill: var(--r6); }
.tag.o4, .tag.o5, .tag.o6 { color: #fff; text-shadow: 0 1px 0 #0004; }
.tag.o4 { background: var(--r4); }
.tag.o5 { background: var(--r5); }
.tag.o6 { background: var(--r6); }
.rank li.o4 { border-color: var(--r4); }
.rank li.o5 { border-color: var(--r5); }
.rank li.o6 { border-color: var(--r6); }
.troop.o4 circle, .troop.o5 circle, .troop.o6 circle { fill: #ffe1dc; }
.stand-bar span.o4 { background: var(--r4); }
.stand-bar span.o5 { background: var(--r5); }
.stand-bar span.o6 { background: var(--r6); }
.legend.o4 i { background: var(--r4); }
.legend.o5 i { background: var(--r5); }
.legend.o6 i { background: var(--r6); }
.realms tr.o4 td:first-child { border-left-color: var(--r4); }
.realms tr.o5 td:first-child { border-left-color: var(--r5); }
.realms tr.o6 td:first-child { border-left-color: var(--r6); }

/* War fronts: stripes over the land, and over front 읍면동 in a village */
.war-front {
  fill: url(#hatch);
  stroke: #c4433a;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.dong.war-front {
  fill: url(#hatch);
  pointer-events: auto;
}

/* Bubble: where this place is */
.panel.pop .region {
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink);
}
.panel.pop .region b {
  font-weight: 400;
  padding: 0 6px 1px;
  margin-right: 2px;
  border-radius: 6px;
  background: var(--gold);
}
.panel.pop .region-text {
  display: block;
  color: var(--soft);
}
/* Diplomacy in the bubble */
.panel.pop .diplo {
  margin: 0 0 8px;
}
.panel.pop .diplo .rel {
  margin: 0 0 5px;
  font-size: 13px;
}
.rel.good,
.dl-rel.good {
  color: var(--green-dark);
}
.rel.bad,
.dl-rel.bad {
  color: var(--red-dark);
}
.panel.pop .diplo .btn {
  min-height: 36px;
  font-size: 14px;
}
/* Levels on lot cards and the upgrade button */
.lot {
  position: relative;
}
.lot .lv {
  position: absolute;
  top: -7px;
  right: -5px;
  padding: 0 5px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--gold);
  font-size: 10.5px;
  font-style: normal;
  line-height: 1.4;
}
.panel.pop .btn.up {
  min-height: 38px;
  font-size: 14px;
  margin: 2px 0 4px;
}
/* 자동 관리 switch */
.auto-toggle {
  display: grid;
  gap: 2px;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  font: inherit;
  color: var(--ink);
}
.auto-toggle b {
  font-weight: 400;
  font-size: 16px;
}
.auto-toggle b::before {
  content: "○ ";
}
.auto-toggle.on {
  background: #e6f6d8;
  border-color: var(--green-dark);
}
.auto-toggle.on b::before {
  content: "● ";
  color: var(--green-dark);
}
.auto-toggle small {
  font-size: 12px;
  color: var(--soft);
}
/* Diplomacy list in 고을 관리 */
.diplo-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.diplo-list li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-left: 5px solid var(--soft);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
}
.diplo-list li.o1 { border-left-color: var(--r1); }
.diplo-list li.o2 { border-left-color: var(--r2); }
.diplo-list li.o3 { border-left-color: var(--r3); }
.diplo-list li.o4 { border-left-color: var(--r4); }
.diplo-list li.o5 { border-left-color: var(--r5); }
.diplo-list li.o6 { border-left-color: var(--r6); }
.dl-name small {
  color: var(--soft);
  font-size: 11px;
}
.dl-rel {
  font-size: 12.5px;
  white-space: nowrap;
}
#reportEvents li.news {
  background: #e6f1fb;
}
/* The building already on the lot: level badge, tap to level up */
.build {
  position: relative;
}
.build.current {
  border-color: var(--gold-dark);
  background: #fff6d6;
}
.build .lv {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 6px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: 11px;
  font-style: normal;
  line-height: 1.45;
  white-space: nowrap;
}
.panel.pop .builds.six {
  margin-top: 10px;
}

/* 🔔 inbox: under the turn ribbon, with an unread count */
.inbox-btn {
  position: absolute;
  left: 10px;
  top: calc(124px + var(--top-safe, env(safe-area-inset-top)));
  z-index: 2;
  font-size: 20px;
}
.inbox-btn[data-count]:not([data-count=""])::after {
  content: attr(data-count);
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  padding: 0 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
}
body[data-view="village"] .inbox-btn {
  top: calc(164px + var(--top-safe, env(safe-area-inset-top)));
}
.inbox-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 58vh;
  overflow-y: auto;
  display: grid;
  gap: 6px;
}
.inbox-list li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: start;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  line-height: 1.4;
}
.inbox-list li.bad {
  background: #fdecea;
}
.inbox-list li.good {
  background: #eaf6e1;
}
.inbox-list li.empty {
  display: block;
  text-align: center;
  color: var(--soft);
}
.inbox-list .notice-icon svg {
  width: 20px;
  height: 20px;
}
.inbox-list small {
  color: var(--soft);
  font-size: 11px;
  white-space: nowrap;
}

/* 추천: one line between the round buttons */
.advice-chip {
  position: absolute;
  left: 88px;
  right: 104px;
  bottom: calc(26px + var(--bottom-safe, env(safe-area-inset-bottom)));
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--ink);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.3;
  text-align: left;
  animation: pop-in 0.24s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.advice-chip b {
  flex: none;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--gold);
  font-weight: 400;
  font-size: 11.5px;
}
.advice-chip span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.advice-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.advice-item {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--ink);
}
.advice-item::after {
  content: " ›";
  color: var(--soft);
}
.unrest-tag {
  background: #fdecea !important;
  color: var(--red-dark) !important;
}

/* Sieges: occupied 읍면동 and besieged districts */
.dong.occupied {
  fill: #9a8f86;
  opacity: 0.85;
}
.sieged {
  fill: none;
  stroke: #3b2a1a;
  stroke-width: 2.4;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.build .lv {
  left: 0;
  right: 0;
  width: fit-content;
  margin: 0 auto;
  transform: none;
}
.inbox-btn {
  font-size: 18px;
}

/* 방침 도감 */
#focus .focus-grid {
  display: block;
  max-height: 64vh;
  overflow-y: auto;
}
.codex-routes {
  margin-bottom: 10px;
}
.route-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.route-card {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  text-align: left;
}
.route-card b {
  font-weight: 400;
  font-size: 15px;
}
.route-card small {
  font-size: 11.5px;
  color: var(--soft);
  line-height: 1.3;
}
.route-card:disabled {
  opacity: 0.55;
}
.route-now {
  display: grid;
  gap: 2px;
  padding: 7px 10px;
  border: 2px solid var(--green-dark);
  border-radius: 12px;
  background: #e6f6d8;
}
.route-now b {
  font-weight: 400;
}
.route-now small {
  font-size: 12px;
  color: var(--soft);
}
.focus-grid-inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.focus-grid-inner.cols4 {
  grid-template-columns: repeat(2, 1fr);
}
.focus-card .stars {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 1px;
  color: #e0a20f;
}
.focus-card small.next {
  color: var(--green-dark);
}
#focus .focus-path {
  grid-template-rows: auto;
  grid-auto-rows: minmax(76px, auto);
}
#focus .focus-card {
  height: auto;
}

/* 살림 box */
.money-box {
  margin: 8px 0;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
}
.money-box h4 {
  margin: 0 0 4px;
  font-weight: 400;
  font-size: 15px;
}
.money-box ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
}
.money-box li {
  display: flex;
  justify-content: space-between;
}
.money-box li b {
  font-weight: 400;
  color: var(--green-dark);
}
.money-box li.out b {
  color: var(--red-dark);
}
.money-box .manage-info {
  margin: 6px 0 0;
}
.res-coin b {
  font-variant-numeric: tabular-nums;
}
.panel.pop .link.disband {
  display: block;
  margin: 6px auto 0;
  font-size: 13px;
}

/* 고을 관리 tabs */
#manage .tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0 0 10px;
}
#manage .tabs button {
  padding: 7px 0;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
#manage .tabs button[aria-selected="true"] {
  background: var(--gold);
  box-shadow: 0 3px 0 var(--ink);
}
#manage .manage-body[hidden] {
  display: none;
}
#manage #codexBox .focus-grid-inner {
  margin-bottom: 4px;
}
.diplo-list li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 8px 10px;
}
.dl-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}
.dl-head b {
  font-weight: 400;
  font-size: 15px;
}
.dl-head .dl-rel {
  margin-left: auto;
}
.diplo-list .row3 .btn {
  min-height: 36px;
  font-size: 14px;
  padding-inline: 2px;
}
#codexBox .focus-grid-inner {
  align-items: start;
}
#codexBox .focus-path {
  align-content: start;
}

.panel.pop .seat-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 6px;
  font-size: 13px;
}
.panel.pop .seat-row .link {
  font-size: 13px;
}
.seat-tag {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--gold);
}

/* Section marks and the realm's path */
h3.marked {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mark {
  font-size: 15px;
  line-height: 1;
}
.route-banner {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
  width: 100%;
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 2px solid var(--green-dark);
  border-radius: 12px;
  background: #e6f6d8;
  font: inherit;
  color: var(--ink);
  text-align: left;
}
.route-banner .mark {
  grid-row: span 2;
  font-size: 22px;
}
.route-banner b {
  font-weight: 400;
  font-size: 15px;
}
.route-banner small {
  font-size: 12px;
  color: var(--soft);
}
.route-banner.empty {
  border-color: var(--gold-dark);
  background: #fff6d6;
}
.bank-box {
  margin: 8px 0;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
}
.bank-box h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.bank-box .manage-info {
  margin: 0 0 6px;
}
.bank-box .btn {
  min-height: 38px;
  font-size: 14px;
}
/* Centred cards and headings in the codex */
#codexBox .focus-path h3 {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  text-align: center;
}
#codexBox .focus-card {
  justify-items: center;
  text-align: center;
}
.route-card {
  justify-items: center;
  text-align: center;
}
.path-경제 .focus-card { border-top: 4px solid #e0a20f; }
.path-군사 .focus-card { border-top: 4px solid #c4433a; }
.path-행정 .focus-card { border-top: 4px solid #4f9cf0; }
.path-루트 .focus-card { border-top: 4px solid var(--green-dark); }
#codexBox .focus-card small {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
  font-size: 11px;
}

.top-box .route-banner {
  margin-bottom: 8px;
}
.top-box .auto-toggle {
  margin-top: 0;
}

#disbandSurplus { margin-top: 6px; min-height: 38px; font-size: 14px; }
.panel.pop .link.disband { display: inline-block; margin: 6px 8px 0; }
