@font-face {
  font-family: 'FIFA 26';
  src: url('./fifa-26.otf') format('opentype');
  font-display: swap;
}

@font-face {
  font-family: 'Cossette Texte';
  src: url('./CossetteTexte-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cossette Texte';
  src: url('./CossetteTexte-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Clean neutral off-white — lets the vibrant album palette pop without
     fighting it. No yellow/cream cast. */
  --paper: #f5f5f3;
  --paper-deep: #e8e8e6;
  --ink: #1a1714;
  --ink-soft: #5a5046;
  --ink-faint: rgba(26, 23, 20, 0.18);

  /* Primary accent — the FWC26 album red. */
  --accent: #d92a2a;
  --accent-soft: rgba(217, 42, 42, 0.14);

  /* Full album palette, exposed as variables for accents/decoration. */
  --color-red:    #d92a2a;
  --color-pink:   #e6437f;
  --color-orange: #ee8d2e;
  --color-yellow: #f5c935;
  --color-green:  #6cbf45;
  --color-cyan:   #5bc2dc;
  --color-teal:   #2da8b0;
  --color-purple: #7e62a9;

  /* Legacy alias used by the dimension callouts and a couple of accents. */
  --pitch: var(--color-teal);

  --canvas-zoom: 1;

  --serif: 'FIFA 26', 'Cossette Texte', system-ui, sans-serif;
  --sans: 'Cossette Texte', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  font-feature-settings: 'ss01', 'cv11';
}

body {
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 18% 10%, rgba(91, 194, 220, 0.10), transparent 55%),
    radial-gradient(ellipse at 90% 90%, rgba(217, 42, 42, 0.06), transparent 50%),
    var(--paper);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.55;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.35 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
}

.page {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.5rem) clamp(1.5rem, 5vw, 4rem) 2rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  padding-bottom: clamp(2rem, 5vw, 3rem);
  position: relative;
}

/* Album-inspired multi-color stripe replaces the plain bottom border. */
.masthead::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(
    to right,
    var(--color-red)    0%,    var(--color-red)    14.285%,
    var(--color-pink)   14.285%, var(--color-pink)   28.57%,
    var(--color-orange) 28.57%,  var(--color-orange) 42.855%,
    var(--color-yellow) 42.855%, var(--color-yellow) 57.14%,
    var(--color-green)  57.14%,  var(--color-green)  71.425%,
    var(--color-cyan)   71.425%, var(--color-cyan)   85.71%,
    var(--color-purple) 85.71%,  var(--color-purple) 100%
  );
}

.meta {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
  text-transform: uppercase;
  animation: rise 0.7s ease-out 0.05s both;
}

.meta-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); }
  50%      { box-shadow: 0 0 0 9px rgba(217, 42, 42, 0); }
}

.title {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.title-display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(4.5rem, 16vw, 11rem);
  line-height: 0.85;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  color: var(--ink);
  animation: rise 0.85s cubic-bezier(0.2, 0.7, 0.2, 1) 0.18s both;
}

/* Per-character album palette across the FWC26 title — warm → cool flow. */
.title-display .ch-1 { color: var(--color-red); }
.title-display .ch-2 { color: var(--color-orange); }
.title-display .ch-3 { color: var(--color-pink); }
.title-display .ch-4 { color: var(--color-green); }
.title-display .ch-5 { color: var(--color-teal); }

.title-sub {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(0.85rem, 1.6vw, 1.05rem);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-left: 0.25rem;
  animation: rise 0.7s ease-out 0.42s both;
}

/* ---------- Stage ---------- */

.stage {
  --canvas-frame-w: 70mm;   /* 48mm sticker + 2 × 11mm padding */
  --canvas-frame-h: 86mm;   /* 64mm sticker + 2 × 11mm padding */

  flex: 1;
  display: grid;
  grid-template-columns: auto minmax(280px, 360px);
  align-items: start;
  justify-content: center;
  gap: clamp(2rem, 5vw, 4rem);
  padding: clamp(3rem, 7vw, 5rem) 0 clamp(2rem, 5vw, 3.5rem);
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.55s both;
}

