/* ═══════════════════════════════════════
   COSMIK RAIDERS — 2060 스타일시트
   ═══════════════════════════════════════ */

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

:root {
  --bg:        #080c10;
  --bg2:       #0c1218;
  --bg3:       #101820;
  --bg4:       #15212a;
  --border:    #1a3340;
  --border2:   #244858;
  --green:     #4ddb8a;
  --cyan:      #3ecfde;
  --yellow:    #d4b84a;
  --red:       #e85560;
  --orange:    #d47a30;
  --purple:    #9e7ee8;
  --white:     #d8e8f0;
  --muted:     #8aa4b4;
  --dim:       #4a6070;
  --font: 'JetBrains Mono','D2Coding','IBM Plex Mono','Consolas',monospace;
  --font-display: 'Iowan Old Style','Noto Serif KR','AppleMyungjo',serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── 전체 레이아웃 ─────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  flex-shrink: 0;
}
#header-title { color: var(--cyan); font-weight: 700; letter-spacing: 0.5px; }
.header-sub   { color: var(--dim);  font-weight: 400; }
#header-time  { color: var(--dim);  font-size: 11px; }

#main-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  background:
    radial-gradient(circle at top left, rgba(62,207,222,0.08), transparent 36%),
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 28%),
    var(--bg);
}

/* ══════════════════════════════════════
   로그인 오버레이
   ══════════════════════════════════════ */
#auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 8, 12, 0.88);
}
#auth-overlay.hidden { display: none; }

#auth-card {
  width: min(920px, calc(100vw - 48px));
  max-height: min(680px, calc(100vh - 40px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  padding: 22px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  overflow: hidden;
  align-items: start;
}

#auth-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; }
#auth-side  { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }

#auth-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#auth-title  { color: var(--cyan); font-size: 16px; font-weight: 700; }
#auth-status { color: var(--dim);  font-size: 11px; }

#auth-subtitle, #auth-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

#auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-tab, #auth-submit {
  min-height: 36px;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.auth-tab.active {
  border-color: var(--cyan);
  color: var(--white);
}
.auth-tab:hover { color: var(--white); }

#auth-error {
  min-height: 16px;
  color: var(--red);
  font-size: 11px;
}

#auth-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.auth-field label {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  width: 60px;
  flex-shrink: 0;
}
.auth-field input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--white);
  font-family: var(--font);
  font-size: 13px;
}

#auth-actions { display: flex; }
#auth-submit {
  min-width: 130px;
  border-color: var(--cyan);
  color: var(--cyan);
}
#auth-submit:disabled { opacity: 0.45; cursor: not-allowed; }
#auth-submit:hover:not(:disabled) {
  background: rgba(62,207,222,0.08);
}

/* 저장된 캐릭터 목록 */
.side-label {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

#auth-side {
  border-left: 1px solid var(--border);
  padding-left: 20px;
  overflow: hidden;
}

#character-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.character-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 8px;
  min-width: 0;
  align-items: stretch;
}
.character-select,
.character-delete {
  min-height: 42px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.character-select {
  display: block;
  min-width: 0;
  padding: 8px 12px;
  color: var(--white);
  cursor: pointer;
  text-align: left;
}
.character-select:hover { border-color: var(--cyan); }
.character-summary { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.character-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}
.character-name,
.character-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.character-name { color: var(--white); font-size: 12px; font-weight: 600; }
.character-meta { color: var(--muted); font-size: 10px; margin-top: 2px; }
.character-badge { color: var(--cyan); font-size: 9px; flex-shrink: 0; white-space: nowrap; }
.character-badge.online { color: var(--orange); }
.character-delete {
  min-width: 48px;
  padding: 0 8px;
  color: var(--red);
  cursor: pointer;
  align-self: stretch;
}
.character-delete:hover:not(:disabled) {
  border-color: var(--red);
  background: rgba(232, 85, 96, 0.08);
}
.character-delete:disabled {
  color: var(--dim);
  cursor: not-allowed;
  opacity: 0.6;
}
.character-empty { color: var(--dim); font-size: 11px; line-height: 1.6; }

/* ══════════════════════════════════════
   좌측 — 게임 패널 (텍스트 로그 주인공)
   ══════════════════════════════════════ */
#game-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
}

