@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+KR:wght@400;500;700;800&display=swap');

:root {
  --bg-app: #101828;
  --surface: #1e2939;
  --surface-pressed: #253247;
  --border: #364153;
  --border-soft: #314158;
  --text-main: #ffffff;
  --text-muted: #d1d5dc;
  --text-sub: #99a1af;
  --red-main: #ff6467;
  --red-soft: #ffa2a2;
  --shadow-lg: 0 26px 65px rgba(2, 8, 22, 0.5);
  --font-family: "Inter", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius-xl: 30px;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 5px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100dvh;
  background: radial-gradient(circle at 18% 12%, #122041 0%, var(--bg-app) 55%);
  color: var(--text-main);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
}

.main-page {
  width: min(1400px, 100%);
  height: 100%;
  max-height: 100%;
}

.game-scene {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 864fr) minmax(0, 274fr);
  gap: 14px;
}

.left-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--left-under-row-height, 153px) minmax(0, 1fr);
  gap: 8px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
}

.map-panel {
  grid-row: 2;
  min-height: 0;
  max-height: none;
  box-shadow: var(--shadow-lg);
}

.map {
  width: 100%;
  height: 100%;
  position: relative;
  background: #070d23;
  border-radius: inherit;
}

.map image {
  image-rendering: -webkit-optimize-contrast;
}

.map-warning-toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: none;
  background: rgba(127, 29, 29, 0.92);
  border: 1px solid #f87171;
  color: #fee2e2;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 10px 28px rgba(127, 29, 29, 0.4);
}

