/* 게임 화면 레이아웃 — docs/specs/interface.md 의 상단/좌/중앙/우/하단 구성 */

.app {
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr) auto;
  height: 100%;
}

/* ---------------------------------------------------------------- 상단 */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: 0 var(--s4);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(
    180deg,
    var(--danger) 0 48%,
    var(--surface-3) 52% 100%
  );
  border: 1.5px solid var(--line-strong);
  position: relative;
  flex: none;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-text b {
  font-size: var(--t-small);
  letter-spacing: 0.02em;
}

.brand-text span {
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  color: var(--ink-faint);
}

.readouts {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.readout {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 0 var(--s4);
  border-left: 1px solid var(--line-soft);
  min-width: 92px;
}

.readout:first-child {
  border-left: 0;
  padding-left: 0;
}

.readout > .label {
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.readout > .value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: "PokemonClassic", var(--font-mono);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  font-size: var(--t-lead);
  line-height: 1.1;
}

.readout > .value small {
  font-size: var(--t-micro);
  color: var(--ink-faint);
}

.readout[data-tone="life"] > .value {
  color: var(--danger);
}

.readout[data-tone="gold"] > .value {
  color: var(--gold);
}

.readout[data-tone="time"][data-urgent="true"] > .value {
  color: var(--danger);
}

.readout[data-tone="boss"] > .value {
  font-size: var(--t-small);
  color: var(--boss);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
}

/* ----------------------------------------------------------- 본문 3열 */

.main {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--detail-w);
  gap: var(--s3);
  padding: var(--s3);
  min-height: 0;
}

.rail,
.detail {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

/* 세로 공간이 부족해도 패널 내용을 잘라내지 않고 열 전체가 스크롤한다 */
.rail > .panel,
.detail > .panel {
  flex: none;
}

.rail > .panel > .panel-body,
.detail > .panel > .panel-body {
  overflow: visible;
}

/* ------------------------------------------------------------ 전장 */

.stage {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-height: 0;
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
}

.phase {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.phase[data-phase="prep"] .phase-dot {
  background: var(--signal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--signal) 22%, transparent);
}

.phase[data-phase="combat"] .phase-dot {
  background: var(--danger);
  animation: pulse 1.6s var(--ease) infinite;
}

.phase[data-phase="settle"] .phase-dot {
  background: var(--warn);
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 36%, transparent);
  }
  50% {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--danger) 0%, transparent);
  }
}

.phase-label {
  font-size: var(--t-small);
  font-weight: 500;
}

.field-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--r3);
  background: radial-gradient(
    120% 90% at 50% 0%,
    var(--ground-grid) 0%,
    var(--field) 70%
  );
  overflow: hidden;
}

#field {
  display: block;
  width: 100%;
  height: 100%;
}

.field-overlay {
  position: absolute;
  inset: auto var(--s3) var(--s3) var(--s3);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3);
  pointer-events: none;
}

.hint {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r2);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(6px);
  font-size: var(--t-micro);
  color: var(--ink-muted);
  pointer-events: auto;
}

/* ------------------------------------------------------------ 시너지 */

.synergy-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.synergy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--s2);
  padding: 4px 6px;
  border-radius: var(--r1);
  border-left: 3px solid var(--type);
  background: color-mix(in srgb, var(--type) 10%, transparent);
  font-size: var(--t-micro);
  text-align: left;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  width: 100%;
  color: inherit;
}

.synergy-row[data-active="false"] {
  background: transparent;
  border-left-color: var(--line);
  color: var(--ink-faint);
}

.synergy-row:hover {
  background: color-mix(in srgb, var(--type) 20%, transparent);
}

.synergy-steps {
  display: flex;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  color: var(--ink-faint);
}

.synergy-steps b {
  color: var(--ink);
}

.synergy-count {
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* -------------------------------------------------------------- 역할 */

.role-row {
  display: grid;
  grid-template-columns: 76px 1fr 34px;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-micro);
}

.role-row > .n {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--ink-muted);
}

/* -------------------------------------------------------------- 하단 */

.dock {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.2fr);
  gap: var(--s3);
  padding: 0 var(--s3) var(--s3);
  height: var(--dock-h);
}

.dock[data-collapsed="true"] {
  height: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.bench-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: var(--s2);
  align-content: start;
}

.bench-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 80px;
  color: var(--ink-faint);
  font-size: var(--t-micro);
  text-align: center;
}