/* ── 상태 줄 / 전투 대상 정보 ───────── */
#status-strip {
  display: contents;
}

#combat-hud {
  --combat-enemy-card-width: 196px;
  display: grid;
  gap: 0;
  padding: 0;
  border: none;
  background: transparent;
  width: min(100%, var(--combat-enemy-card-width));
  justify-self: start;
  align-self: start;
}

#combat-hud.is-multi-enemy {
  grid-column: 1 / -1;
  width: min(100%, 620px);
}

#combat-hud.hidden {
  display: none !important;
}

#combat-hud-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-bottom: 0;
}

#combat-hud.is-multi-enemy #combat-hud-inner {
  grid-template-columns: repeat(auto-fit, minmax(var(--combat-enemy-card-width), var(--combat-enemy-card-width)));
  align-items: start;
  justify-content: start;
}

.c-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  box-sizing: border-box;
  width: var(--combat-enemy-card-width);
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  overflow: hidden;
  min-height: 58px;
}
.c-card-player { border-left: 2px solid var(--cyan); }
.c-card-enemy  { border-right: 2px solid var(--red); flex-direction: row-reverse; }

.c-icon {
  font-size: 14px;
  color: var(--cyan);
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.c-icon-enemy { color: var(--red); }

.c-body { flex: 1; min-width: 0; display: grid; gap: 2px; }

.c-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.c-name { color: var(--white); font-size: 11px; font-weight: 700; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-tag  { color: var(--cyan); font-size: 9px; line-height: 1.1; flex-shrink: 0; }
.c-tag-enemy { color: var(--red); }

.c-bar-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  width: 136px;
}
.c-bar {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  height: 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  overflow: hidden;
}
.c-fill { height: 100%; transition: width 0.3s ease; }
.c-fill-p { background: linear-gradient(90deg, #2a9e60, var(--green)); }
.c-fill-e { background: linear-gradient(90deg, #9e2020, var(--red)); }
.c-bar-txt {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  justify-self: stretch;
  color: var(--white);
  font-size: 9px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  white-space: nowrap;
  pointer-events: none;
}

.c-stats { color: var(--dim); font-size: 8px; display: flex; flex-wrap: wrap; gap: 2px 6px; }
.c-stats span { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.c-stats b { color: var(--white); font-weight: 600; }

.c-statuses { display: flex; flex-wrap: wrap; gap: 4px; min-height: 12px; }
.combat-status-chip { font-size: 9px; color: var(--muted); font-weight: 700; }
.combat-status-chip.is-danger { color: var(--red); }
.combat-status-chip.is-guard  { color: var(--yellow); }
.combat-status-chip.is-empty  { color: var(--dim); }

#combat-vs {
  text-align: center;
  color: var(--dim);
  font-size: 9px;
  font-weight: 700;
}

.c-card-player,
#combat-vs {
  display: none;
}

.c-support-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

#combat-hud.is-multi-enemy .c-support-list {
  display: contents;
}

.c-support-list.hidden {
  display: none !important;
}

.c-card-support {
  min-height: 58px;
}

.c-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  color: var(--dim);
  font-size: 8px;
}

.c-statuses {
  display: none;
}

.c-note {
  display: none;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
  min-height: 12px;
  white-space: pre-wrap;
}

.c-note.is-visible {
  display: block;
}

.c-popups {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.combat-popup {
  position: absolute;
  left: 50%; top: 30%;
  transform: translate(-50%, 0);
  font-size: 16px;
  font-weight: 700;
  opacity: 0;
  animation: floatUp 0.9s ease forwards;
}
.combat-popup.is-damage { color: var(--red); }
.combat-popup.is-miss   { color: var(--cyan); }
.combat-popup.is-block  { color: var(--yellow); }

/* 전투 버튼 */
#combat-log-wrap {
  display: block;
  margin-top: 8px;
}

#combat-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.ca {
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.ca:hover:not(:disabled) { border-color: var(--cyan); color: var(--white); }
.ca:disabled { opacity: 0.35; cursor: not-allowed; }

/* 전투 애니메이션 */
.c-card.is-hit   { animation: hitFlash 0.3s ease; }
.c-card.is-evade { animation: evadeFlash 0.3s ease; }
#combat-hud.is-screen-shaking { animation: shake 0.3s linear; }

@keyframes floatUp  { 0%{opacity:1;transform:translate(-50%,0)} 100%{opacity:0;transform:translate(-50%,-28px)} }
@keyframes statFloatUp { 0%{opacity:1;transform:translateY(0)} 100%{opacity:0;transform:translateY(-18px)} }
@keyframes hitFlash { 0%,100%{background:var(--bg3)} 50%{background:rgba(232,85,96,0.18)} }
@keyframes evadeFlash { 0%,100%{opacity:1} 50%{opacity:0.5} }
@keyframes shake    { 0%,100%{transform:none} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }

/* ── 텍스트 출력 ────────────────────── */
#game-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 14px 16px 12px;
  border-right: 1px solid var(--border);
}

#scene-panel {
  order: 1;
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border2);
  background:
    radial-gradient(circle at top left, rgba(62,207,222,0.10), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
    var(--bg2);
  overflow: hidden;
}

