@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400;500;600;700&family=VT323&display=swap');

:root {
  color-scheme: light;
  --ink: #3e2723;
  --muted: #6d4c41;
  --line: #8b6914;
  --paper: #f4e4bc;
  --panel: #faf0d4;
  --accent: #c8205c;
  --accent-dark: #8b1538;
  --gold: #d4a017;
  --gold-light: #f5c842;
  --gold-dark: #6b4f0e;
  --warn: #c2410c;
  --shadow: 0 4px 0 rgba(62, 39, 35, 0.25), 0 8px 24px rgba(62, 39, 35, 0.18);
  --pixel-font: 'Pixelify Sans', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top left, rgba(212, 160, 23, 0.08), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(200, 32, 92, 0.05), transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1, h2, h3, .eyebrow {
  font-family: var(--pixel-font);
  letter-spacing: 0.01em;
}

button,
input {
  font: inherit;
}

button {
  border: 2px solid var(--gold-dark);
  background: linear-gradient(180deg, #fdf3d4 0%, #f0d99a 100%);
  color: var(--ink);
  border-radius: 4px;
  cursor: pointer;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 700;
  font-family: var(--pixel-font);
  font-size: 0.98rem;
  box-shadow: 0 2px 0 var(--gold-dark);
  transition: transform 0.05s, box-shadow 0.05s;
}

button:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fef7e0 0%, #f5c842 100%);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--gold-dark);
}

.primary-button {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent-dark);
  color: #ffffff;
  box-shadow: 0 2px 0 #5d0a23;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
}

.primary-button:hover {
  background: linear-gradient(180deg, #e0317a 0%, var(--accent) 100%);
  border-color: var(--accent-dark);
}

.primary-button:active {
  box-shadow: 0 0 0 #5d0a23;
}

[hidden] {
  display: none !important;
}

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(212, 160, 23, 0.15), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(200, 32, 92, 0.08), transparent 60%),
    var(--paper);
  overflow-y: auto;
}

.onboarding-panel {
  width: min(620px, 100%);
  background: var(--panel);
  border: 3px solid var(--gold-dark);
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 28px;
  position: relative;
}

.onboarding-panel::before,
.onboarding-panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 2px solid var(--gold-dark);
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 50% 78%, 18% 100%, 0% 38%);
}

.onboarding-panel::before {
  top: -10px;
  left: -10px;
}

.onboarding-panel::after {
  top: -10px;
  right: -10px;
}

.welcome-hero {
  display: block;
  width: calc(100% + 56px);
  margin: -28px -28px 18px -28px;
  height: 160px;
  object-fit: cover;
  border-bottom: 3px solid var(--gold-dark);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.welcome-logo {
  display: block;
  width: 220px;
  max-width: 80%;
  margin: 0 auto 12px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.onboarding-panel h1 {
  margin-bottom: 16px;
}

.onboarding-panel p {
  color: var(--muted);
  line-height: 1.5;
}

#newPasscode {
  color: var(--accent-dark);
  white-space: nowrap;
}

.version-label {
  display: inline-block;
  margin: -2px 0 14px;
  padding: 4px 10px;
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: var(--ink);
  font-family: var(--pixel-font);
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 2px 0 var(--gold-dark);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  padding: 0 14px;
  color: var(--ink);
  background: #fdf3d4;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  box-shadow: inset 0 2px 0 rgba(62, 39, 35, 0.1);
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.name-fields {
  display: grid;
  gap: 10px;
}

.name-fields input {
  text-transform: none;
}

.mode-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--panel);
  border: 3px solid var(--gold-dark);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-logo {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 1px 1px 0 rgba(212, 160, 23, 0.3);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.18rem;
  letter-spacing: 0;
}

.status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 700;
}