.draw-block {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.odds {
  display: flex;
  gap: 1px;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--surface-3);
}

.odds > span {
  display: block;
}

.odds-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s3);
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  color: var(--ink-faint);
}

.research-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-micro);
}

.pips {
  display: flex;
  gap: 2px;
}

.pips > i {
  width: 9px;
  height: 5px;
  border-radius: 1px;
  background: var(--surface-3);
}

.pips > i[data-on="true"] {
  background: var(--signal);
}

/* ------------------------------------------------------------- 상세 */

.detail-head {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.detail-title {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-title);
  line-height: 1.2;
}

.slot-badge {
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r1);
  color: var(--ink-muted);
}

.kv {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 2px var(--s2);
  font-size: var(--t-micro);
}

.kv > dt {
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: var(--t-eyebrow);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 1px;
}

.kv > dd {
  margin: 0;
}

.equip-row {
  display: flex;
  gap: var(--s2);
}

.equip-slot {
  flex: 1;
  aspect-ratio: 1;
  border: 1px dashed var(--line);
  border-radius: var(--r2);
  display: grid;
  place-items: center;
  font-size: var(--t-eyebrow);
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

.equip-slot[data-kind="berry"] {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--signal) 40%, transparent);
  color: color-mix(in srgb, var(--signal) 70%, var(--ink-faint));
}

.empty-detail {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s5) var(--s3);
  text-align: center;
  color: var(--ink-faint);
  font-size: var(--t-micro);
}

/* ------------------------------------------------------------- 테스트실 */

.lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
}

.lab-grid .btn {
  justify-content: center;
}

.field-input {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-micro);
}

.field-input input,
.field-input select {
  flex: 1;
  min-width: 0;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface-2);
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  font-size: var(--t-micro);
  padding: 3px 0;
}

.switch input {
  appearance: none;
  width: 32px;
  height: 18px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  position: relative;
  transition: background var(--dur) var(--ease);
  flex: none;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition:
    translate var(--dur) var(--ease),
    background var(--dur) var(--ease);
}

.switch input:checked {
  background: var(--signal-dim);
  border-color: var(--signal);
}

.switch input:checked::after {
  translate: 14px 0;
  background: var(--signal);
}

/* ------------------------------------------------------------- 결과 */

.result {
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.result h2 {
  font-size: var(--t-display);
}

/* ------------------------------------------------------------- 반응형 */

@media (width < 1560px) {
  :root {
    --rail-w: 252px;
    --detail-w: 320px;
  }
}

@media (width < 1280px) {
  .main {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail,
  .detail {
    display: none;
  }

  .main[data-pane="rail"] .rail,
  .main[data-pane="detail"] .detail {
    display: flex;
    position: absolute;
    z-index: 30;
    top: calc(var(--topbar-h) + var(--s3));
    bottom: calc(var(--dock-h) + var(--s3));
    width: min(340px, calc(100vw - 32px));
    padding: var(--s3);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r3);
    box-shadow: var(--shadow-pop);
  }

  .main[data-pane="rail"] .rail {
    left: var(--s3);
  }

  .main[data-pane="detail"] .detail {
    right: var(--s3);
  }

  .dock {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .dock > .panel:nth-child(3) {
    display: none;
  }
}

.pane-toggles {
  display: none;
  gap: var(--s2);
}

@media (width < 1280px) {
  .pane-toggles {
    display: flex;
  }
}

/* A round-start weather label never obscures the board. Reduced-motion is global. */
.weather-hud {
  font-size: 12px;
  color: var(--ink-muted);
  animation: weather-reveal 300ms ease-out;
}
@keyframes weather-reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Visible before the large Pokémon/skill module graph finishes loading. */
.startup-card {
  width: min(90vw, 32rem);
  margin: 12vh auto;
  padding: 2rem;
  border: 1px solid var(--line, #45505e);
  border-radius: 12px;
  background: var(--surface, #18202b);
  color: var(--ink, #edf3f8);
  font:
    16px / 1.7 system-ui,
    sans-serif;
  text-align: center;
}
.startup-card h1 {
  font-size: 1.4rem;
  margin: 0 0 1.2rem;
}
.startup-card progress {
  width: 100%;
  height: 8px;
  accent-color: #e6bd58;
}
.startup-card .startup-hint {
  font-size: 0.85rem;
  opacity: 0.65;
}
.startup-card [hidden] {
  display: none;
}