#scene-panel.is-transitioning {
  box-shadow: inset 0 0 0 1px rgba(62,207,222,0.18);
}

#scene-intro {
  position: absolute;
  inset: 18px 18px auto auto;
  width: min(360px, calc(100% - 36px));
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid rgba(62,207,222,0.4);
  background: rgba(8, 12, 16, 0.92);
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
  z-index: 3;
}

.scene-intro-label {
  color: var(--cyan);
  font-size: 10px;
  letter-spacing: 1px;
}

#scene-intro-title {
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
}

#scene-intro-body {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

#scene-hero {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto 188px auto;
  gap: 10px;
  min-height: 0;
  height: 100%;
  align-content: stretch;
}

#scene-kicker {
  color: var(--cyan);
  font-size: 10px;
  letter-spacing: 1.4px;
  grid-column: 1 / -1;
}

#scene-row1 {
  display: flex;
  align-items: end;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

#scene-name {
  color: var(--white);
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
  font-weight: 700;
}

#scene-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  grid-column: 1 / -1;
}

.scene-meta-badge {
  padding: 2px 8px;
  border: 1px solid currentColor;
  font-size: 10px;
  color: var(--muted);
}

.scene-meta-badge.is-success { color: var(--green); }
.scene-meta-badge.is-highlight { color: var(--yellow); }
.scene-meta-badge.is-zone { color: var(--cyan); }
.scene-meta-badge.is-muted { color: var(--dim); }

#scene-reference {
  color: var(--muted);
  font-size: 11px;
  grid-column: 1 / -1;
  grid-row: 4;
}

#scene-description {
  max-width: 820px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  color: var(--white);
  font-family: var(--font-display);
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.78;
  white-space: normal;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  grid-column: 1 / -1;
  grid-row: 5;
}

#scene-description::-webkit-scrollbar { width: 5px; }
#scene-description::-webkit-scrollbar-track { background: transparent; }
#scene-description::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.scene-enemy-presence {
  display: block;
  margin-top: 14px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.8;
  color: var(--white);
}

.scene-context-block {
  display: block;
  margin-top: 14px;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}

.scene-context-line {
  display: block;
}

.scene-context-line + .scene-context-line {
  margin-top: 2px;
}

.scene-context-label {
  color: var(--cyan);
  margin-right: 6px;
}

.scene-item-pickup {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--yellow);
  font-family: var(--font);
  font-size: inherit;
  line-height: inherit;
  cursor: pointer;
}

.scene-item-pickup:hover,
.scene-item-pickup:focus-visible {
  color: var(--white);
  text-decoration: underline;
  outline: none;
}

.scene-enemy-line {
  display: block;
}

.scene-enemy-line + .scene-enemy-line {
  margin-top: 4px;
}

.scene-enemy-name {
  color: var(--white);
  font-weight: 700;
  margin-right: 4px;
}

