:root{
  --page-w: 297mm;
  --page-h: 210mm;
  --page-pad: 8mm;
  --bg: #fff;
  --text: #111;
  --line: #000;
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  font-family: Century Gothic,CenturyGothic,AppleGothic,sans-serif; 
  color: var(--text);
  background: #64CCC9;
}

.toolbar{
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 16px;
  background: #ff9e1b;
  color: #000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toolbar-row{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}

.toolbar label{
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.toolbar input,
.toolbar select,
.toolbar button{
  font-size: 14px;
  padding: 8px 10px;
}

.toolbar button{
  cursor: pointer;
}

.help{
  margin-top: 8px;
  font-size: 13px;
  opacity: .9;
}

#pages{
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.page{
  width: var(--page-w);
  min-height: var(--page-h);
  min-height: 0;
  background: var(--bg);
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
  padding: var(--page-pad);
  page-break-after: always;
  break-after: page;
  overflow: hidden;
}

/* single layout */
.page.single{
  display: block;
}

.card-single{
  width: 100%;
  height: calc(var(--page-h) - 2 * var(--page-pad));
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.startnummer-big{
  text-align: center;
  font-size: 145mm;
  line-height: 0.82;
  font-weight: 300;
  letter-spacing: -3mm;
  margin-top: 5mm;
}

.bar{
  height: 8mm;
  background: var(--line);
  margin: 8mm 4mm 8mm 4mm;
}

.name-row{
  text-align: center;
  font-size: 10mm;
  line-height: 1.1;
  margin: 2mm 20mm 2mm 20mm;
  align-self: center;
  max-width: 80%;
}

.name-row .name{
  font-weight: 700;
  font-style: italic;
}

.name-row .club{
  font-weight: 300;
  font-style: italic;
}

.subtitle{
  text-align: center;
  font-size: 5.5mm;
  margin-top: 2mm;
}

.brand{
  position: absolute;
  left: -10mm;
  bottom: 0mm;
}

.brand img{
  width: 45mm;
  height: auto;
}

.corner-flag{
  position: absolute;
  right: 6mm;
  bottom: 6mm;
}

.corner-flag img{
  width: 28mm;
  height: auto;
  object-fit: contain;
}

/* 4-up grid */
.page.grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6mm;
}

.card-grid{
  position: relative;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
}

.card-grid .startnummer{
  text-align: center;
  font-size: 75mm;
  line-height: 0.86;
  font-weight: 300;
  letter-spacing: -1.5mm;
  margin-top: 2mm;
}

.card-grid .bar{
  height: 4mm;
  min-height: 4mm;
  flex-shrink: 0;
  background: var(--line);
  margin: 1mm 4mm 8mm 4mm;
  display: block;
}

.card-grid .name-row{
  font-size: 5mm;
  margin: 0 8mm 0 8mm;
  max-width: 20mm;
  align-self: center;
  max-width: 75%;
}

.card-grid .subtitle{
  font-size: 3.2mm;
  margin-top: 1mm;
}

.card-grid .brand{
  left: -3mm;
  bottom: 0mm;
}

.card-grid .brand img{
  width: 25mm;
}

.card-grid .corner-flag{
  right: 0mm;
  bottom: 0mm;
}

.card-grid .corner-flag img{
  width: 16mm;
}

/* print */
@page{
  size: A4 landscape;
  margin: 0;
}

@media print{

  html,
  body{
    margin: 0;
    padding: 0;
    background: white;
  }

  .toolbar,
  .no-print{
    display: none !important;
  }

  #pages{
    display: block;
    padding: 0;
    margin: 0;
  }

  .page{
    width: 297mm;
    height: 210mm;
    min-height: 210mm;
    max-height: 210mm;

    margin: 0;
    padding: 8mm;

    box-shadow: none;

    break-after: page;
    page-break-after: always;

    overflow: hidden;
  }

  .page:last-child{
    break-after: auto;
    page-break-after: auto;
  }

  .page.grid{
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 6mm;

    width: 297mm;
    height: 210mm;
  }

  .card-single .bar{
    display: block !important;
    width: calc(100% - 8mm) !important;
    height: 8mm !important;
    min-height: 8mm !important;
    background: #000 !important;
    flex-shrink: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .card-grid .bar{
    display: block !important;
    height: 4mm !important;
    min-height: 4mm !important;
    background: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