.status span,
.section-heading span {
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  padding: 5px 10px;
  background: linear-gradient(180deg, #fdf3d4, #f0d99a);
  font-family: var(--pixel-font);
  color: var(--ink);
  font-size: 0.85rem;
}

.passcode-copy-btn {
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  padding: 5px 10px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  font-weight: 700;
  font-family: var(--pixel-font);
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s;
  min-height: unset;
  box-shadow: 0 2px 0 var(--gold-dark);
}

.passcode-copy-btn:hover {
  background: linear-gradient(180deg, #fdf3d4, var(--gold-light));
}

.passcode-copy-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--gold-dark);
}

h1 .passcode-copy-btn {
  font-size: 0.55em;
  vertical-align: middle;
  padding: 6px 14px;
}

.help-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--accent-dark);
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--panel);
  border: 2px solid var(--gold-dark);
  border-radius: 6px;
  box-shadow: 0 2px 0 var(--gold-dark);
}

.session-bar span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.storage-warning {
  color: var(--warn) !important;
  font-weight: 800;
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.country-copy a,
.rankings a {
  color: inherit;
  text-decoration-color: rgba(12, 122, 107, 0.45);
  text-underline-offset: 3px;
}

.country-copy a:hover,
.rankings a:hover {
  color: var(--accent-dark);
}

.compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.country-panel,
.rankings,
.loved-panel {
  background: var(--panel);
  border: 3px solid var(--gold-dark);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.country-panel {
  display: grid;
  grid-template-rows: 300px minmax(260px, 1fr) auto;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

.country-panel::before,
.country-panel::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 2px solid var(--gold-dark);
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 50% 78%, 18% 100%, 0% 38%);
  z-index: 2;
  pointer-events: none;
}

.country-panel::before { top: 4px; left: 4px; }
.country-panel::after { top: 4px; right: 4px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, 1fr);
  height: 300px;
  background: var(--gold-dark);
  gap: 2px;
  border-bottom: 3px solid var(--gold-dark);
}

.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #dde4e2;
}

.country-copy {
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto auto auto;
  gap: 10px;
  padding: 18px;
  background: #fdf3d4;
}

.country-copy p {
  max-height: 190px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.rating {
  margin-bottom: 0;
  color: var(--accent-dark);
  font-weight: 800;
}

.more-photos {
  min-height: 36px;
  padding: 0 12px;
  color: var(--accent-dark);
  font-size: 0.9rem;
}

.more-photos[hidden] {
  display: none;
}

.country-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.country-actions button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.heart-button {
  width: 44px;
  padding: 0;
  color: var(--accent);
  font-size: 1.5rem;
  background: linear-gradient(180deg, #fdf3d4, #f0d99a);
}

.heart-button.active {
  background: linear-gradient(180deg, #ffdce8, #ffb3c8);
  border-color: var(--accent-dark);
  color: var(--accent-dark);
  text-shadow: 0 0 8px rgba(200, 32, 92, 0.5);
}

.remove-button {
  color: var(--warn);
}

.comment-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcfc;
}

.comment-box summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.comment-box.has-comment summary {
  color: var(--accent-dark);
}

.partner-comment-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-dark);
  vertical-align: middle;
  margin-left: 3px;
  cursor: help;
  font-size: 0;
}

.comment-box textarea {
  width: 100%;
  margin: 8px 0;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--ink);
  font: inherit;
  line-height: 1.35;
}

.summary-expanded {
  max-height: none !important;
}

.comment-box textarea[readonly] {
  resize: none;
  background: transparent;
  border-color: transparent;
  padding-left: 0;
  cursor: default;
  color: var(--muted);
}

.comment-box button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--accent-dark);
  font-size: 0.86rem;
}

.country-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
}

.country-stats p {
  margin: 0;
}

