:root {
  --bg: #efe7db;
  --text: #fff8ef;
  --muted: rgba(255, 248, 239, 0.72);
  --accent: #ff8f5c;
  --accent-strong: #ff6f3c;
  --border: rgba(255, 255, 255, 0.12);
  --panel: rgba(26, 30, 35, 0.88);
  --panel-strong: rgba(20, 23, 29, 0.95);
  --shadow: 0 24px 60px rgba(42, 31, 15, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 184, 108, 0.65), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 111, 60, 0.18), transparent 24%),
    linear-gradient(135deg, #f6efdf 0%, #ebdcc2 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
}

.map-stage {
  position: relative;
  min-height: 100vh;
  padding: 0;
}

.map-canvas {
  width: 100%;
  height: 100vh;
  min-height: 560px;
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.45)),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.25),
      rgba(255, 255, 255, 0.25) 10px,
      rgba(244, 212, 184, 0.35) 10px,
      rgba(244, 212, 184, 0.35) 20px
    );
}

.top-ui {
  position: absolute;
  top: 1.2rem;
  left: 1.2rem;
  z-index: 5;
  display: grid;
  gap: 0.75rem;
  max-width: min(92vw, 640px);
}

.top-ui[hidden] {
  display: none;
}

.top-capsule,
.floating-panel,
.map-context-menu {
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
}

.top-capsule {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  border-radius: 999px;
  background:
    linear-gradient(160deg, rgba(255, 143, 92, 0.15), rgba(255, 255, 255, 0.05)),
    var(--panel);
}

.floating-panel {
  position: absolute;
  min-width: 280px;
  padding: 0.95rem;
  border-radius: 20px;
  background: var(--panel-strong);
  color: var(--text);
}

.settings-popover {
  top: calc(100% + 0.2rem);
  left: 0;
  width: min(320px, calc(100vw - 2.4rem));
}

.import-popover {
  top: calc(100% + 0.2rem);
  left: 0;
  width: min(420px, calc(100vw - 2.4rem));
}

.help-popover {
  position: fixed;
  top: 50vh;
  left: 50vw;
  width: min(75vw, 1080px);
  max-width: calc(100vw - 2rem);
  max-height: min(75vh, 820px);
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: 1.15rem 1.15rem 1.25rem;
  z-index: 7;
}

.floating-status {
  max-width: 360px;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  background: rgba(162, 16, 16, 0.9);
  color: #fff4ef;
  line-height: 1.4;
}

.floating-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.floating-panel-header h2,
.popup-title {
  font-size: 1rem;
  font-weight: 700;
}

.popup-subtitle,
.helper-text,
.popup-label {
  color: var(--muted);
}

.popup-heading {
  display: grid;
  gap: 0.2rem;
}

.help-content {
  display: grid;
  gap: 1rem;
}

.help-steps-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.help-section {
  display: grid;
  gap: 0.45rem;
}

.help-section-purpose {
  padding-bottom: 0.25rem;
}

.help-section-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
}

.help-image-placeholder {
  min-height: 150px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
  padding: 1rem;
}

.help-popover::-webkit-scrollbar {
  width: 12px;
}

.help-popover::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.help-popover::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255, 143, 92, 0.65), rgba(255, 255, 255, 0.2));
  border-radius: 999px;
  border: 2px solid rgba(20, 23, 29, 0.95);
}

.help-popover {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 143, 92, 0.7) rgba(255, 255, 255, 0.04);
}

.popup-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.language-picker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.language-dropdown {
  position: relative;
  width: 3rem;
  height: 3rem;
}

.language-dropdown-button,
.language-option-button,
.top-icon-button {
  width: 3rem;
  height: 3rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.08)),
    rgba(8, 10, 14, 0.32);
  color: var(--text);
  cursor: pointer;
}

.top-icon-button {
  font-size: 1.2rem;
}

.language-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  display: grid;
  gap: 0.35rem;
  padding: 0.45rem;
  border-radius: 18px;
  background: rgba(24, 24, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(12px);
}

.language-dropdown-menu[hidden] {
  display: none;
}

