html, body {
  margin: 0;
  padding: 0;
  background: #000;
  overflow: hidden;
  font-family: ui-monospace, monospace;
  color: #9ae6b4;
  width: 100%;
  height: 100%;
}

*:focus,
*:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.hidden {
  display: none !important;
}

#ui {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#game-wrap {
  position: fixed;
  inset: 0;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  touch-action: none;
}

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

#topbar {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 9999;
  display: flex;
  gap: 6px;
  align-items: center;
}

#spawnBtn,
#teamSelect,
#weaponSelect,
.ui-btn {
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #1a3;
  color: #9ae6b4;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  cursor: pointer;
}

#spawnBtn:hover,
.ui-btn:hover {
  filter: brightness(1.25);
}

.ui-btn.is-active {
  background: rgba(20, 110, 55, 0.35);
  border-color: #2ad26f;
  color: #b9ffcf;
}

.world-time-box {
  position: fixed;
  top: 44px;
  left: 8px;
  width: 176px;
  padding: 6px 8px;
  border: 1px solid #1a3;
  background: rgba(0, 0, 0, 0.28);
  font-size: 11px;
  line-height: 1.4;
  z-index: 9998;
}

.world-time-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.world-time-label {
  color: #6fbd84;
}

.battle-panel {
  position: fixed;
  left: 8px;
  bottom: 8px;
  width: 230px;
  min-height: 126px;
  padding: 8px;
  border: 1px solid #1a3;
  background: rgba(6, 18, 12, 0.88);
  backdrop-filter: blur(3px);
  font-size: 11px;
  line-height: 1.4;
  z-index: 9998;
}

.battle-panel-title {
  margin-bottom: 8px;
  color: #9ae6b4;
  text-transform: lowercase;
}

.battle-panel-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.units-panel {
  position: fixed;
  left: 265px;
  right: 248px;
  bottom: 8px;
  min-height: 126px;
  padding: 8px 12px;
  border: 1px solid #1a3;
  background: rgba(6, 18, 12, 0.88);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 9997;
}

.unit-card {
  width: 112px;
  min-width: 112px;
  height: 114px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid #1a3;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  box-sizing: border-box;
}

.unit-card:hover {
  filter: brightness(1.12);
}

.unit-card.is-active {
  background: rgba(20, 110, 55, 0.35);
  border-color: #2ad26f;
  color: #b9ffcf;
}

.unit-card-thumb {
  width: 68px;
  height: 68px;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  user-select: none;
}

.unit-card-name {
  width: 100%;
  text-align: center;
  font-size: 10px;
  line-height: 1.2;
  color: #9ae6b4;
  word-break: break-word;
  pointer-events: none;
  user-select: none;
}

.pawn-panel {
  position: fixed;
  right: 8px;
  bottom: 8px;
  width: 210px;
  min-height: 126px;
  padding: 8px;
  border: 1px solid #1a3;
  background: rgba(0, 0, 0, 0.32);
  font-size: 11px;
  z-index: 9998;
}

.pawn-panel.hidden {
  display: none;
}

.pawn-panel-head {
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(34, 170, 51, 0.35);
  padding-bottom: 4px;
}

.pawn-panel-body {
  display: block;
}

.pawn-panel-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pawn-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.pawn-label {
  color: #6fbd84;
}

#kofi-topbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0;
  text-decoration: none;
}

#kofi-topbar img {
  display: block;
  height: 18px;
  width: auto;
  filter: hue-rotate(90deg) brightness(0.8) saturate(1.6);
}

#kofi-topbar:hover img {
  filter: hue-rotate(90deg) brightness(1) saturate(1.8);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 12000;
}

.modal-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 320px;
  max-width: calc(100vw - 24px);
  transform: translate(-50%, -50%);
  border: 1px solid #1a3;
  background: rgba(6, 18, 12, 0.96);
  padding: 10px;
  z-index: 12001;
}

.modal-title {
  margin-bottom: 10px;
  color: #9ae6b4;
  font-size: 12px;
  text-transform: lowercase;
}

.modal-field {
  display: block;
  margin-bottom: 8px;
}

.modal-label {
  display: block;
  margin-bottom: 4px;
  color: #6fbd84;
  font-size: 11px;
}

.modal-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #1a3;
  color: #9ae6b4;
  font-size: 11px;
  font-family: ui-monospace, monospace;
}

.modal-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* unit info modal */

.unit-info-modal {
  width: 420px;
  max-width: calc(100vw - 24px);
  padding: 14px;
  border: 1px solid #2ad26f;
  background: rgba(4, 14, 10, 0.98);
}

.unit-info-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.unit-info-image-wrap {
  width: 104px;
  min-width: 104px;
  height: 104px;
  border: 1px solid rgba(42, 210, 111, 0.24);
  background: rgba(0, 0, 0, 0.26);
  display: flex;
  align-items: center;
  justify-content: center;
}