.advisory-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.advisory-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.advisory-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.advisory-1 { background: #e8f5e9; color: #2e7d32; }
.advisory-2 { background: #fff8e1; color: #e65100; }
.advisory-3 { background: #fff3e0; color: #bf360c; }
.advisory-4 { background: #ffebee; color: #b71c1c; }

.has-tooltip {
  position: relative;
}

.has-tooltip::before {
  content: "i";
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.choose {
  margin: 0 20px 20px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: white;
  border: 2px solid var(--accent-dark);
  box-shadow: 0 3px 0 #5d0a23;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.choose:hover {
  background: linear-gradient(180deg, #e0317a, var(--accent));
  border-color: var(--accent-dark);
}

.choose:active {
  box-shadow: 0 0 0 #5d0a23;
}

.middle-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  width: 150px;
}

#hardChoice {
  color: var(--warn);
}

.workspace {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.rankings,
.loved-panel,
.comments-panel,
.removed-panel {
  padding: 18px;
}

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

.removed-panel {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.removed-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.removed-panel ul {
  margin-top: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.ranking-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.ranking-controls button,
.see-more {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.92rem;
}

.ranking-controls button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.see-more {
  margin-top: 14px;
  color: var(--accent-dark);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.hint {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
}

ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 26px;
}

li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.empty-list {
  color: var(--muted);
  list-style: none;
}

li strong {
  display: block;
}

li span {
  color: var(--muted);
  font-size: 0.92rem;
}

#commentsFeed li strong {
  display: block;
  margin-bottom: 4px;
}

#commentsFeed li span {
  display: block;
  line-height: 1.45;
}

.photo-modal,
.help-modal {
  width: min(980px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
  border: 3px solid var(--gold-dark);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  background: var(--panel) !important;
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.photo-modal::backdrop,
.help-modal::backdrop {
  background: rgba(29, 35, 40, 0.55);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-heading h2 {
  margin-bottom: 0;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 160px);
  overflow: auto;
}

.modal-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #dde4e2;
}

.help-content {
  display: grid;
  gap: 12px;
}

.help-content section {
  padding: 14px;
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  background: #fdf3d4;
  box-shadow: 0 2px 0 var(--gold-dark);
}

.help-content textarea {
  width: 100%;
  min-height: 110px;
  margin-top: 8px;
  padding: 10px;
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  background: #fffaeb;
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.help-content pre {
  max-height: 220px;
  margin: 0;
  padding: 10px;
  background: #2d1810;
  color: #f5c842;
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  font-size: 0.78rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.removal-section {
  margin-top: 8px;
}

.removal-section h3 {
  margin: 6px 0 4px;
  font-size: 0.95rem;
  color: var(--accent-dark);
}

.removal-hint {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

#suggestionsList li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}

.confirm-removal-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: white;
  border-color: var(--accent-dark);
  box-shadow: 0 2px 0 #5d0a23;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
}

.confirm-removal-btn:hover {
  background: linear-gradient(180deg, #e0317a, var(--accent));
}

.confirm-removal-btn:active {
  box-shadow: 0 0 0 #5d0a23;
}

.help-icons {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 4px auto 16px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.loved-banner {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 12px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.help-content h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.help-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.floating-tooltip {
  position: fixed;
  z-index: 30;
  width: min(280px, calc(100vw - 24px));
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  pointer-events: none;
}

.donation-footer {
  position: relative;
  display: grid;
  justify-items: center;
  margin-top: 18px;
  padding: 24px;
  background: var(--panel);
  border: 3px solid var(--gold-dark);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  text-align: center;
}

.hide-donation {
  justify-self: end;
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.donation-footer p {
  max-width: 620px;
  color: var(--muted);
}

#paypal-container-TR9ZS535L4PNQ {
  display: grid;
  place-items: center;
  justify-items: center;
  width: min(760px, 100%);
  min-height: 48px;
  margin: 0 auto;
}

#paypal-container-TR9ZS535L4PNQ > * {
  width: 100% !important;
  max-width: 760px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

@media (max-width: 860px) {
  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .status {
    justify-content: flex-start;
  }

  .compare,
  .workspace {
    grid-template-columns: 1fr;
  }

  .session-bar,
  .mode-choice {
    grid-template-columns: 1fr;
  }

  .session-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .session-actions {
    justify-content: flex-start;
  }

  .middle-actions {
    width: auto;
    flex-direction: row;
  }

  .middle-actions button {
    flex: 1;
  }

  .country-panel {
    grid-template-rows: 230px minmax(260px, 1fr) auto;
  }

  .photo-grid {
    height: 230px;
  }

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