.language-option-button.active {
  border-color: rgba(255, 209, 189, 0.38);
  background:
    linear-gradient(180deg, rgba(255, 143, 92, 0.28), rgba(255, 255, 255, 0.08)),
    rgba(8, 10, 14, 0.32);
}

.language-flag-icon {
  width: 2.15rem;
  height: 2.15rem;
  display: block;
  border-radius: 999px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.flag-en {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%3E%3Crect%20width='64'%20height='64'%20fill='%23012169'/%3E%3Cpath%20d='M0%200%2064%2064M64%200%200%2064'%20stroke='%23FFFFFF'%20stroke-width='18'/%3E%3Cpath%20d='M0%200%2064%2064M64%200%200%2064'%20stroke='%23C8102E'%20stroke-width='8'/%3E%3Cpath%20d='M32%200V64M0%2032H64'%20stroke='%23FFFFFF'%20stroke-width='24'/%3E%3Cpath%20d='M32%200V64M0%2032H64'%20stroke='%23C8102E'%20stroke-width='12'/%3E%3C/svg%3E");
}

.flag-ja {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%3E%3Crect%20width='64'%20height='64'%20fill='%23FFFFFF'/%3E%3Ccircle%20cx='32'%20cy='32'%20r='18'%20fill='%23BC002D'/%3E%3C/svg%3E");
}

.flag-fr {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%3E%3Crect%20width='21.34'%20height='64'%20x='0'%20y='0'%20fill='%230055A4'/%3E%3Crect%20width='21.34'%20height='64'%20x='21.33'%20y='0'%20fill='%23FFFFFF'/%3E%3Crect%20width='21.34'%20height='64'%20x='42.66'%20y='0'%20fill='%23EF4135'/%3E%3C/svg%3E");
}

.field {
  display: grid;
  gap: 0.42rem;
  margin-bottom: 0.8rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field span {
  font-size: 0.9rem;
}

.import-form {
  display: grid;
  gap: 0.85rem;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.import-preview {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.import-preview[hidden] {
  display: none;
}

.import-preview-header {
  display: grid;
  gap: 0.2rem;
}

.import-preview-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
  max-height: 220px;
  overflow: auto;
}

.import-preview-list li {
  display: grid;
  gap: 0.16rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.import-preview-name {
  font-size: 0.92rem;
  color: var(--text);
}

.import-preview-meta {
  font-size: 0.76rem;
  color: var(--muted);
}

.import-secondary-button {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.color-field {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 0.72rem 0.85rem;
  background: rgba(8, 10, 14, 0.36);
  color: var(--text);
}

input[type="color"] {
  width: 54px;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.color-field input[type="text"] {
  flex: 1;
}

.map-search-form {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: min(360px, 56vw);
}

#mapSearchInput {
  width: min(280px, 42vw);
  padding: 0.52rem 0.72rem;
  border: 1px solid rgba(32, 36, 45, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: #20242d;
  font-size: 1rem;
  box-shadow: 0 10px 28px rgba(32, 36, 45, 0.14);
}

#mapSearchInput::placeholder {
  color: rgba(32, 36, 45, 0.55);
}

.map-search-button,
.context-menu-button,
.icon-button {
  border: none;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.map-search-button {
  border-radius: 12px;
  padding: 0.52rem 0.72rem;
  background: #20242d;
  color: #fff8ef;
  font-size: 0.95rem;
}

.map-search-icon-button {
  width: 2.55rem;
  height: 2.55rem;
  display: inline-grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: #20242d;
  color: #fff8ef;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.map-search-icon-button svg {
  width: 1.15rem;
  height: 1.15rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-search-icon-button[hidden] {
  display: none;
}

.map-context-menu {
  position: absolute;
  z-index: 6;
  min-width: 176px;
  padding: 0.35rem;
  border-radius: 16px;
  background: rgba(24, 24, 24, 0.94);
}

.context-menu-button {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-align: left;
}

.point-popup {
  z-index: 6;
  width: min(320px, calc(100vw - 2.4rem));
}

.ad-tray {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 4;
  width: min(560px, calc(100vw - 2rem));
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.ad-tray[hidden],
.ad-tray-expanded[hidden],
.ad-tray-collapsed[hidden] {
  display: none;
}

.ad-tray-expanded,
.ad-tray-collapsed {
  pointer-events: auto;
}

.ad-tray-expanded {
  width: 100%;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.8rem 0.9rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 248, 239, 0.92);
  box-shadow: 0 14px 30px rgba(32, 36, 45, 0.18);
  color: #20242d;
}

.ad-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.ad-badge {
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: rgba(32, 36, 45, 0.08);
  color: #20242d;
  font-size: 0.78rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.ad-text {
  min-width: 0;
  display: grid;
  gap: 0.18rem;
}

.ad-headline {
  font-size: 0.98rem;
  font-weight: 700;
  color: #20242d;
}

.ad-description {
  font-size: 0.84rem;
  line-height: 1.35;
  color: rgba(32, 36, 45, 0.72);
}

.ad-toggle-button {
  background: rgba(32, 36, 45, 0.08);
  color: #20242d;
}

.ad-tray-collapsed {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  background: rgba(255, 248, 239, 0.92);
  color: #20242d;
  font-weight: 700;
  box-shadow: 0 14px 30px rgba(32, 36, 45, 0.18);
  cursor: pointer;
}

.top-icon-button[hidden],
.language-dropdown-button[hidden],
.language-option-button[hidden] {
  display: none;
}

.popup-detail {
  display: grid;
  gap: 0.25rem;
}

.popup-value {
  font-size: 0.95rem;
  color: var(--text);
}

.point-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

.icon-button {
  width: 2.2rem;
  height: 2.2rem;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  flex: 0 0 auto;
}

.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.confirm-button {
  background: rgba(67, 160, 71, 0.3);
}

.danger-button {
  background: rgba(162, 16, 16, 0.3);
}

.map-search-button:hover,
.map-search-icon-button:hover,
.context-menu-button:hover,
.icon-button:hover,
.language-dropdown-button:hover,
.language-option-button:hover,
.top-icon-button:hover {
  transform: translateY(-1px);
}

.map-point-marker {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #20242d;
  border: 4px solid #ff8f5c;
  color: #ffe7da;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 10px 24px rgba(32, 36, 45, 0.24);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.map-point-marker.circle-hidden {
  opacity: 0.5;
}

.map-point-marker.selected {
  background: #ff8f5c;
  border-color: #fff6e9;
  color: #ffffff;
}

.map-point-marker.hovered {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 14px 30px rgba(32, 36, 45, 0.32);
}

.search-result-marker {
  position: relative;
  width: 34px;
  height: 34px;
}

.search-result-marker::before,
.search-result-marker::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 4px;
  border-radius: 999px;
  background: #a21010;
  box-shadow: 0 0 0 2px rgba(255, 248, 239, 0.78);
  transform: translate(-50%, -50%);
}

.search-result-marker::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.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;
}

@media (max-width: 860px) {
  .map-canvas {
    height: 100vh;
    min-height: 480px;
  }

  .top-ui {
    top: 1rem;
    left: 1rem;
    max-width: calc(100vw - 2rem);
  }

  .top-capsule {
    flex-wrap: wrap;
    border-radius: 28px;
  }

  .map-search-form {
    min-width: 100%;
    width: 100%;
  }

  #mapSearchInput {
    width: 100%;
  }

  .help-popover {
    width: min(88vw, 760px);
    max-height: min(78vh, 760px);
  }

  .help-steps-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .map-canvas {
    height: 100vh;
    min-height: 420px;
  }

  .top-ui {
    top: 0.8rem;
    left: 0.8rem;
    max-width: calc(100vw - 1.6rem);
  }

  .top-capsule {
    gap: 0.55rem;
    padding: 0.6rem;
  }

  .settings-popover,
  .import-popover,
  .point-popup,
  .help-popover {
    width: min(320px, calc(100vw - 2rem));
  }

  .help-popover {
    max-height: min(80vh, 760px);
    padding: 1rem;
  }

  .ad-tray {
    width: calc(100vw - 1rem);
    bottom: 0.6rem;
  }

  .ad-tray-expanded {
    min-height: 64px;
    padding: 0.7rem 0.75rem;
    gap: 0.65rem;
  }

  .ad-copy {
    gap: 0.65rem;
  }

  .ad-description {
    font-size: 0.78rem;
  }
}