/* Wraps the sticker viewport + the Save-as-PNG button in one grid cell. */
.stage-canvas {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.canvas-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* Portrait sliders (Scale / Brightness / Contrast). */
.portrait-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 0.25rem;
}

.portrait-control-label {
  white-space: nowrap;
  min-width: 5.5em;
}

.portrait-control-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 22px;
  cursor: pointer;
}

.portrait-control-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--ink-faint);
  border-radius: 2px;
}

.portrait-control-slider::-moz-range-track {
  height: 2px;
  background: var(--ink-faint);
  border-radius: 2px;
}

.portrait-control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  margin-top: -5px;
  box-shadow: 0 1px 4px rgba(26, 23, 20, 0.18);
}

.portrait-control-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: 0 1px 4px rgba(26, 23, 20, 0.18);
}

.portrait-control-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.portrait-control-value {
  min-width: 3.2em;
  text-align: right;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.save-btn {
  appearance: none;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 2px;
  padding: 0.7rem 1.4rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  transition: background 140ms ease, transform 80ms ease;
}

.save-btn:hover {
  background: var(--accent);
}

.save-btn:active {
  transform: scale(0.97);
}

.save-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.save-btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.save-btn-icon {
  font-family: var(--mono);
  font-weight: 700;
}

/* Secondary button — outlined, for less-primary actions like Print. */
.save-btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}