.panel-actions {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.panel-actions-right {
  left: auto;
  right: 12px;
}

.map-panel:hover .panel-actions,
.map-panel:focus-within .panel-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ghost {
  border: 1px solid var(--border-soft);
  background: rgba(16, 24, 40, 0.84);
  color: var(--text-main);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
}

.ghost:hover {
  background: rgba(30, 41, 57, 0.96);
}

.ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.virus-toggle.is-active {
  border-color: #8ec5ff;
  color: #8ec5ff;
}

.left-under-panel {
  grid-row: 1;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.status-panel,
.vaccine-panel,
.timer-panel {
  border-radius: var(--radius-lg);
  height: 100%;
}

.status-panel {
  padding: 0;
  display: flex;
  flex-direction: column;
}

.status-cards {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.status-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

.status-value {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 600;
  line-height: 1;
}

.status-main {
  color: var(--text-main);
  font-size: clamp(36px, 4.2vw, 48px);
  font-weight: 700;
}

.status-slash,
.status-sub {
  color: var(--text-sub);
  font-size: clamp(20px, 2.2vw, 30px);
}

.status-card.warning .status-main {
  color: var(--red-main);
}

.status-card.warning .status-slash,
.status-card.warning .status-sub {
  color: var(--red-soft);
}

.result-banner {
  position: absolute;
  inset: auto 10px 10px;
  z-index: 50;
  border-radius: 10px;
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: #ffffff;
  background: rgba(255, 100, 103, 0.88);
  display: none;
}

.result-banner.show {
  display: block;
}

.vaccine-panel {
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.vaccine-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
}

.vaccine-cards {
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  padding: 10px 6px 8px;
}

.vaccine-card {
  min-width: 0;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  opacity: 0.45;
  filter: grayscale(0.3) saturate(0.45);
  transition: box-shadow 0.2s ease, transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.vaccine-card img {
  width: 26px;
  height: 27px;
  object-fit: contain;
}

.vaccine-card span {
  font-size: 14px;
  font-weight: 700;
}

.vaccine-card.subject-calculus span {
  color: #ff6467;
}

.vaccine-card.subject-physics span {
  color: #fdc700;
}

.vaccine-card.subject-chemistry span {
  color: #51a2ff;
}

.vaccine-card.subject-biology span {
  color: #7bf1a8;
}

.vaccine-card.is-developed {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.timer-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  grid-template-rows: minmax(0, 1fr) auto;
  column-gap: 6px;
  padding: 6px;
}

.timer-main {
  grid-column: 1;
  grid-row: 1 / span 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 4px;
  overflow: hidden;
}

.timer-stage {
  margin: 0;
  max-width: 100%;
  font-size: clamp(18px, 1.2vw, 21px);
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.timer-display {
  margin: 0;
  font-size: clamp(60px, 3.4vw, 70px);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.timer-phase-row,
.timer-resume-row {
  width: 96px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.timer-phase-row {
  grid-column: 2;
  grid-row: 1;
  align-content: center;
}

.timer-resume-row {
  grid-column: 2;
  grid-row: 2;
}

.timer-phase {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  padding: 4px 3px;
  font-family: var(--font-family);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: var(--radius-sm);
}

.timer-phase.is-active {
  background: var(--surface-pressed);
}

.timer-phase.is-hidden {
  display: none;
}

.timer-phase:hover {
  background: rgba(37, 50, 71, 0.9);
}

.timer-phase:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.right-panel {
  min-height: 0;
  display: grid;
  gap: 10px;
  grid-template-rows: repeat(6, minmax(0, 1fr));
}

.team-panel {
  border-radius: var(--radius-xl);
  padding: 10px;
  min-height: 0;
}

.team-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
}

.team-title {
  min-width: 0;
}

.team-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-gpa {
  min-width: 40px;
  border-radius: 5px;
  padding: 2px 6px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  background: #9f0712;
  color: #eaf2ff;
}

.team-card.team-ME .team-name {
  color: #ffa2a2;
}

.team-card.team-LS .team-name {
  color: #7bf1a8;
}

.team-card.team-BE .team-name {
  color: #fee685;
}

.team-card.team-PH .team-name {
  color: #ffb86a;
}

.team-card.team-AE .team-name {
  color: #8feff6;
}

.team-card.team-CS .team-name {
  color: #ffffff;
}

.team-cards {
  --chip-gap: 5px;
  --card-columns: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--chip-gap);
  flex: 1;
  min-height: 0;
  padding: 0 10px;
  overflow-x: auto;
  overflow-y: hidden;
}

.card-chip {
  width: calc(
    (100% - (var(--chip-gap) * (var(--card-columns) - 1))) / var(--card-columns)
  );
  height: 100%;
  min-width: 24px;
  max-width: 42px;
  aspect-ratio: 132 / 244;
  border-radius: 5px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  flex: 0 0 auto;
}

.card-chip.subject-calculus {
  background-color: #d2524c;
  background-image: url("../asset/img/card/ca.webp");
}

.card-chip.subject-physics {
  background-color: #eccd4b;
  background-image: url("../asset/img/card/ph.webp");
}

.card-chip.subject-chemistry {
  background-color: #6082ee;
  background-image: url("../asset/img/card/ch.webp");
}

.card-chip.subject-biology {
  background-color: #6bc16a;
  background-image: url("../asset/img/card/bi.webp");
}

.card-chip.card-empty {
  width: auto;
  max-width: none;
  min-width: 76px;
  aspect-ratio: auto;
  border-style: dashed;
  box-shadow: none;
  background: rgba(153, 161, 175, 0.1);
  color: #c0c8d5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
}

button {
  font-family: var(--font-family);
}

.primary {
  border: none;
  border-radius: 12px;
  background: #314158;
  color: #ffffff;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.primary:hover {
  background: #3f5575;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.action-form {
  display: grid;
  gap: 10px;
}

.action-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.action-form .is-hidden {
  display: none;
}

.action-form select,
.action-form input[type="number"] {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #101828;
  color: #ffffff;
  padding: 10px 12px;
}

.action-form input[type="number"] {
  width: 80px;
}

.target-building-picker {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.pick-building-btn {
  white-space: nowrap;
}

.target-building-display {
  font-size: 12px;
  color: var(--text-sub);
}

.target-building-display:not(.is-empty) {
  color: #8ec5ff;
  font-weight: 700;
}

.share-card-grid {
  display: grid;
  gap: 8px;
}

.share-card-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.share-card-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.share-step {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #101828;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.share-step:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-buttons {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.round-end-actions {
  grid-template-columns: 1fr;
}

.round-end-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-sub);
}

.log {
  max-height: 52vh;
  overflow: auto;
}

#activity-log {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

#activity-log li {
  border-left: 3px solid #8ec5ff;
  background: #101828;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #d1d5dc;
}

.feedback {
  min-height: 18px;
  margin-top: 8px;
  font-size: 12px;
  color: #96f7e4;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.graph {
  width: 100%;
  height: 100%;
  display: block;
}

.node-group {
  cursor: default;
}

.building-label {
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 700;
  fill: #ffffff;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.76);
  stroke-width: 2.5px;
}

.map.building-pick-active .building-label {
  cursor: default;
  fill: #ffffff;
}

.map.building-pick-active .building-label.is-selectable {
  cursor: pointer;
  fill: #fdc700;
}

.map.building-pick-active .building-label.is-selectable:hover {
  fill: #fff085;
}

.map.building-pick-active .building-label.building-barrier.is-selectable {
  fill: #ffb86a;
}

.building-label.building-barrier {
  fill: #f97316;
}

.building-label.building-warning {
  fill: #ff6467;
}

.building-label.building-warning.building-barrier {
  fill: #f97316;
}

.map.building-pick-active .building-label.building-warning.is-selectable {
  fill: #fdc700;
}

.map.building-pick-active .building-label.building-warning.is-selectable:hover {
  fill: #fff085;
}

.map.building-pick-active .building-label.building-warning.building-barrier.is-selectable {
  fill: #ffb86a;
}

.team-badge-img {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  cursor: pointer;
  pointer-events: all;
}

.team-acted {
  opacity: 0.5;
  filter: grayscale(0.8);
}

.virus-icon {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.virus-removal-active .virus-icon {
  pointer-events: all;
  cursor: pointer;
}

.map.virus-pick-active .virus-icon {
  opacity: 0.22;
  filter: grayscale(0.6);
  pointer-events: none;
}

.map.virus-pick-active .virus-icon.is-selectable {
  opacity: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.42)) brightness(1.12);
  pointer-events: all;
  cursor: pointer;
}

.map.virus-pick-active .virus-icon.is-selectable:hover {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.42)) brightness(1.24);
}

@media (max-width: 860px) {
  html,
  body {
    height: auto;
    overflow-y: auto;
  }

  body {
    min-height: 100dvh;
  }

  #app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    align-items: flex-start;
  }

  .game-scene {
    height: auto;
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .left-panel {
    height: auto;
    grid-template-rows: auto minmax(360px, 58dvh);
  }

  .left-under-panel {
    height: auto;
    grid-template-columns: 1fr;
  }

  .status-panel,
  .vaccine-panel,
  .timer-panel {
    min-height: 152px;
  }

  .right-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(120px, auto));
  }
}

@media (max-width: 540px) {
  #app {
    padding: 10px;
  }

  .panel-actions {
    position: static;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    margin: 8px;
    flex-wrap: wrap;
  }

  .map-panel {
    display: flex;
    flex-direction: column;
  }

  .map {
    min-height: 340px;
  }

  .right-panel {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, minmax(120px, auto));
  }
}