.unit-info-image {
  width: 86px;
  height: 86px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.unit-info-main {
  min-width: 0;
  flex: 1;
}

.unit-info-title {
  margin-bottom: 10px;
  color: #d7ffe4;
  font-size: 16px;
  line-height: 1.2;
}

.unit-info-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* battle result modal */

#battleResultModal {
  width: 380px;
  max-width: calc(100vw - 24px);
  padding: 14px;
  border: 1px solid #2ad26f;
  background: rgba(4, 14, 10, 0.98);
}

#battleResultModal .modal-title {
  margin: 0 0 8px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(42, 210, 111, 0.28);
  color: #b9ffcf;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.result-outcome-box {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(42, 210, 111, 0.24);
  background: rgba(0, 0, 0, 0.28);
}

.result-outcome-label {
  margin-bottom: 4px;
  color: #6fbd84;
  font-size: 10px;
  text-transform: lowercase;
}

.result-outcome-value {
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0.08em;
  color: #d7ffe4;
  text-transform: uppercase;
}

.result-outcome-value.is-victory {
  color: #b9ffcf;
}

.result-outcome-value.is-defeat {
  color: #ff8f8f;
}

.result-outcome-value.is-draw {
  color: #ffe89a;
}

.result-section {
  margin-bottom: 10px;
  padding: 9px 10px 8px 10px;
  border: 1px solid rgba(42, 210, 111, 0.18);
  background: rgba(0, 0, 0, 0.22);
}

.result-section-title {
  margin-bottom: 8px;
  color: #86d69d;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 16px;
}

.result-label {
  color: #6fbd84;
  font-size: 11px;
  white-space: nowrap;
}

.result-value {
  color: #d7ffe4;
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

#battleResultModal .modal-actions,
.unit-info-modal .modal-actions {
  margin-top: 12px;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid rgba(42, 210, 111, 0.2);
}

#battleResultOkBtn,
#unitInfoDeployBtn,
#unitInfoCloseBtn {
  min-width: 74px;
}

@media (max-width: 1100px) {
  .battle-panel {
    width: 205px;
  }

  .units-panel {
    left: 240px;
    right: 225px;
  }

  .pawn-panel {
    width: 187px;
  }

  .unit-card {
    width: 102px;
    min-width: 102px;
    height: 106px;
  }

  .unit-card-thumb {
    width: 60px;
    height: 60px;
  }
}

@media (max-width: 900px) {
  #topbar {
    top: 6px;
    left: 6px;
  }

  #kofi-topbar {
    height: 14px;
  }

  #kofi-topbar img {
    height: 14px;
  }

  .world-time-box {
    top: 28px;
    left: 6px;
    width: 150px;
    padding: 5px 6px;
    font-size: 9px;
    line-height: 1.3;
  }

  .battle-panel {
    left: 6px;
    bottom: 6px;
    width: 180px;
    min-height: 112px;
    padding: 6px;
    font-size: 10px;
  }

  .battle-panel-title {
    margin-bottom: 6px;
    font-size: 10px;
  }

  .battle-panel-actions {
    gap: 4px;
  }

  #spawnBtn,
  #teamSelect,
  #weaponSelect,
  .ui-btn {
    padding: 4px 6px;
    font-size: 10px;
  }

  .units-panel {
    left: 200px;
    right: 176px;
    bottom: 6px;
    min-height: 112px;
    padding: 6px 8px;
    gap: 10px;
  }

  .unit-card {
    width: 88px;
    min-width: 88px;
    height: 96px;
    padding: 5px;
  }

  .unit-card-thumb {
    width: 50px;
    height: 50px;
  }

  .unit-card-name {
    font-size: 9px;
  }

  .pawn-panel {
    right: 6px;
    bottom: 6px;
    width: 152px;
    min-height: 112px;
    max-width: calc(100vw - 12px);
    padding: 6px;
    font-size: 10px;
  }

  .modal-panel {
    width: 280px;
    padding: 8px;
  }

  #battleResultModal,
  .unit-info-modal {
    width: 300px;
    padding: 10px;
  }

  .result-outcome-box {
    padding: 8px 9px;
  }

  .result-outcome-value {
    font-size: 18px;
  }

  .result-section {
    padding: 8px;
  }

  .result-row {
    gap: 10px;
  }

  .result-label,
  .result-value {
    font-size: 10px;
  }

  .unit-info-top {
    gap: 10px;
  }

  .unit-info-image-wrap {
    width: 82px;
    min-width: 82px;
    height: 82px;
  }

  .unit-info-image {
    width: 68px;
    height: 68px;
  }

  .unit-info-title {
    font-size: 13px;
  }
}

.unit-info-top{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
}

.unit-info-main{
  width:100%;
}

.unit-info-title{
  text-align:center;
  margin-bottom:6px;
}

.unit-info-image-wrap{
  width:220px;
  height:220px;
}

.unit-info-image{
  width:100%;
  height:100%;
  object-fit:contain;
  image-rendering:pixelated;
}