.save-btn--ghost:hover {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- Print rules ---------- */

@media print {
  /* Use the printer's default page (Letter / A4 from the print dialog).
     A small @page margin keeps the sticker off the edge for cuttability. */
  @page {
    margin: 15mm;
  }

  /* Force the browser to preserve colors and SVG fills exactly — without
     this, "save ink" stripping can wipe out the 26 background and other
     inline fills when generating the final print/PDF (even though the
     print preview looks correct). */
  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  html,
  body {
    background: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
  }

  /* Hide everything that isn't the sticker. */
  .grain,
  .masthead,
  .controls,
  .canvas-actions,
  .footer {
    display: none !important;
  }

  /* Strip the wrappers — no borders, padding, transforms, min-height, or
     background. The sticker stays at its natural 48×64mm. */
  .page,
  .stage,
  .stage-canvas,
  .canvas-viewport,
  .canvas-zoom,
  .canvas-frame {
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    transform: none !important;
    position: static !important;
    inset: auto !important;
    flex: none !important;
  }

  .sticker {
    box-shadow: none !important;
    margin: 0 !important;
  }
}

.canvas-viewport {
  width: clamp(280px, 38vw, 460px);
  height: clamp(360px, 48vw, 580px);
  overflow: auto;
  background: var(--paper-deep);
  border: 1px solid var(--ink-faint);
  border-radius: 4px;
  display: grid;
  place-content: safe center;
  scrollbar-color: var(--ink-soft) transparent;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.canvas-viewport.is-panning {
  cursor: grabbing;
}

.canvas-viewport.is-panning * {
  pointer-events: none;
}

.canvas-viewport::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.canvas-viewport::-webkit-scrollbar-thumb {
  background: var(--ink-faint);
  border-radius: 5px;
  border: 2px solid var(--paper-deep);
}

.canvas-viewport::-webkit-scrollbar-thumb:hover {
  background: var(--ink-soft);
}

/* The zoom wrapper grows with the zoom factor so layout (and therefore
   the scroll area) tracks the visually scaled canvas-frame. */
.canvas-zoom {
  width: calc(var(--canvas-frame-w) * var(--canvas-zoom, 1));
  height: calc(var(--canvas-frame-h) * var(--canvas-zoom, 1));
  position: relative;
  margin: 1.5rem;
  transition: width 90ms ease-out, height 90ms ease-out;
}

.canvas-frame {
  position: absolute;
  inset: 0;
  width: var(--canvas-frame-w);
  height: var(--canvas-frame-h);
  padding: 11mm;
  box-sizing: border-box;
  transform: scale(var(--canvas-zoom, 1));
  transform-origin: top left;
  transition: transform 90ms ease-out;
  will-change: transform;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
  padding-top: 1.5rem;
}

@media (max-width: 760px) {
  .stage {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .controls {
    width: min(420px, 100%);
    padding-top: 0;
  }
}

/* Print registration marks */
.reg {
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
  opacity: 0.55;
}

.reg::before,
.reg::after {
  content: '';
  position: absolute;
  background: var(--ink-soft);
}

.reg::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(-50%);
}

.reg::after {
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  transform: translateY(-50%);
}

.reg-tl { top: 0; left: 0; }
.reg-tr { top: 0; right: 0; }
.reg-bl { bottom: 0; left: 0; }
.reg-br { bottom: 0; right: 0; }

/* Dimension callouts */
.dim {
  position: absolute;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.dim-line {
  display: block;
  background: var(--ink-faint);
}

.dim-label {
  display: inline-block;
  background: var(--paper);
  padding: 0 0.5rem;
}

.dim-w {
  top: 0.4rem;
  left: 11mm;
  right: 11mm;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dim-w .dim-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  top: 50%;
}

.dim-h {
  top: 11mm;
  bottom: 11mm;
  left: 0.4rem;
  width: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dim-h .dim-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  left: 50%;
}

.dim-h .dim-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 0.5rem 0;
}

/* The sticker — actual print dimensions */
.sticker {
  --sticker-bg: #75c9c9;
  --capsule-color: #007d8c;

  width: 48mm;
  height: 64mm;
  background: var(--sticker-bg);
  position: relative;
  padding: 3.5mm 3mm;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.04),
    0 18px 38px -14px rgba(26, 23, 20, 0.22),
    0 6px 14px -10px rgba(26, 23, 20, 0.18);
  overflow: hidden;
}

/* Working area: 42mm × 57mm (sticker minus padding) */
.sticker-art {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Background design layer — sits between the sticker's teal fill and all
   other elements. Anchored to the working area's top-left, 42×38mm.
   The three glyph fills are CSS variables so JS can swap them per
   country, with red / white / blue as the fallback for unlisted teams. */
.sticker-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 42mm;
  height: 38mm;
  pointer-events: none;
}

/* Fills are set inline on each <text> by app.js so they're captured
   correctly by html-to-image. These rules just provide a sane default
   in case JS hasn't run yet (initial paint before the script loads). */
.sticker-bg-2       { fill: #d23b2f; }
.sticker-bg-overlap { fill: #ffffff; }
.sticker-bg-6       { fill: #2563d2; }

/* Portrait — invisible 33.5mm × 48mm frame, top-left of working area.
   Big radius on TL/TR/BL; BR stays square. */
.portrait-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 33.5mm;
  height: 47mm;
  border-radius: 8mm 8mm 0 8mm;
  overflow: hidden;
}

.portrait-image {
  --portrait-x: 0mm;
  --portrait-y: 0mm;
  --portrait-scale: 1;
  --portrait-brightness: 1;
  --portrait-contrast: 1;
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  width: auto;
  /* Read right-to-left: scale around the image's centre, then apply the
     user-controlled translate, then centre horizontally with -50%. The
     -50% uses the natural (un-scaled) width so centring is stable across
     scale values. */
  transform:
    translateX(-50%)
    translate(var(--portrait-x), var(--portrait-y))
    scale(var(--portrait-scale));
  transform-origin: center center;
  filter:
    brightness(var(--portrait-brightness))
    contrast(var(--portrait-contrast));
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Capsules — share the BR-square shape language with the portrait,
   radii proportional to the player's frame (~24% of the short side).
   --capsule-color is set on .sticker so it can be overridden per-sticker later. */
.capsule {
  position: absolute;
  background: var(--capsule-color);
}

.capsule-primary {
  top: 48mm;
  left: 0;
  width: 33.5mm;
  height: 5.5mm;
  border-radius: 2.75mm 2.75mm 0 2.75mm;
}

.capsule-secondary {
  top: 54.1mm;
  left: 0;
  width: 28.5mm;
  height: 2.5mm;
  border-radius: 1.25mm 1.25mm 0 1.25mm;
}

/* Capsule text content */
.capsule-primary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2mm;
  padding: 0 0.5mm 0 0.5mm;
  color: #fff;
  font-family: 'Cossette Texte', sans-serif;
  overflow: hidden;
  text-align: center;
}

.capsule-line {
  white-space: nowrap;
  line-height: 1;
  /* No overflow:hidden here — it would clip the 'g'/'p' descenders at the
     line box. The parent .capsule-primary still hides anything beyond
     the capsule itself, so we don't lose the overall clip. */
}

.capsule-name {
  font-size: 2.1mm;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

.cap-firstname {
  font-weight: 400;
}

.cap-firstname:not(:empty) + .cap-lastname::before {
  content: ' ';
}

.cap-lastname {
  font-weight: 700;
}

.capsule-stats {
  font-size: 1.6mm;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.capsule-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.4mm 0 0.4mm;
  color: #fff;
  font-family: 'Cossette Texte', sans-serif;
  font-weight: 400;
  font-size: 1.4mm;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
}

.cap-club {
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Chip — yellow rectangle aligned with capsule 2, 0.5mm gap to its right */
.chip {
  position: absolute;
  top: 54.1mm;
  left: 29mm;
  width: 12mm;
  height: 2.5mm;
  background: #fdee08;
  border: 0.2mm solid #000;
  box-sizing: border-box;
}

.chip-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 70%;
  height: 0.15mm;
  background: #000;
}

/* Country flag — square frame on the right column, below the logo.
   Border colour matches the sticker background, creating a 1px inset bleed.
   Same BR-square shape language as the rest of the design. */
.flag-frame {
  position: absolute;
  top: 30.3mm;
  left: 34mm;
  width: 7mm;
  height: 7mm;
  border: 1px solid var(--sticker-bg);
  border-radius: 3.5mm 3.5mm 0 3.5mm;
  box-sizing: border-box;
  overflow: hidden;
}

/* Country code — vertical SVG stack below the flag.
   ViewBox in mm; font-size, dy, stroke-width all in user units (= mm). */
.country-code {
  position: absolute;
  top: 36.5mm;
  left: 35.6mm;
  width: 7mm;
  height: 18mm;
  overflow: visible;
  pointer-events: none;
  user-select: none;
}

/* Inner 2px white border, sits on top of the flag image */
.flag-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid #fff;
  border-radius: inherit;
  box-sizing: border-box;
  pointer-events: none;
}

.flag-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Logo — sits flush against the portrait's right edge, top of working area */
.sticker-logo {
  position: absolute;
  top: 0;
  left: 34.2mm;
  width: 7.2mm;
  height: 14mm;
  object-fit: contain;
  object-position: top left;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------- Country picker ---------- */

.picker {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: rise 0.7s ease-out 0.7s both;
}

.picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.picker-hint {
  font-style: italic;
  letter-spacing: 0.08em;
  text-transform: none;
  opacity: 0.7;
}

.picker-control {
  position: relative;
}

.picker-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  border: 1px solid var(--ink-faint);
  border-radius: 2px;
  padding: 0.55rem 2.25rem 0.55rem 0.85rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.picker-select:hover {
  border-color: var(--ink);
}

.picker-select:focus-visible {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.picker-arrow {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  width: 10px;
  height: 6px;
  pointer-events: none;
  transform: translateY(-50%);
  background-color: var(--ink);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M0 0l5 6 5-6z'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M0 0l5 6 5-6z'/></svg>") center / contain no-repeat;
}

/* ---------- Portrait controls ---------- */

.portrait-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  animation: rise 0.7s ease-out 0.72s both;
}

.portrait-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.portrait-reset {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.65rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 140ms ease;
}

.portrait-reset:hover {
  color: var(--ink);
}

/* Upload — file input is hidden, label provides the visible button */
.portrait-upload {
  display: block;
  cursor: pointer;
}

.portrait-upload input[type='file'] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
}

.portrait-upload-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--ink-faint);
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  background: transparent;
  transition: border-color 140ms ease, background 140ms ease;
}

.portrait-upload:hover .portrait-upload-btn {
  border-color: var(--ink);
}

.portrait-upload input[type='file']:focus-visible + .portrait-upload-btn {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.portrait-upload-icon {
  font-family: var(--mono);
  font-weight: 600;
}

.portrait-upload-label {
  font-weight: 500;
}

.portrait-upload-name {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Directional pad — 3 cols × 3 rows but only 5 cells used */
.portrait-pad {
  display: grid;
  grid-template-columns: repeat(3, 2.4rem);
  grid-template-rows: repeat(3, 2.4rem);
  gap: 0.3rem;
  justify-content: center;
}

.pad-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--ink-faint);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 80ms ease;
}

.pad-btn:hover {
  border-color: var(--ink);
}

.pad-btn:active {
  transform: scale(0.94);
  background: var(--accent-soft);
}

.pad-btn:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.pad-up    { grid-column: 2; grid-row: 1; }
.pad-left  { grid-column: 1; grid-row: 2; }
.pad-center{ grid-column: 2; grid-row: 2; }
.pad-right { grid-column: 3; grid-row: 2; }
.pad-down  { grid-column: 2; grid-row: 3; }

/* ---------- Player info form ---------- */

.info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  animation: rise 0.7s ease-out 0.74s both;
}