.scene-enemy-name.is-higher { color: var(--red); }
.scene-enemy-name.is-equal { color: var(--white); }
.scene-enemy-name.is-lower { color: var(--dim); }

#scene-command-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: baseline;
  grid-column: 1 / -1;
  grid-row: 9;
}

#scene-command-label {
  color: var(--white);
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}

#scene-command-content {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

#scene-actions {
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.scene-action-text {
  cursor: pointer;
}

.scene-action-text.is-move {
  color: var(--green);
}

.scene-action-text.is-utility {
  color: var(--cyan);
}

.scene-action-sep {
  color: rgba(216, 232, 240, 0.75);
}

#scene-command-prompt {
  color: var(--cyan);
  font-size: 12px;
  line-height: 1.7;
  flex-shrink: 0;
}

#cmd-input {
  min-width: 140px;
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--white);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.7;
  caret-color: var(--cyan);
  padding: 0;
}

#cmd-input::placeholder { color: var(--dim); }

#feed-panel {
  flex-shrink: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  height: 188px;
  min-height: 188px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 16, 0.48);
  overflow: hidden;
  grid-column: 2;
  grid-row: 8;
}

#combat-hud {
  grid-column: 1;
  grid-row: 6;
}

#info-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  height: 164px;
  min-height: 164px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 16, 0.48);
  overflow: hidden;
  grid-column: 1 / -1;
  grid-row: 7;
}

#info-panel.is-shop-expanded {
  height: 248px;
  min-height: 248px;
}

#info-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#info-close {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.24);
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  line-height: 1.2;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

#info-close:hover {
  color: var(--white);
  border-color: rgba(92, 208, 255, 0.45);
}

#info-output {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#info-output::-webkit-scrollbar { width: 5px; }
#info-output::-webkit-scrollbar-track { background: transparent; }
#info-output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#info-output.is-stat-allocation {
  white-space: normal;
}

#info-output.is-shop-info {
  white-space: normal;
}

.shop-info-panel {
  display: grid;
  gap: 8px;
  width: 100%;
  margin: 0;
}

.shop-info-credits {
  color: var(--yellow);
  font-size: 11px;
  line-height: 1.4;
}

