:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2a37;
  --line: #d0d7e2;
  --accent: #1359a4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

main {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 64px);
  overflow: hidden;
}

aside {
  height: 100%;
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: var(--card);
  overflow-y: auto;
}

#map {
  width: 100%;
  height: 100%;
}

#map-stage {
  position: relative;
  width: 100%;
  height: 100%;
}

button {
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

#init-caposaldi-btn.caposaldi-btn-confirm {
  background: #ffe8b5;
  border-color: #d48b00;
  color: #5a3a00;
  font-weight: 600;
}

#init-caposaldi-btn.caposaldi-btn-locked {
  background: #e7f7ea;
  border-color: #2d8a3f;
  color: #1d5d2a;
  font-weight: 600;
  cursor: not-allowed;
}

#status {
  white-space: pre-wrap;
  background: #eef3fa;
  padding: 0.6rem;
  border-radius: 4px;
}

input {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.25rem;
  margin-bottom: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
}

select {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.25rem;
  margin-bottom: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 0.8rem;
}

.auth-card {
  max-width: 420px;
  margin: 2rem auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.list-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 0.6rem;
  background: #fff;
}

.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 44px);
  gap: 0.35rem;
}

.ctrl-btn {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 44px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
}

.dpad-btn {
  background: #f6f9ff;
  border-color: #b9c9df;
}

.dpad-btn:active {
  background: #e7f0ff;
}

.dpad-gap {
  pointer-events: none;
}

.dpad-center {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d7deea;
  border-radius: 9px;
  color: #7f8b9c;
  background: #fbfcfe;
  font-size: 1rem;
}

.zoom-stack {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 0.35rem;
}

.zoom-btn {
  background: #eef7f0;
  border-color: #adc9b2;
  font-size: 1.35rem;
}

.zoom-btn:active {
  background: #ddf0e2;
}

.map-nav-controls {
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 900;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d4dbe7;
  border-radius: 12px;
  padding: 0.55rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

#caposaldi-list {
  margin-top: 0.8rem;
}

.section-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 0.8rem;
  margin-top: 0.8rem;
}

.section-card h3 {
  margin-top: 0;
}

.hidden {
  display: none;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.inline-check input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.inline-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.selected-row {
  border-color: var(--accent);
  background: #eef6ff;
}

.map-symbol-icon {
  background: transparent;
  border: none;
}

.symbol-wrap {
  width: 56px;
  height: 56px;
  transform-origin: center center;
  border-radius: 10px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}

.symbol-wrap img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  pointer-events: none;
}

.symbol-quiete {
  border-color: #2a9d8f;
}

.symbol-impact {
  border-color: #d00000;
  box-shadow: 0 0 0 2px rgba(208, 0, 0, 0.2);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1400;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  padding: 1rem;
}

.modal-card h3 {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal-actions button {
  width: auto;
  margin-bottom: 0;
  min-width: 110px;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  main {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  aside {
    border-right: none;
    border-bottom: 1px solid var(--line);
    height: auto;
  }

  #map {
    height: 65vh;
  }

  #map-stage {
    height: 65vh;
  }

  .map-nav-controls {
    top: auto;
    bottom: 0.8rem;
    right: 0.8rem;
    transform: none;
  }
}
