:root {
  --ink: #3c2918;
  --paper: #f7f0e4;
  --gold: #e7b15a;
  --sage: #6e8b63;
  --hp: #d15a48;
  --mp: #4d7eaa;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% -10%, #6a5138 0%, transparent 46%),
    #1a120c;
  color: var(--paper);
  font-family: "IBM Plex Sans KR", sans-serif;
}

button, input { font: inherit; color: inherit; }

.bar {
  width: min(1100px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 16px 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: #d9c3a2;
}

h1 {
  margin: 2px 0 0;
  font-family: "Gowun Batang", serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

h1 span {
  margin-left: 8px;
  font-family: "IBM Plex Sans KR", sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: #c9b497;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

nav button {
  border: 1px solid rgba(247, 232, 206, 0.28);
  background: rgba(255, 244, 224, 0.06);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}

nav button[aria-pressed="true"] {
  background: #f3e2c4;
  color: var(--ink);
  border-color: transparent;
}

.stage {
  position: relative;
  width: min(1100px, calc(100vw - 28px), calc((100vh - 96px) * 16 / 9));
  aspect-ratio: 16 / 9;
  margin: 12px auto 28px;
  border-radius: 18px;
  overflow: hidden;
  background: #2a1c12;
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 232, 196, 0.2);
}

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.place {
  position: absolute;
  top: 16px;
  left: 16px;
  margin: 0;
  padding: 6px 12px 7px;
  border-radius: 999px;
  background: rgba(42, 26, 14, 0.72);
  color: #f6e7cf;
  font-size: 13px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(6px);
}

.cast { position: absolute; inset: 0; pointer-events: none; }

.actor {
  position: absolute;
  bottom: 17%;
  width: 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.actor.haru { left: 4%; }
.actor.moka { left: 25%; }
.actor.riko { left: 10%; }
.actor.slime { right: 5%; width: 18%; bottom: 22%; }
.actor.solo { right: 8%; }

.actor img.sprite {
  width: 100%;
  display: block;
  filter: drop-shadow(0 12px 8px rgba(40, 20, 8, 0.28));
}

.plate {
  width: min(148px, 90%);
  margin-bottom: -6px;
  text-align: center;
  z-index: 1;
}

.plate b {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 8px 3px;
  border-radius: 999px;
  background: rgba(42, 26, 14, 0.78);
  color: #fff6e8;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.meter {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: rgba(28, 16, 10, 0.35);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

.meter b {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(#f0a090, var(--hp));
}

.meter.mp b { background: linear-gradient(#9ec4e4, var(--mp)); }
.meter.slim { height: 7px; }

.actor.hit .sprite { animation: shake 0.35s ease; }

@keyframes shake {
  0% { transform: translateX(0); filter: brightness(1.8) drop-shadow(0 16px 10px rgba(40, 20, 8, 0.28)); }
  40% { transform: translateX(10px); }
  100% { transform: translateX(0); }
}

.fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; }

.popup {
  position: absolute;
  top: 8%;
  left: 50%;
  font-family: "Black Han Sans", sans-serif;
  font-style: normal;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  color: #fff6d0;
  text-shadow:
    0 3px 0 #8d3b16,
    0 0 16px rgba(255, 176, 72, 0.9);
  animation: rise 0.9s ease forwards;
  white-space: nowrap;
}

.popup.ally {
  color: #ffe4e0;
  text-shadow:
    0 3px 0 #8a2430,
    0 0 14px rgba(255, 120, 100, 0.85);
}

.banner {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  padding: 4px 22px 8px;
  font-family: "Black Han Sans", sans-serif;
  font-size: clamp(32px, 5vw, 58px);
  letter-spacing: 0.08em;
  color: #fffaf0;
  background: linear-gradient(90deg, transparent, rgba(92, 48, 18, 0.55), transparent);
  text-shadow:
    0 3px 0 #6a3412,
    0 0 18px rgba(255, 196, 92, 0.85);
  animation: banner 0.85s ease forwards;
}

.banner.sage {
  text-shadow:
    0 3px 0 #2d4a32,
    0 0 18px rgba(168, 214, 150, 0.8);
}

@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.86); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -36px) scale(1.04); }
}

@keyframes banner {
  0% { opacity: 0; letter-spacing: 0.2em; }
  20% { opacity: 1; letter-spacing: 0.08em; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

.dialogue {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 4;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: stretch;
  min-height: 28%;
  padding: 12px 16px 14px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 248, 236, 0.94), rgba(243, 226, 196, 0.94));
  color: var(--ink);
  box-shadow:
    0 10px 30px rgba(40, 18, 8, 0.28),
    inset 0 0 0 1px rgba(120, 72, 28, 0.18);
  cursor: pointer;
}

.face {
  width: clamp(72px, 10vw, 104px);
  height: clamp(72px, 10vw, 104px);
  object-fit: cover;
  object-position: center center;
  border-radius: 14px;
  align-self: center;
  background: #f4ead8;
  box-shadow: inset 0 0 0 1px rgba(90, 54, 24, 0.18);
}

.lines { min-width: 0; display: flex; flex-direction: column; }

.who {
  margin: 0;
  font-family: "Gowun Batang", serif;
  font-size: 18px;
}

.say {
  margin: 4px 0 0;
  font-size: clamp(15px, 1.7vw, 18px);
  line-height: 1.55;
  min-height: 1.55em;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.choices button,
.sheet-close {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #3f2a1b;
  color: #f8efe2;
  cursor: pointer;
}

.choices button.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(63, 42, 27, 0.35);
}

.choices button:disabled {
  opacity: 0.4;
  cursor: default;
}

.cue {
  margin-left: auto;
  color: #8a6844;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.status {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
}

.status[hidden] { display: none; }

.status-dim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(22, 12, 6, 0.46);
  cursor: pointer;
}

.sheet {
  position: relative;
  width: min(640px, 86%);
  aspect-ratio: 4 / 3;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.4));
}