.shop-info-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.shop-info-section {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.shop-info-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.shop-info-section-title {
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.shop-info-qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.shop-info-qty-label {
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.shop-info-qty-input {
  width: 52px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border);
  background: rgba(10, 16, 22, 0.92);
  color: var(--white);
  font-family: var(--font);
  font-size: 10px;
  line-height: 1;
}

.shop-info-qty-input:focus {
  outline: none;
  border-color: rgba(181, 108, 255, 0.8);
}

.shop-info-list {
  display: grid;
  gap: 4px;
}

.shop-info-row {
  display: grid;
  grid-template-columns: 28px minmax(110px, 0.8fr) minmax(0, 1fr) 64px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 0;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.shop-info-row:hover {
  background: rgba(173, 88, 255, 0.08);
}
.shop-info-row:focus-visible {
  outline: 1px solid rgba(181, 108, 255, 0.8);
  outline-offset: 1px;
}

.shop-info-index,
.shop-info-name,
.shop-info-stats,
.shop-info-price {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.shop-info-index {
  color: var(--cyan);
}

.shop-info-name {
  color: var(--white);
}

.shop-info-stats {
  color: var(--muted);
}

.shop-info-price {
  color: var(--yellow);
  text-align: right;
}

.shop-info-guide {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.shop-info-empty {
  color: var(--dim);
  font-size: 11px;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .shop-info-columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
}

.stat-alloc-panel {
  display: grid;
  gap: 8px;
  width: min(100%, 456px);
}

.stat-alloc-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.stat-alloc-summary strong {
  color: var(--white);
  font-size: 12px;
}

.stat-alloc-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.stat-alloc-row {
  display: grid;
  grid-template-columns: 38px max-content 24px;
  grid-template-areas: "name meta add";
  align-items: center;
  justify-content: start;
  gap: 5px;
  padding: 0;
  border: none;
  background: transparent;
}

.stat-alloc-name {
  grid-area: name;
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.stat-alloc-meta {
  grid-area: meta;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.stat-alloc-meta span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.stat-alloc-meta b {
  color: var(--white);
  font-weight: 700;
}

.stat-alloc-add {
  grid-area: add;
  align-self: center;
  justify-self: end;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(92, 208, 255, 0.38);
  background: rgba(24, 40, 52, 0.42);
  color: var(--cyan);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.stat-alloc-add:hover:not(:disabled) {
  border-color: var(--cyan);
  color: var(--white);
}

.stat-alloc-add:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stat-alloc-empty {
  color: var(--dim);
  font-size: 11px;
  line-height: 1.6;
}

@media (max-width: 880px) {
  .stat-alloc-meta {
    gap: 6px;
  }
}

#stats-panel {
  grid-column: 1;
  grid-row: 8;
}

#output {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  font-size: 12px;
  line-height: 1.7;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#output::-webkit-scrollbar { width: 5px; }
#output::-webkit-scrollbar-track { background: transparent; }
#output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ══════════════════════════════════════
   우측 — 정보 패널 묶음
   ══════════════════════════════════════ */
#side-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 14px 16px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#side-panel::-webkit-scrollbar { width: 4px; }
#side-panel::-webkit-scrollbar-track { background: transparent; }
#side-panel::-webkit-scrollbar-thumb { background: var(--border); }

#stats-panel,
#map-panel,
#inventory-panel {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 16, 0.76);
  flex-shrink: 0;
}

#inventory-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

#inventory-meta {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-align: right;
}

#stats-panel {
  min-width: 0;
  align-content: start;
  width: min(100%, 236px);
  gap: 3px;
}

/* ── 캐릭터 상태 ─────────────────────── */
#stats-name-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 1px;
}

.header-combat-badge {
  margin-left: auto;
  align-self: center;
  font-size: 9px;
  padding: 1px 5px;
}

.s-name  { color: var(--green);  font-size: 12px; font-weight: 700; line-height: 1.1; }
.s-level { color: var(--cyan);   font-size: 10px; line-height: 1.1; }

.s-bar-row {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 168px) 14px;
  align-items: center;
  gap: 5px;
  margin-bottom: 0;
}

.s-bar-row .s-stat-inline-add {
  grid-column: 3;
}

.s-bar-row .s-stat-float {
  right: -2px;
  top: -6px;
}

.s-lbl { color: var(--white); font-size: 9px; line-height: 1.1; }
.s-val { color: var(--muted); font-size: 10px; text-align: right; }

.bar-track {
  position: relative;
  height: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  overflow: hidden;
}

.s-val-inside {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 10px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  pointer-events: none;
}

.bar-fill {
  height: 100%;
  transition: width 0.35s ease, background 0.35s ease;
}

.bar-hp  { background: linear-gradient(90deg, #1a9948, var(--green)); }
.bar-mp  { background: linear-gradient(90deg, #3b5cad, #77a8ff); }
.bar-exp { background: linear-gradient(90deg, #1a7a9e, var(--cyan)); }

.s-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 8px;
  margin: 3px 0 1px;
}

.s-stat {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px 14px;
  align-items: center;
  gap: 3px;
  padding: 0;
  background: transparent;
  border: none;
  min-width: 0;
}

.s-stat-button {
  grid-template-columns: minmax(0, 1fr) 22px 14px;
  width: 100%;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
}

.s-stat-button::after {
  content: '';
  width: 14px;
  height: 14px;
  grid-column: 3;
}

.s-stat-button:hover,
.s-stat-button:focus-visible {
  color: var(--white);
}

.s-stat-button.has-points .s-lbl,
.s-stat-button.has-points b {
  color: var(--cyan);
}

.s-stat .s-lbl {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.1;
  min-width: 0;
  white-space: nowrap;
}
.s-stat b {
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  text-align: right;
  min-width: 18px;
}

.s-stat-inline-add {
  width: 14px;
  height: 14px;
  padding: 0;
  border: 1px solid rgba(92, 208, 255, 0.38);
  background: rgba(24, 40, 52, 0.52);
  color: var(--cyan);
  font-family: var(--font);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.s-stat-inline-add.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.s-stat-inline-add:hover,
.s-stat-inline-add:focus-visible {
  color: var(--white);
  border-color: rgba(138, 231, 255, 0.72);
  background: rgba(38, 66, 82, 0.68);
  outline: none;
}

.s-stat-float {
  position: absolute;
  right: 0;
  top: -2px;
  color: #7fffb0;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0);
}

.s-stat.is-gaining .s-stat-float {
  animation: statFloatUp 0.85s ease forwards;
}

.s-equip-row {
  display: none;
}

.s-equip {
  color: var(--yellow);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#status-badges { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }

.badge {
  font-size: 10px;
  padding: 1px 6px;
  border: 1px solid currentColor;
  font-weight: 700;
}

.badge-bleed  { color: var(--red);    background: rgba(232,85,96,0.12); }
.badge-rest   { color: var(--green);  background: rgba(77,219,138,0.10); }
.badge-combat { color: var(--orange); background: rgba(212,122,48,0.12); }
.badge-guard  { color: var(--yellow); background: rgba(212,184,74,0.10); }
.badge-pvp    { color: var(--purple); background: rgba(158,126,232,0.12); }
.badge-stat   { color: var(--cyan);   background: rgba(77,195,219,0.10); }
.badge-stat[role="button"] { cursor: pointer; }

/* ── 미니맵 / 알림 ───────────────────── */
#map-display {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  /* ASCII 폴백용 */
  font-size: 11px;
  line-height: 1.55;
  color: var(--dim);
  white-space: pre;
  letter-spacing: 0;
  font-family: var(--font);
}

#inventory-display {
  min-height: 0;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.5;
  color: var(--white);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#inventory-display::-webkit-scrollbar { width: 5px; }
#inventory-display::-webkit-scrollbar-track { background: transparent; }
#inventory-display::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* SVG 모눈 미니맵 */
.minimap-svg { display: block; }

.minimap-grid line {
  stroke: rgba(255,255,255,0.06);
  stroke-width: 0.5;
}

.minimap-fog { opacity: 1; }

.minimap-conn {
  stroke: rgba(100,160,190,0.38);
  stroke-width: 1.5;
  stroke-linecap: round;
}
.minimap-conn.is-current-path {
  stroke-width: 2;
}
.minimap-conn.is-dim {
  stroke: rgba(42,52,60,0.16);
}

.minimap-cell {
  fill: rgba(70,110,130,0.38);
  stroke: rgba(110,150,170,0.55);
  stroke-width: 1;
}
.minimap-cell.is-fog {
  fill: rgba(12,16,20,0.94);
  stroke: rgba(28,36,44,0.72);
}
.minimap-cell.is-dim {
  fill: rgba(10,14,18,0.92);
  stroke: rgba(34,42,50,0.48);
}
.minimap-cell.is-current {
  fill: rgba(0,255,136,0.62);
  stroke: #00ff88;
  stroke-width: 2;
}
.minimap-cell.is-cross-discovered {
  fill: rgba(62,207,222,0.64);
  stroke: #3ecfde;
  stroke-width: 1.6;
}
.minimap-cell.is-player {
  fill: rgba(212,184,74,0.55);
  stroke: #d4b84a;
  stroke-width: 1;
}
.minimap-cell.is-shop {
  fill: rgba(173,88,255,0.62);
  stroke: #b56cff;
  stroke-width: 1.4;
}
.minimap-cell.is-current.is-shop {
  fill: rgba(0,255,136,0.62);
  stroke: #b56cff;
  stroke-width: 2;
}
.minimap-shop-badge {
  fill: rgba(173,88,255,0.98);
  stroke: rgba(242,231,255,0.96);
  stroke-width: 1.2;
  filter: drop-shadow(0 0 2px rgba(181,108,255,0.55));
  pointer-events: none;
}
.minimap-shop-badge.is-current {
  fill: rgba(173,88,255,0.98);
  stroke: rgba(255,255,255,0.98);
  stroke-width: 1.4;
  pointer-events: none;
}

.minimap-label {
  fill: rgba(160,200,220,0.85);
  font-size: 7px;
  font-family: var(--font);
  pointer-events: none;
}
.minimap-label.is-dim {
  fill: rgba(72,84,92,0.22);
}
.minimap-label.is-current { fill: #002e15; font-weight: 700; }
.minimap-label.is-player  { fill: #3a2c00; }

/* ASCII 폴백 */
.map-current { color: var(--green); font-weight: 700; }
.map-player  { color: var(--yellow); }
.map-normal  { color: var(--dim); }

#map-legend { font-size: 10px; color: var(--dim); margin-top: 4px; }
.leg-cur    { color: var(--green); }
.leg-ply    { color: var(--yellow); }

#enhance-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 8, 12, 0.42);
  pointer-events: none;
}

#enhance-card {
  width: min(420px, calc(100vw - 48px));
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  border: 1px solid rgba(36, 72, 88, 0.92);
  background: rgba(8, 12, 16, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  text-align: center;
}

#enhance-kicker {
  color: var(--muted);
  font-size: 11px;
}

#enhance-item {
  color: var(--white);
  font-size: 24px;
  line-height: 1.3;
  font-family: var(--font-display);
}

#enhance-result {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

#enhance-card.is-pending #enhance-item {
  animation: enhancePulse 0.62s ease-in-out infinite alternate;
}

#enhance-card.is-success {
  border-color: rgba(62, 207, 222, 0.75);
}
#enhance-card.is-success #enhance-result {
  color: var(--cyan);
}

#enhance-card.is-fail {
  border-color: rgba(138, 164, 180, 0.7);
}
#enhance-card.is-fail #enhance-result {
  color: var(--muted);
}

#enhance-card.is-downgrade {
  border-color: rgba(212, 122, 48, 0.78);
}
#enhance-card.is-downgrade #enhance-result {
  color: var(--orange);
}

