/*
 * theme.css — 색·글꼴·버튼·창 같은 공통 모양 (밝은 양피지 테마)
 *
 * 색을 바꾸고 싶으면 아래 :root 의 값만 고치면 게임 전체에 반영돼요.
 * "픽셀 테두리"는 그림 파일 없이 그림자(box-shadow)로 그려서, 모서리가 계단처럼 깎인 모양이 됩니다.
 */

:root {
  /* 바탕 */
  --bg: #e9dabb;
  --bg-dot: rgba(122, 86, 48, 0.1);
  /* 양피지 (밝음 → 어두움) */
  --paper: #f8f0dd;
  --paper-2: #efe2c4;
  --paper-3: #e3d0a8;
  --paper-edge: #cdb283;
  /* 잉크 (글자·외곽선) */
  --ink: #3a2718;
  --ink-2: #5e4630;
  --ink-soft: #8a7258;
  /* 나무·가죽 */
  --wood: #8b5a34;
  --wood-dark: #5c3920;
  --wood-light: #b98552;
  /* 강조색 */
  --red: #a63d2c;
  --red-dark: #74281c;
  --red-light: #c4553d;
  --green: #4e7c45;
  --green-soft: #e1ebcc;
  --gold: #c99a3c;
  --gold-soft: #f5e3a6;
  --blue: #3d6a86;
  --purple: #6e4a8e;
  /* 픽셀 테두리 두께 */
  --px: 3px;
  /* 글꼴 */
  --font-body: 'Gowun Batang', 'Batang', serif;
  --font-title: 'Song Myung', 'Gowun Batang', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 40%, transparent 55%, rgba(120, 82, 44, 0.16) 100%),
    radial-gradient(var(--bg-dot) 1px, transparent 1.5px);
  background-size: 100% 100%, 7px 7px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
}
button, input { font-family: inherit; font-size: inherit; color: inherit; }
#app { height: 100%; }

/* 스크롤 막대 */
* { scrollbar-width: thin; scrollbar-color: var(--wood-light) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--wood-light); border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ───────── 픽셀 테두리 (여러 부품이 같이 씀) ─────────
 * --face: 면 색, --line: 테두리 색, --hi/--lo: 위쪽 밝은 줄 / 아래쪽 어두운 줄 */
.btn, .panel, .modal, .tooltip, .hud-chip, .toast, .px-box {
  --face: var(--paper);
  --line: var(--ink);
  --hi: rgba(255, 252, 240, 0.75);
  --lo: rgba(94, 70, 48, 0.22);
  --outline:
    0 calc(-1 * var(--px)) 0 0 var(--line),
    0 var(--px) 0 0 var(--line),
    calc(-1 * var(--px)) 0 0 0 var(--line),
    var(--px) 0 0 0 var(--line);
  --bevel: inset 0 var(--px) 0 0 var(--hi), inset 0 calc(-1 * var(--px)) 0 0 var(--lo);
  --drop: 0 calc(2 * var(--px)) 0 0 rgba(58, 39, 24, 0.18);
  background-color: var(--face);
  box-shadow: var(--bevel), var(--outline), var(--drop);
}

/* ───────── 버튼 ───────── */
.btn {
  --face: var(--paper-2);
  position: relative;
  margin: var(--px);
  padding: 6px 14px;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.4;
  transition: background-color 0.1s;
}
.btn:hover:not(:disabled) { --face: #fbf5e6; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: var(--bevel), var(--outline); }
.btn:focus-visible { outline: 2px dashed var(--red); outline-offset: 5px; }
.btn:disabled { cursor: default; opacity: 0.5; }
.btn-primary {
  --face: var(--red);
  --line: var(--red-dark);
  --hi: rgba(255, 214, 180, 0.4);
  --lo: rgba(60, 14, 8, 0.35);
  color: #fff4e2;
  text-shadow: 0 1px 0 rgba(60, 14, 8, 0.5);
}
.btn-primary:hover:not(:disabled) { --face: var(--red-light); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(139, 90, 52, 0.12); }
.btn-ghost:active:not(:disabled) { box-shadow: none; }
.btn-test { --face: var(--gold-soft); --line: #8a6a22; }
.btn-large { padding: 10px 28px; font-size: 18px; }
.btn-small { padding: 3px 10px; font-size: 13px; }

/* ───────── 판(패널) ───────── */
.panel {
  --line: var(--wood-dark);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: var(--px);
  padding: 14px 16px 12px;
}
/* 안쪽 장식선 + 네 모서리 금속 징 */
.panel::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 2px solid rgba(139, 90, 52, 0.22);
  pointer-events: none;
}
.panel::after {
  content: '';
  position: absolute;
  inset: 2px;
  pointer-events: none;
  background:
    linear-gradient(var(--gold), var(--gold)) left top / 6px 6px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right top / 6px 6px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left bottom / 6px 6px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right bottom / 6px 6px no-repeat;
}
.panel > * { position: relative; z-index: 1; }

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: 21px;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
}
.panel-title::before,
.panel-title::after {
  content: '';
  flex: 1;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--wood-light));
}
.panel-title::after { background: linear-gradient(270deg, transparent, var(--wood-light)); }
.panel-hint { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-soft); text-align: center; }