.info-head {
  font-family: var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 0.65rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

.field-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field-input {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid var(--ink-faint);
  border-radius: 2px;
  padding: 0.45rem 0.65rem;
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  width: 100%;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  min-width: 0;
}

.field-input::placeholder {
  color: var(--ink-soft);
  opacity: 0.5;
  font-weight: 400;
}

.field-input:hover {
  border-color: var(--ink);
}

.field-input:focus-visible {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.field-input[type='number']::-webkit-outer-spin-button,
.field-input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-input[type='number'] {
  -moz-appearance: textfield;
}

.dob-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 0.4rem;
}

.dob-inputs .field-input {
  text-align: center;
  letter-spacing: 0.05em;
}

/* ---------- Zoom control ---------- */

.zoom {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: rise 0.7s ease-out 0.78s both;
}

.zoom-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.zoom-value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.zoom-track {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
}

.zoom-tick {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
  opacity: 0.6;
}

.zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}

.zoom-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(
    to right,
    var(--ink) 0%,
    var(--ink) var(--zoom-fill, 20%),
    var(--ink-faint) var(--zoom-fill, 20%),
    var(--ink-faint) 100%
  );
  border-radius: 2px;
}

.zoom-slider::-moz-range-track {
  height: 2px;
  background: var(--ink-faint);
  border-radius: 2px;
}