#enhance-card.is-break {
  border-color: rgba(232, 85, 96, 0.8);
}
#enhance-card.is-break #enhance-result {
  color: var(--red);
}

@keyframes enhancePulse {
  from {
    opacity: 1;
    transform: scale(1);
    text-shadow: 0 0 0 rgba(158, 126, 232, 0);
  }
  to {
    opacity: 0.28;
    transform: scale(0.985);
    text-shadow: 0 0 22px rgba(158, 126, 232, 0.35);
  }
}

#toast-layer {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 10px 12px;
  border: 1px solid var(--border2);
  background: rgba(8, 12, 16, 0.95);
  color: var(--white);
  font-size: 11px;
  line-height: 1.55;
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
  animation: toastIn 0.18s ease;
}

.toast.is-danger { border-color: rgba(232,85,96,0.5); color: #ffd6da; }
.toast.is-accent { border-color: rgba(62,207,222,0.5); }
.toast.is-warn   { border-color: rgba(212,184,74,0.5); color: #fff2c6; }
.toast.is-neutral { border-color: rgba(138,164,180,0.4); color: var(--muted); }
.toast.is-leaving { opacity: 0; transform: translateY(4px); transition: opacity 0.2s ease, transform 0.2s ease; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════
   메시지 색상
   ══════════════════════════════════════ */
.msg-line { white-space: pre-wrap; word-break: break-word; }

.msg-welcome       { color: var(--cyan); }
.msg-system        { color: var(--dim);  font-style: italic; }
.msg-input         { color: var(--green); }
.msg-look          { color: var(--white); }
.msg-info          { color: var(--white); }
.msg-error         { color: var(--red);  }
.msg-help          { color: var(--cyan); }
.msg-inventory     { color: var(--white); }
.msg-status        { color: var(--white); }
.msg-shop          { color: var(--yellow); }
.msg-enhance       { color: var(--purple); }
.msg-chat          { color: var(--green); }
.msg-whisper       { color: var(--purple); }
.msg-party         { color: var(--cyan); }
.msg-encounter     { color: var(--red);   font-weight: 700; }
.msg-levelup       { color: var(--cyan);  font-weight: 700; }
.msg-rest          { color: var(--green); }

.msg-combat-start  { color: var(--red);    font-weight: 700; }
.msg-combat-end    { color: var(--yellow); font-weight: 700; }
.msg-combat-status { color: var(--white); }
.msg-combat-p-act  { color: var(--cyan); }
.msg-combat-m-dmg  { color: var(--yellow); }
.msg-combat-m-act  { color: var(--orange); font-weight: 700; }
.msg-combat-p-dmg  { color: var(--red);    font-weight: 700; }
.msg-combat-dodge  { color: var(--dim);    font-style: italic; }
.msg-combat-bleed  { color: #e03010;       font-weight: 700; }

.msg-combat-start, .msg-encounter {
  animation: flashBg 0.45s ease;
}
@keyframes flashBg { 0%{background:rgba(232,85,96,0.15)} 100%{background:transparent} }

.msg-frag-text {
  color: var(--white);
}

.msg-frag-note {
  color: var(--muted);
}

.msg-frag-damage {
  color: var(--red);
  font-weight: 700;
}

.msg-frag-heal {
  color: var(--green);
  font-weight: 700;
}

.msg-entity-name,
.msg-item-name {
  color: var(--white);
  font-weight: 700;
}

.msg-entity-name.is-higher { color: var(--red); }
.msg-entity-name.is-equal { color: var(--white); }
.msg-entity-name.is-lower { color: var(--dim); }

.inventory-card {
  display: grid;
  gap: 7px;
}

.inventory-section-title {
  color: var(--cyan);
  font-weight: 700;
}

.inventory-equipped-list {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.inventory-equipped-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.inventory-equipped-label {
  color: var(--white);
}

.inventory-carried-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 12px;
}

.inventory-carried-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.inventory-item-button {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.inventory-equipped-item {
  min-width: 0;
}

.inventory-item-button:hover,
.inventory-item-button:focus-visible {
  color: var(--white);
}

.inventory-item-button:focus-visible {
  outline: none;
  border-color: rgba(77, 195, 219, 0.7);
}

.inventory-item-button.is-selected {
  border-color: rgba(212, 184, 74, 0.9);
  background: rgba(212, 184, 74, 0.08);
}

.inventory-item-button.is-enhance-target {
  border-color: rgba(77, 195, 219, 0.45);
  background: rgba(77, 195, 219, 0.06);
}

.inventory-item-index {
  color: var(--cyan);
  flex-shrink: 0;
}

.inventory-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-item-name.is-normal { color: #f0f3f6; }
.inventory-item-name.is-magic { color: #6aa9ff; }
.inventory-item-name.is-rare { color: #f2d15b; }
.inventory-item-name.is-unique { color: #d98a3a; }

.inventory-empty {
  color: var(--muted);
}

.inventory-guide {
  color: var(--dim);
  font-size: 10px;
  line-height: 1.5;
}

/* ── 반응형 ─────────────────────────── */
@media (max-width: 980px) {
  #main-layout { flex-direction: column; }
  #game-panel { border-right: none; border-bottom: 1px solid var(--border); }
  #scene-hero { grid-template-columns: minmax(0, 1fr); }
  #scene-reference,
  #scene-description,
  #scene-command-row,
  #info-panel,
  #feed-panel,
  #combat-hud,
  #stats-panel {
    grid-row: auto;
  }
  #info-panel,
  #feed-panel,
  #combat-hud,
  #stats-panel {
    grid-column: 1;
  }
  #info-panel { grid-row: auto; }
  #feed-panel { grid-row: auto; }
  #combat-hud { grid-row: auto; }
  #stats-panel { grid-row: auto; }
  #side-panel {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .inventory-carried-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  #auth-card {
    grid-template-columns: minmax(0, 1fr);
    max-height: calc(100vh - 24px);
    padding: 16px;
  }
  #auth-form { grid-template-columns: 1fr; }
  #auth-side {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 14px;
  }
  .character-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .character-delete {
    min-height: 36px;
  }
  #side-panel { display: none; }
  #game-panel { padding: 10px; }
  #scene-panel { padding: 16px; }
  #scene-row1 { align-items: start; }
  #scene-name { font-size: 28px; }
}