.sheet > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.sheet-body {
  position: absolute;
  inset: 13% 12% 12% 13%;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sheet-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #8d6844;
}

.sheet-body h2 {
  margin: 0;
  font-family: "Gowun Batang", serif;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: 0.06em;
}

.job {
  margin: 0 0 8px;
  color: #7a5a3a;
  font-size: 13px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
}

.sheet-face {
  width: clamp(72px, 12vw, 104px);
  height: clamp(92px, 15vw, 128px);
  object-fit: cover;
  object-position: center 12%;
  border-radius: 12px;
  background: #f6ecda;
  box-shadow: inset 0 0 0 1px rgba(90, 54, 24, 0.16);
}

.meter-row {
  display: grid;
  grid-template-columns: 2em 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.meter-row em { font-style: normal; font-variant-numeric: tabular-nums; }

.stats {
  display: flex;
  gap: 14px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.stats li {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.stats span { color: #8a6240; font-size: 12px; }
.stats b {
  font-family: "Gowun Batang", serif;
  font-size: 20px;
}

.kit {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 0;
}

.kit div {
  padding: 6px 8px 7px;
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.45);
}

.kit dt {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #8a6240;
}

.kit dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-size: 14px;
}

.ally {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 600;
}

.ally img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  object-position: center 15%;
  border-radius: 50%;
}

.sheet-close {
  align-self: flex-end;
  margin-top: auto;
}

@media (max-width: 720px) {
  .bar { align-items: flex-start; flex-direction: column; }
  nav { justify-content: flex-start; }
  .stage {
    width: calc(100vw - 16px);
    aspect-ratio: auto;
    height: calc(100vh - 132px);
    min-height: 520px;
    margin-inline: auto;
  }
  .actor { width: 34%; }
  .actor.haru { left: 2%; }
  .actor.moka { left: 32%; width: 34%; }
  .actor.riko, .actor.solo { width: 40%; }
  .actor.slime { width: 28%; }
  .dialogue { grid-template-columns: 64px 1fr; min-height: 34%; }
  .kit { grid-template-columns: 1fr; }
  .sheet { width: 94%; }
}
