:root {
  --accent: #ff4b3a;
  --amber: #ffb020;
  --lime: #7ce34a;
  --blue: #4aa3ff;
  --ink: #0b1120;
  --glass: rgba(10, 16, 30, 0.72);
  --glass-line: rgba(255, 255, 255, 0.14);
  font-size: 16px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b1120;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: fixed; inset: 0; }
#app canvas { display: block; }

#vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(5, 9, 20, 0.42) 100%);
  z-index: 5;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }

#hud-top {
  position: absolute; top: 22px; left: 26px; right: 26px;
  display: flex; justify-content: space-between; align-items: flex-start;
}

#score-chip {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 10px 18px 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
#half-chip {
  font-size: 0.65rem; letter-spacing: 3px; font-weight: 700;
  color: var(--amber);
}
#score-line {
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.35rem; letter-spacing: 1px;
  display: flex; align-items: center; gap: 10px;
  font-variant-numeric: tabular-nums;
}
#score-line .dot {
  width: 12px; height: 12px; border-radius: 3px;
  display: inline-block;
}
#score-line .dot.home { background: var(--accent); }
#score-line .dot.away { background: #2563eb; }
#score-line .vs { color: #8fa3c8; font-size: 0.9rem; }

#timer {
  font-family: 'Archivo Black', sans-serif;
  font-size: 2.2rem;
  letter-spacing: 1px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 14px;
  padding: 8px 20px;
  backdrop-filter: blur(8px);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* power meter */
#meters {
  position: absolute; bottom: 34px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 14px;
  width: min(420px, 74vw);
}
#power-wrap {
  position: relative;
  height: 20px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  overflow: hidden;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
#power-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--lime), var(--amber) 60%, var(--accent));
  border-radius: 999px;
  transition: width 40ms linear;
}
.meter-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 3px;
  color: rgba(255,255,255,.92);
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

/* center message (GOAL!, KICK OFF, FULL TIME) */
#center-msg {
  position: absolute; top: 34%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(3rem, 11vw, 8rem);
  letter-spacing: 4px;
  text-shadow: 0 6px 0 rgba(0,0,0,.28), 0 18px 60px rgba(0,0,0,.5);
  opacity: 0;
  white-space: nowrap;
  z-index: 12;
}
#center-msg.pop {
  animation: msgpop 1.1s cubic-bezier(.2,1.6,.35,1) forwards;
}
#center-msg.go { color: var(--lime); }
#center-msg.bad { color: var(--accent); }
@keyframes msgpop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(2.2); }
  18%  { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(.92); }
}

/* floating popup (scorer, corner, save) */
#popup {
  position: absolute; top: 46%; left: 50%;
  transform: translateX(-50%);
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  color: var(--amber);
  text-shadow: 0 4px 0 rgba(0,0,0,.3), 0 12px 40px rgba(0,0,0,.5);
  opacity: 0;
  white-space: nowrap;
  z-index: 12;
}
#popup.rise { animation: rise 1.6s ease-out forwards; }
#popup.bad { color: var(--accent); }
@keyframes rise {
  0%   { opacity: 0; transform: translate(-50%, 26px) scale(.7); }
  15%  { opacity: 1; transform: translate(-50%, 0) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(.96); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(6,10,22,.25) 0%, rgba(6,10,22,.68) 100%);
  backdrop-filter: blur(3px);
}

.card-box, .title-box {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 24px;
  padding: 42px 58px;
  text-align: center;
  max-width: min(620px, 90vw);
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
  backdrop-filter: blur(14px);
  animation: cardin .45s cubic-bezier(.2,1.4,.4,1);
}
@keyframes cardin {
  from { opacity: 0; transform: translateY(26px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.card-kicker, .title-kicker {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 5px;
  color: var(--amber);
  margin-bottom: 12px;
}

.card-box h2 {
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: 2px;
  line-height: 1.02;
  background: linear-gradient(120deg, #fff 30%, #ffd9a0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 14px;
}

.card-hint {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 3px;
  color: #e8eefc;
}
.card-hint b { color: var(--lime); }
.blink { animation: blink 1.4s step-end infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* title screen — floats free over the stadium, no modal */
#title {
  background: transparent;
  backdrop-filter: none;
}
#title .title-box {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  max-width: none;
}
.title-box h1 {
  font-family: 'Archivo Black', sans-serif;
  font-size: clamp(3rem, 9.5vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: 3px;
  /* generous padding so background-clip:text never crops edge glyphs */
  padding: 0.06em 0.2em;
  background: linear-gradient(160deg, #ffffff 10%, #ffc46b 45%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 18px;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)) drop-shadow(0 16px 34px rgba(0,0,0,.5));
}
.title-kicker,
.title-sub,
#title .card-hint,
.title-controls {
  text-shadow: 0 2px 10px rgba(0,0,0,.75), 0 0 30px rgba(0,0,0,.5);
}
.title-sub {
  color: #e6eeff;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 28px;
}
.title-controls {
  margin-top: 22px;
  font-size: 0.68rem; letter-spacing: 2.5px; font-weight: 600;
  color: #c6d4ee;
}

/* results table */
#results-table { margin: 6px 0 26px; max-height: 40vh; overflow-y: auto; }
.res-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 18px;
  margin-bottom: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  text-align: left;
  font-weight: 600;
}
.res-row.player {
  border-color: rgba(255,75,58,.6);
  background: rgba(255,75,58,.12);
}
.res-pos {
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.05rem;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.res-name { letter-spacing: 1px; }
.res-mark { font-variant-numeric: tabular-nums; color: #cfe0ff; font-weight: 700; letter-spacing: 2px; }

/* ---------- touch controls ---------- */
#touch-ui { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#t-stick {
  pointer-events: auto;
  position: absolute; left: 22px; bottom: 24px;
  width: 132px; height: 132px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(10,16,30,.45);
  backdrop-filter: blur(6px);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: grid; place-items: center;
}
#t-nub {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: rgba(255,255,255,.28);
  border: 1px solid rgba(255,255,255,.4);
  pointer-events: none;
}
#t-action {
  pointer-events: auto;
  position: absolute; right: 22px; bottom: 24px;
  width: 108px; height: 108px;
  border-radius: 50%;
  border: 1px solid rgba(255,75,58,.65);
  background: rgba(255,75,58,.35);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 2px;
  backdrop-filter: blur(6px);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#t-action:active { background: rgba(255,75,58,.6); transform: scale(.93); }
#touch-ui { display: none; }
body.touch #touch-ui { display: block; }
.touch-only { display: none; }
body.touch .touch-only { display: block; }
body.touch #meters { bottom: 158px; width: min(320px, 50vw); }

/* ---------- small screens ---------- */
@media (max-width: 680px) {
  #hud-top { top: 10px; left: 10px; right: 10px; }
  #score-chip { padding: 6px 12px 8px; }
  #score-line { font-size: 1rem; gap: 7px; }
  #half-chip { font-size: 0.55rem; }
  #timer { font-size: 1.5rem; padding: 4px 12px; }
  .card-box, .title-box { padding: 24px 20px; max-width: 94vw; }
  .card-box h2 { font-size: 1.6rem; }
  .res-row { padding: 5px 10px; margin-bottom: 4px; font-size: 0.78rem; gap: 8px; grid-template-columns: 36px 1fr auto; }
  .res-pos { font-size: 0.9rem; }
}
