:root {
  --un-blue: #009edb;
  --un-blue-dark: #0077a8;
  --ink: #1d2733;
  --muted: #5d6b7a;
  --bg: #f3f8fc;
  --card: #ffffff;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
}

.site-header {
  background: var(--un-blue);
  color: #fff;
  padding: calc(20px + env(safe-area-inset-top)) 18px 20px;
  text-align: center;
}
.site-header h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.site-header .brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
}
.site-header .logo {
  display: block;
  flex: 0 0 auto;
  height: 64px;
  width: auto;
  filter: drop-shadow(0 1px 2px rgba(0, 40, 70, .35));
}
.site-header .logo-pc {
  box-sizing: border-box;
  width: 64px;
  object-fit: contain;
  padding: 5px;
  border-radius: 50%;
  background: #351e5b;
  filter: none;
  box-shadow: 0 1px 3px rgba(0, 40, 70, .35);
}
.site-header .dot { opacity: .8; }
.nowrap { white-space: nowrap; }
@media (max-width: 519px) {
  .site-header .dot { display: none; }
  .site-header .nowrap { display: block; }
  .site-header .brand { flex-wrap: wrap; }
  .site-header .brand h1 { order: 3; flex-basis: 100%; }
  .site-header .logo { height: 56px; }
  .site-header .logo-pc { width: 56px; }
}
.site-header .sub {
  margin: 6px 0 0;
  font-size: .95rem;
  font-weight: 600;
  opacity: .95;
}
.site-header .hint {
  margin: 12px auto 0;
  max-width: 34em;
  font-size: .9rem;
  background: rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: 7px 14px;
  display: inline-block;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 12px 8px;
}

.status {
  margin: 0 0 12px;
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}
.status.error {
  color: #9b1c1c;
  background: #fdecec;
  border-radius: 10px;
  padding: 10px 12px;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } main { max-width: 1400px; } }

.grid > li { display: flex; }

.tile {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(16, 40, 64, .08), 0 2px 8px rgba(16, 40, 64, .06);
  border: 1px solid rgba(0, 119, 168, .10);
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, box-shadow .12s ease;
}

a.tile:hover { box-shadow: 0 2px 4px rgba(16, 40, 64, .10), 0 6px 18px rgba(0, 119, 168, .16); }
a.tile:active { transform: scale(.97); }
a.tile:focus-visible { outline: 3px solid var(--un-blue); outline-offset: 2px; }

/* Stall without a link yet */
.tile.off {
  filter: grayscale(1);
  opacity: .5;
  pointer-events: none;
  cursor: default;
  box-shadow: none;
}

/* Team is full: flags stay in colour, dimmed; the tile is not a link */
.tile.full {
  position: relative;
  overflow: hidden;
  cursor: default;
}
.tile.full .flags { opacity: .6; }
.tile.full .ribbon {
  position: absolute;
  z-index: 2;
  top: 22px;
  right: -46px;
  width: 168px;
  margin: 0;
  padding: 5px 0;
  background: #9f2d2d;
  color: #fff;
  text-align: center;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.1;
  transform: rotate(45deg);
  box-shadow: 0 2px 6px rgba(16, 40, 64, .28);
  pointer-events: none;
}
.tile.full .label {
  color: #3d4c5c;
  font-weight: 600;
  line-height: 1.25;
}

/* Flag area: fixed 4:3 box; flags are arranged inside it */
.flags {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: 6%;
}
.flags img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  flex: 0 0 auto;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .14);
  background: #eee;
}
.flags.n2 img { width: 46%; border-radius: 4px; }
.flags.n3 img,
.flags.n4 img { width: 44%; border-radius: 4px; }
.flags.n2 { gap: 6%; }
.flags.n3, .flags.n4 { row-gap: 4%; column-gap: 6%; }

.name {
  margin-top: 10px;
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: break-word;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.label {
  margin-top: 6px;
  text-align: center;
  font-size: .78rem;
  font-weight: 600;
  color: var(--un-blue-dark);
}
.tile.off .label { color: var(--muted); font-weight: 500; }

.site-footer {
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
  padding: 16px 12px calc(20px + env(safe-area-inset-bottom));
}

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  a.tile:active { transform: none; }
}
