:root {
  --ink: #17202a;
  --muted: #64717f;
  --line: #dce3ea;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --accent: #0f8b6f;
  --accent-dark: #096b55;
  --warn: #b64b2c;
  --shadow: 0 12px 34px rgba(21, 38, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 76px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 360px);
  gap: 20px;
  align-items: end;
  padding-bottom: 18px;
}

.title-block {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
}

.progress-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.progress-number {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

.progress-copy {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  height: 10px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf2;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #2f6fab);
  transition: width 180ms ease;
}

.controls,
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.quick-actions {
  margin-top: 10px;
  padding: 10px 14px;
}

.search-field,
.select-field,
.state-select,
.state-name {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-field {
  flex: 1 1 250px;
}

.select-field {
  flex: 0 1 260px;
}

.state-select {
  width: 100%;
}

.state-name {
  width: 100%;
}

.share-link {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 111, 0.15);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2f6;
}

.segment,
.tool-button,
.quick-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
}

.segment.is-active,
.tool-button,
.quick-actions button {
  color: #fff;
  background: var(--accent);
}

.tool-button:hover,
.quick-actions button:hover {
  background: var(--accent-dark);
}

.state-menu button:disabled,
.state-menu select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.state-menu {
  position: relative;
  flex: 0 0 250px;
  z-index: 30;
}

.state-menu details {
  position: relative;
}

.state-menu summary {
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: 6px;
  padding: 0 13px;
  color: #fff;
  background: #263746;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.state-menu summary::-webkit-details-marker {
  display: none;
}

.state-menu-body {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 10px;
  width: min(330px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.state-menu-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.state-menu-actions button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.state-menu-actions button:hover {
  background: var(--accent-dark);
}

.state-message {
  min-height: 20px;
  align-self: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.tool-button.secondary {
  color: #0c536b;
  background: #e7f4f8;
}

.tool-button.secondary:hover {
  background: #cfe9f1;
}

.tool-button.subtle {
  color: var(--warn);
  background: #fff0ea;
}

.actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.album {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.team-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.team-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f0f5f8;
}

.team-header h2 {
  margin: 0;
  font-size: 1.02rem;
}

.team-meta {
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  padding: 12px;
}

.sticker {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 9px;
  min-height: 58px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.sticker:hover {
  border-color: var(--accent);
}

.sticker.is-collected {
  border-color: rgba(15, 139, 111, 0.38);
  background: #eef9f5;
}

.sticker-code {
  align-self: start;
  border-radius: 5px;
  padding: 5px 4px;
  color: #fff;
  background: #263746;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.sticker.is-collected .sticker-code {
  background: var(--accent);
}

.sticker-name {
  display: block;
  font-weight: 700;
  line-height: 1.2;
}

.sticker-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state {
  margin-top: 18px;
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.site-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(247, 249, 251, 0.94);
  backdrop-filter: blur(8px);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration-color: currentColor;
  text-underline-offset: 3px;
}

.print-sheet {
  display: none;
}

.sort-dialog {
  width: min(1240px, calc(100% - 28px));
  max-height: calc(100vh - 56px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sort-dialog::backdrop {
  background: rgba(23, 32, 42, 0.38);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f0f5f8;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  font-size: 1.4rem;
  line-height: 1;
}

.dialog-close:hover {
  background: #e7edf2;
}

.sort-dialog-body {
  display: grid;
  grid-template-columns: minmax(390px, 1fr) minmax(110px, 0.3fr) minmax(310px, 0.8fr) minmax(280px, 0.75fr);
  gap: 10px;
  padding: 12px;
}

.sort-panel h3 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sort-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.sort-list p {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0;
  min-height: 74px;
  padding: 7px;
  border: 2px solid #c9d5de;
  border-radius: 7px;
  font-size: 0.74rem;
  line-height: 1.2;
  background: #fff;
}

.pile-card::after {
  content: attr(data-countries);
  position: absolute;
  right: 6px;
  bottom: calc(100% + 7px);
  left: 6px;
  z-index: 5;
  display: none;
  padding: 8px;
  border: 1px solid #b7c7d3;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 0.76rem;
  line-height: 1.25;
}

.pile-card:hover::after,
.pile-card:focus-within::after {
  display: block;
}

.pile-heading {
  display: inline-flex;
  align-items: center;
  margin-bottom: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: #0c536b;
  box-shadow: 0 2px 0 #ffd34d;
}

.pile-heading strong {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
}

.letter-piles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.letter-piles span {
  display: grid;
  place-items: center;
  min-height: 28px;
  border: 2px solid #c9d5de;
  border-radius: 7px;
  color: #fff;
  background: #263746;
  font-weight: 800;
  box-shadow: inset 0 -3px 0 #ffd34d;
}

.team-letter-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}

.team-letter-card {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 5px;
  align-items: start;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 0.68rem;
  line-height: 1.12;
}

.team-letter-card span {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.team-letter-card strong {
  display: grid;
  place-items: center;
  min-height: 20px;
  border-radius: 5px;
  color: #fff;
  background: #0c536b;
  font-size: 0.72rem;
}

.team-code {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--ink);
  background: #eef3f6;
  font-weight: 800;
}

.album-order-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(24, minmax(0, auto));
  grid-auto-flow: column;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: album-team;
}

.album-order-list li {
  counter-increment: album-team;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 5px;
  align-items: center;
  min-height: 22px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 0.76rem;
  line-height: 1.12;
}

.album-order-list li::before {
  content: counter(album-team);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
    padding-bottom: 76px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .title-block {
    display: grid;
  }

  .state-menu {
    width: 100%;
    flex-basis: auto;
  }

  .state-menu-body {
    right: auto;
    left: 0;
    width: 100%;
  }

  .actions,
  .tool-button {
    width: 100%;
  }

  .actions {
    margin-left: 0;
  }

  .sticker-grid {
    grid-template-columns: 1fr;
  }

  .sort-dialog-body {
    grid-template-columns: 1fr;
  }

  .sort-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .letter-piles {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .team-letter-list {
    grid-template-columns: 1fr;
  }
}

@page {
  size: A4 portrait;
  margin: 8mm;
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    display: none;
  }

  .site-footer {
    display: none;
  }

  .print-sheet {
    display: block;
    color: #111;
    font-family: Arial, Helvetica, sans-serif;
  }

  .print-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    border-bottom: 1px solid #111;
    padding-bottom: 3mm;
    margin-bottom: 3mm;
  }

  .print-title h1 {
    font-size: 15pt;
  }

  .print-title p {
    margin: 0;
    font-size: 8pt;
  }

  .print-groups {
    column-count: 3;
    column-gap: 5mm;
    font-size: 6.8pt;
    line-height: 1.22;
  }

  .print-group {
    break-inside: avoid;
    margin: 0 0 2.2mm;
  }

  .print-group h2 {
    margin: 0 0 0.5mm;
    font-size: 7.6pt;
    line-height: 1.1;
  }

  .print-group p {
    margin: 0;
  }
}
