:root {
  color-scheme: dark;
  font-family: Manrope, system-ui, sans-serif;
  color: #f1f6fc;
  background: #080f1d;
  --line: #2b405b;
  --panel: #121e30;
  --ocean: #101e34;
  --muted: #a9bed5;
  --cyan: #7fe3ff;
  --gold: #f2c77b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
p, h1 { margin: 0; }
button, input { font: inherit; }
a { color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled, input:disabled { opacity: .56; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; }

.shell { width: min(100% - 5rem, 85rem); margin-inline: auto; }
.site-header { border-bottom: 1px solid #24364f; }
.header-inner { min-height: 4rem; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-size: 1.125rem; font-weight: 700; letter-spacing: -.035em; text-decoration: none; }
.back-link { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .875rem; text-decoration: none; }
.back-link:hover, .map-notes a:hover { color: var(--cyan); }
.page-nav { display: flex; align-items: center; gap: 1rem; }
.current-page { color: var(--cyan); font-size: .875rem; font-weight: 700; }

.intro { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; padding-block: 2.5rem 1.5rem; }
h1 { font-size: clamp(2.25rem, 4vw, 4rem); font-weight: 700; line-height: 1.06; letter-spacing: -.065em; text-wrap: balance; }
.intro p { max-width: 43rem; margin-top: .75rem; font-size: 1rem; line-height: 1.5; color: var(--muted); text-wrap: pretty; }

.quiet-button, .main-button {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: .5rem .75rem;
  background: transparent;
  color: #d6e5f4;
  font-weight: 700;
  line-height: 1.35;
  transition: border-color .2s, background-color .2s, color .2s;
}
.quiet-button:hover:not(:disabled) { border-color: #587f9c; background: #192b42; color: #fff; }
.preset { font-size: .875rem; white-space: nowrap; }
.preset::before { content: ''; display: inline-block; width: .5rem; height: .5rem; margin: 0 .65rem .05rem .125rem; border-radius: 50%; background: var(--cyan); box-shadow: .33rem .08rem 0 -.08rem var(--gold); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  grid-template-rows: minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--panel);
}
.map-stage { grid-column: 1; grid-row: 1 / 3; position: relative; min-width: 0; min-height: clamp(32rem, 61vh, 39rem); overflow: hidden; border-radius: .6875rem 0 0 .6875rem; background: var(--ocean); }
#world-map { display: block; position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#world-map:focus-visible { outline-offset: -4px; }
#world-map.is-dragging { cursor: grabbing; }
#world-map.can-move-country { cursor: move; }
.projection-label, .coordinates, .map-label {
  position: absolute;
  padding: .375rem .625rem;
  border: 1px solid #33506d;
  border-radius: .375rem;
  background: #0c1729ed;
  color: #bdcfe2;
  font-size: .75rem;
  line-height: 1.35;
  pointer-events: none;
}
.projection-label { top: 1rem; left: 1rem; }
.coordinates { right: 1rem; bottom: 1rem; font-variant-numeric: tabular-nums; }
.map-label { z-index: 1; padding: .3rem .5rem; color: var(--country-color); border-color: color-mix(in srgb, var(--country-color) 43%, #263a53); white-space: nowrap; transform: translate(-50%, calc(-100% - .7rem)); }
.map-label.reference { transform: translate(-50%, .7rem); }
.map-controls {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 2;
  display: flex;
  gap: 1px;
  padding: 1px;
  border: 1px solid #33506d;
  border-radius: .5rem;
  background: #1b304a;
}
.map-controls button { width: 2.75rem; height: 2.75rem; border: 0; border-radius: .375rem; background: #0c1729; color: #e2effa; font-size: 1.25rem; line-height: 1; }
.map-controls button:hover:not(:disabled) { background: #233b57; color: white; }
.map-status { position: absolute; top: 50%; left: 50%; width: max-content; max-width: calc(100% - 2rem); padding: .75rem 1rem; border: 1px solid var(--line); border-radius: .5rem; background: #0c1729; color: #d5e7f7; transform: translate(-50%, -50%); }

.comparison { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 1.5rem; padding: 1.5rem; border-left: 1px solid var(--line); }
.moving { --country-color: var(--cyan); }
.reference { --country-color: var(--gold); }
.country-group label { display: flex; align-items: center; gap: .5rem; color: #c1d3e7; font-size: .875rem; font-weight: 700; }
.color-key { width: .625rem; height: .625rem; flex: none; border-radius: 50%; background: var(--country-color); }
.country-picker { position: relative; margin-top: .5rem; }
.country-picker::after { content: ''; position: absolute; top: 1.2rem; right: .9rem; width: .45rem; height: .45rem; border-right: 2px solid #9ab6d0; border-bottom: 2px solid #9ab6d0; transform: translateY(-30%) rotate(45deg); pointer-events: none; }
.country-picker input {
  width: 100%;
  min-height: 2.75rem;
  appearance: none;
  padding: .5rem 2rem .5rem .75rem;
  border: 1px solid #3a536e;
  border-radius: .5rem;
  background: #0b1729;
  color: #f1f6fc;
  font-size: 1rem;
  font-weight: 700;
}
.country-picker input:hover:not(:disabled) { border-color: var(--country-color); }
.country-options, .country-empty { position: absolute; z-index: 4; inset: calc(100% + .25rem) 0 auto; margin: 0; padding: .25rem; border: 1px solid #45617d; border-radius: .5rem; background: #13233a; color: #e6f0fc; font-size: .875rem; }
.country-options { list-style: none; max-height: min(20rem, 42dvh); overflow: auto; overscroll-behavior-y: contain; }
.country-options li { padding: .65rem .5rem; border-radius: .375rem; cursor: pointer; line-height: 1.3; overflow-wrap: anywhere; }
.country-options li:is(:hover, [aria-selected="true"]) { background: #24455f; color: #fff; }
.country-empty { padding: .625rem .5rem; color: var(--muted); }
.country-area { margin-top: .375rem; color: var(--country-color); font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result { padding-top: 1rem; border-top: 1px solid var(--line); }
.result-caption { color: var(--muted); font-size: .875rem; }
.result-text { margin-top: .375rem; font-size: 1.25rem; font-weight: 700; line-height: 1.25; letter-spacing: -.033em; text-wrap: pretty; }
.area-bars { display: grid; gap: .375rem; margin-top: .875rem; }
.area-bars span { display: block; width: 0; height: .25rem; background: var(--country-color); border-radius: .25rem; }
.actions { grid-column: 2; grid-row: 2; display: grid; gap: .5rem; padding: 0 1.5rem 1.5rem; border-left: 1px solid var(--line); }
.main-button { min-height: 2.875rem; border-color: var(--cyan); background: var(--cyan); color: #061823; }
.main-button:hover:not(:disabled) { border-color: #b3efff; background: #b3efff; }
.reset { font-size: .875rem; }
button:active:not(:disabled) { transform: translateY(1px); }

.map-notes { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-block: 1rem 2rem; color: var(--muted); font-size: .875rem; line-height: 1.5; }
.map-notes summary { cursor: pointer; color: #c6d9eb; }
.map-notes details p { max-width: 42rem; margin-top: .5rem; text-wrap: pretty; }
.map-notes a { flex: none; text-underline-offset: .2rem; text-decoration-color: #67839f; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 59rem) {
  .shell { width: calc(100% - 2rem); }
  .workspace { grid-template-columns: minmax(0, 1fr) 17rem; }
  .comparison { padding: 1rem; }
  .actions { padding: 0 1rem 1rem; }
  .intro { padding-block: 2rem 1.25rem; }
}

@media (max-width: 43rem) {
  .header-inner { min-height: 3.5rem; flex-wrap: wrap; column-gap: .625rem; }
  .page-nav { gap: .625rem; }
  .page-nav > * { font-size: .75rem; }
  .current-page { display: none; }
  .intro { display: grid; align-items: start; gap: .875rem; padding-top: 1.5rem; }
  .intro p { margin-top: .625rem; font-size: .9375rem; }
  .preset { justify-self: start; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; }
  .map-stage { min-height: clamp(20rem, 48svh, 30rem); }
  .map-stage { grid-row: 1; border-radius: .6875rem .6875rem 0 0; }
  .projection-label { top: .625rem; left: .625rem; }
  .map-controls { bottom: .625rem; left: .625rem; }
  .coordinates { right: .625rem; bottom: .625rem; }
  .comparison { grid-column: 1; grid-row: 3; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem .75rem; border-left: 0; border-top: 1px solid var(--line); }
  .result { grid-column: 1 / -1; }
  .actions { grid-column: 1; grid-row: 2; grid-template-columns: 1.15fr 1fr; padding: .75rem; border-left: 0; border-top: 1px solid var(--line); }
  .main-button { font-size: .875rem; }
  .country-group label { gap: .375rem; font-size: .75rem; }
  .country-picker input { padding-left: .5rem; }
  .map-notes { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
