/* ============================================================
 * 요새 지키기 - 스타일
 * 1280x720 고정 해상도를 화면에 맞게 스케일 (가로 모바일 기준)
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  background: #2a3324;
  overflow: hidden;
  font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: fixed; inset: 0; }
#scaler {
  position: absolute;
  left: 50%; top: 50%;
  width: 1280px; height: 720px;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.screen { position: absolute; inset: 0; }
.hidden { display: none !important; }

/* ================= 로비 ================= */
#lobby {
  background: linear-gradient(170deg, #f7edd8 0%, #ecdcbc 55%, #dfcba4 100%);
  display: flex; flex-direction: column;
}
#lobbyTop {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px 6px;
}
.gameTitle { font-size: 30px; font-weight: 800; color: #5a4326; text-shadow: 0 2px 0 rgba(255,255,255,0.5); }
.resBox { display: flex; gap: 14px; font-size: 20px; font-weight: 700; color: #5a4326; }
.resBox span {
  background: rgba(255,255,255,0.65);
  border: 2px solid #c9b088;
  border-radius: 14px;
  padding: 6px 16px;
}

#lobbyMain { flex: 1; display: flex; min-height: 0; padding: 8px 20px 18px; gap: 18px; }
#charStage {
  width: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 65%, #fff8e8 0%, rgba(255,248,232,0) 70%);
}
#charCanvas { }
#charCaption { font-size: 19px; color: #5a4326; margin-top: 4px; text-align: center; }
#charCaption b { color: #8a5f1e; }

#panelWrap {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: rgba(255,252,244,0.8);
  border: 3px solid #c9b088;
  border-radius: 20px;
  overflow: hidden;
}
#tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 10px 4px;
  background: rgba(201,176,136,0.25);
}
.tab {
  border: 2px solid #c9b088; background: #f3e8d2; color: #6b5433;
  border-radius: 12px; padding: 7px 13px; font-size: 16px; font-weight: 700;
  cursor: pointer;
}
.tab.on { background: #7fae69; border-color: #5c8a46; color: #fff; }

#panel { flex: 1; overflow-y: auto; padding: 12px 16px 20px; }
#panel h3 { color: #6b5433; font-size: 19px; margin: 10px 0 8px; }
#panel .hint { color: #90815f; font-size: 14px; margin-top: 8px; }

.card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fffdf7;
  border: 2px solid #ddcba6;
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 17px; color: #54432a;
}
.card.locked { opacity: 0.75; }
.card.equipped { border-color: #5c8a46; box-shadow: 0 0 0 2px rgba(92,138,70,0.25); }
.card.resume { border-color: #4a90c2; background: #f0f8ff; }
.card.danger { border-color: #d89090; }
.card .sub, .sub { font-size: 14px; color: #8d7b58; }
.card .sub.need { color: #c05050; }
.card .lv { font-size: 14px; color: #4a90c2; font-weight: 700; }
.card .arrow { color: #4a9c47; font-weight: 700; }
.winfo { flex: 1; min-width: 0; }
.winfo .sub { display: block; margin-top: 2px; }
.wact { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 46%; }

.btn {
  border: 2px solid #b09a6e; background: #f3e8d2; color: #54432a;
  border-radius: 12px; padding: 8px 14px; font-size: 16px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: #7fae69; border-color: #5c8a46; color: #fff; }
.btn.danger { background: #d96a5a; border-color: #b14a3c; color: #fff; }
.btn.buy { background: #e9c468; border-color: #c49a2e; }
.btn.on { background: #5c8a46; border-color: #46703a; color: #fff; }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn.big { display: block; width: 240px; margin: 8px auto; padding: 12px; font-size: 19px; }
.btn.disabled { opacity: 0.45; cursor: not-allowed; }
.btn .cost { font-size: 13px; display: block; font-weight: 600; }
.lack { color: #c05050; font-size: 13px; font-weight: 700; white-space: nowrap; }

.tag { background: #e3d5b4; color: #7a6238; border-radius: 8px; padding: 2px 8px; font-size: 13px; font-weight: 700; }
.tag.max { background: #caa227; color: #fff; }
.tag.on { background: #5c8a46; color: #fff; }

.abilityRow { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid #b09a6e; background: #f3e8d2; color: #54432a;
  border-radius: 20px; padding: 8px 14px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.chip.on { background: #5c8a46; border-color: #46703a; color: #fff; }
.chip.locked { opacity: 0.55; cursor: default; }

.costumeGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.costumeCard {
  background: #fffdf7; border: 2px solid #ddcba6; border-radius: 14px;
  padding: 10px 6px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 16px; color: #54432a;
}
.costumeCard.wearing { border-color: #5c8a46; box-shadow: 0 0 0 2px rgba(92,138,70,0.25); }

#fortPreview { display: block; margin: 8px auto; border-radius: 14px; border: 2px solid #ddcba6; }

/* ================= 전투 ================= */
#battle { background: #000; }
#gameCanvas { position: absolute; inset: 0; width: 1280px; height: 720px; }

#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

#hudFort {
  position: absolute; left: 14px; top: 12px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(40,32,20,0.72);
  border-radius: 14px; padding: 8px 14px;
  color: #f5ecd8;
}
#hudFort .icon { font-size: 22px; }
.fortCol { display: flex; flex-direction: column; gap: 3px; }
.fortCol .label { font-size: 13px; font-weight: 700; }
#hudFort .bar { width: 190px; height: 13px; background: rgba(0,0,0,0.5); border-radius: 7px; overflow: hidden; }
#fortHpFill { height: 100%; width: 100%; border-radius: 7px; transition: width 0.15s; }
#fortHpFill.ok { background: #67d35c; }
#fortHpFill.warn { background: #f2b531; }
#fortHpFill.bad { background: #e35345; }
#fortHpText { font-size: 15px; font-weight: 700; min-width: 86px; text-align: right; }

#hudRound {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  text-align: center;
  background: rgba(40,32,20,0.72);
  border-radius: 16px; padding: 7px 26px;
  color: #f5ecd8;
}
.roundLabel { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
#timeText { font-size: 15px; font-weight: 600; opacity: 0.9; }

#hudRight {
  position: absolute; right: 14px; top: 12px;
  display: flex; align-items: center; gap: 8px;
}
.pill {
  background: rgba(40,32,20,0.72); color: #ffe9a3;
  border-radius: 14px; padding: 9px 14px; font-size: 18px; font-weight: 800;
}
#btnPause {
  width: 46px; height: 46px; border-radius: 14px; border: none;
  background: rgba(40,32,20,0.72); color: #f5ecd8; font-size: 20px; cursor: pointer;
}

#hudTarget {
  position: absolute; right: 18px; bottom: 18px;
  background: rgba(40,32,20,0.78); color: #ffd23e;
  border: 2px solid #ffd23e;
  border-radius: 20px; padding: 10px 18px; font-size: 17px; font-weight: 800;
}

#devHud {
  position: absolute; right: 14px; top: 70px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(130,40,120,0.75);
  border-radius: 12px; padding: 6px 10px;
}
#devHud .devLabel { color: #ffd1f5; font-size: 13px; font-weight: 800; }
#devHud button {
  border: none; border-radius: 9px; padding: 6px 10px;
  background: #fff; color: #822878; font-size: 14px; font-weight: 700; cursor: pointer;
}

#joyZone {
  position: absolute; left: 0; bottom: 0;
  width: 260px; height: 240px;
}
#joyBase {
  display: none;
  position: absolute; width: 124px; height: 124px;
  margin-left: -62px; margin-top: -62px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  border: 2px solid rgba(255,255,255,0.35);
}
#joyKnob {
  position: absolute; left: 50%; top: 50%;
  width: 58px; height: 58px; border-radius: 50%;
  background: rgba(255,255,255,0.75);
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%);
}

/* ================= 오버레이 ================= */
.overlay {
  position: absolute; inset: 0;
  background: rgba(20,16,8,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.dialog {
  background: #fdf6e6;
  border: 3px solid #c9b088;
  border-radius: 22px;
  padding: 26px 40px;
  min-width: 420px;
  text-align: center;
  color: #54432a;
}
.dialog h2 { font-size: 28px; margin-bottom: 8px; }
.dialog h2.win { color: #4a9c47; }
.dialog h2.lose { color: #c05050; }
.dialog .sub { margin-bottom: 12px; }
.resTable { margin: 12px auto; max-width: 340px; }
.resTable .row {
  display: flex; justify-content: space-between;
  font-size: 17px; padding: 5px 4px;
  border-bottom: 1px dashed #d8c7a2;
}
.resTable .row.total { font-size: 20px; font-weight: 800; color: #8a5f1e; border-bottom: none; margin-top: 4px; }
.unlock { color: #c2443d; font-weight: 800; font-size: 18px; min-height: 22px; }
.btnRow { display: flex; gap: 10px; justify-content: center; }
.btnRow .btn.big { width: 180px; margin: 8px 0; }

/* 스크롤바 */
#panel::-webkit-scrollbar { width: 10px; }
#panel::-webkit-scrollbar-thumb { background: #cdb88e; border-radius: 5px; }