.zoom-slider::-moz-range-progress {
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  margin-top: -8px;
  box-shadow: 0 2px 6px rgba(26, 23, 20, 0.18);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.zoom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 6px var(--accent-soft), 0 2px 6px rgba(26, 23, 20, 0.18);
}

.zoom-slider:active::-webkit-slider-thumb {
  background: var(--accent);
  border-color: var(--accent);
}

.zoom-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: 0 2px 6px rgba(26, 23, 20, 0.18);
}

.zoom-slider:focus-visible {
  outline: none;
}
.zoom-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 6px var(--accent-soft), 0 2px 6px rgba(26, 23, 20, 0.18);
}

.zoom-hint {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.25rem;
  font-style: italic;
  opacity: 0.85;
}

/* ---------- Cookie / consent banner ---------- */

.cookie-banner {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.4;
  box-shadow: 0 16px 48px -12px rgba(26, 23, 20, 0.45);
  z-index: 100;
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner-text {
  flex: 1 1 14rem;
  margin: 0;
}

.cookie-banner-actions {
  display: flex;
  gap: 0.5rem;
}

.cookie-btn {
  appearance: none;
  border: 1px solid currentColor;
  background: transparent;
  color: var(--paper);
  padding: 0.45rem 1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 2px;
  transition: background 140ms ease, color 140ms ease;
}

.cookie-btn:hover {
  background: rgba(245, 245, 243, 0.12);
}

.cookie-btn--primary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

.cookie-btn--primary:hover {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

@media (max-width: 480px) {
  .cookie-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .cookie-banner-actions {
    justify-content: flex-end;
  }
}

/* ---------- Footer ---------- */

.footer {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding-top: 2rem;
  border-top: 1px solid var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  animation: rise 0.6s ease-out 1s both;
}

.footer-tag {
  color: var(--ink);
}

.footer-sep {
  opacity: 0.5;
}

/* ---------- Animations ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .canvas-frame {
    transition: none;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 540px) {
  .dim { display: none; }
  .canvas-frame { padding: 1.5rem; }
}