/* 리본 (공방 이름, 책 제목 등) */
.ribbon {
  display: inline-block;
  padding: 5px 30px 6px;
  background: var(--red);
  color: #fff4e2;
  font-family: var(--font-title);
  font-size: 21px;
  line-height: 1.3;
  white-space: nowrap;
  text-shadow: 0 2px 0 var(--red-dark);
  box-shadow: inset 0 3px 0 rgba(255, 220, 190, 0.28), inset 0 -3px 0 rgba(60, 14, 8, 0.35);
  clip-path: polygon(0 0, 100% 0, calc(100% - 13px) 50%, 100% 100%, 0 100%, 13px 50%);
}

/* ───────── 떠 있는 창 ───────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(92, 64, 36, 0.32);
  animation: fade-in 0.15s ease-out;
}
.modal {
  --line: var(--wood-dark);
  width: min(460px, 100%);
  padding: 24px 28px 20px;
  animation: pop-in 0.18s ease-out;
}
.modal-title {
  margin: 0 0 12px;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: 24px;
  color: var(--red-dark);
  text-align: center;
}
.modal-message { white-space: pre-line; margin: 0 0 6px; }
.modal-hint { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.name-input {
  width: 100%;
  margin-top: 8px;
  padding: 9px 12px;
  border: 0;
  background: #fffaf0;
  box-shadow: inset 0 0 0 var(--px) var(--ink), inset 0 6px 0 rgba(94, 70, 48, 0.12);
  font-size: 18px;
  outline: none;
}
.name-input:focus { box-shadow: inset 0 0 0 var(--px) var(--red), inset 0 6px 0 rgba(94, 70, 48, 0.12); }

/* ───────── 잠깐 뜨는 알림 ───────── */
.toast-stack {
  position: fixed;
  top: 70px;
  left: 50%;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  --face: var(--paper);
  --line: var(--wood-dark);
  padding: 9px 22px;
  font-size: 16px;
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.is-discover { --face: var(--gold-soft); --line: #8a6a22; font-family: var(--font-title); font-size: 19px; }
.toast.is-warn { --face: #f7dccf; --line: var(--red-dark); }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); }

/* ───────── 테스트 표시 / 오류 화면 ───────── */
.test-badge {
  position: fixed;
  left: 14px;
  bottom: 12px;
  z-index: 50;
  padding: 4px 12px;
  background: var(--gold-soft);
  box-shadow: 0 0 0 2px #8a6a22;
  color: #5a4210;
  font-size: 13px;
}
.error-screen {
  max-width: 560px;
  margin: 12vh auto 0;
  padding: 28px;
  background: var(--paper);
  box-shadow: 0 0 0 var(--px) var(--red-dark);
  white-space: pre-line;
}
.error-screen h1 { margin-top: 0; font-family: var(--font-title); font-weight: 400; color: var(--red-dark); }
.error-hint { color: var(--ink-soft); font-size: 14px; }

/* ───────── 움직임 ───────── */
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

/* '움직임 줄이기' 설정을 켠 사람을 위해 크게 흔들리거나 흘러가는 효과만 멈춰요 (cauldron.css, title.css 참고) */
