:root {
  --ink: #172033;
  --muted: #64748b;
  --blue: #0797e8;
  --blue-dark: #075985;
  --red: #f24b4b;
  --red-dark: #b4232a;
  --yellow: #ffd34d;
  --green: #43d17a;
  --paper: #ffffff;
  --line: rgba(23, 32, 51, 0.18);
  --pull: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 14% 15%, rgba(255, 211, 77, 0.38), transparent 24%),
    radial-gradient(circle at 88% 12%, rgba(7, 151, 232, 0.32), transparent 25%),
    linear-gradient(135deg, #18243b 0%, #253d63 52%, #112030 100%);
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100dvh;
  touch-action: manipulation;
}

.start-screen {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: clamp(18px, 3vw, 42px);
  background:
    linear-gradient(90deg, rgba(24, 36, 59, 0.82), rgba(24, 36, 59, 0.42) 52%, rgba(17, 32, 48, 0.76)),
    url("assets/bg-ordklasse-arena-ai.png") center / cover no-repeat;
}

.start-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 430px);
  gap: clamp(22px, 4vw, 64px);
  width: min(1280px, 100%);
  align-items: center;
}

.start-copy {
  width: fit-content;
  max-width: 680px;
  border: 3px solid #0b1220;
  border-radius: 8px;
  background: rgba(11, 18, 32, 0.64);
  padding: clamp(18px, 3vw, 34px);
  box-shadow: 8px 8px 0 rgba(11, 18, 32, 0.58);
}

.kicker {
  display: inline-grid;
  margin: 0 0 18px;
  padding: 9px 14px;
  border: 3px solid #0b1220;
  border-radius: 8px;
  background: var(--green);
  color: #07140d;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: 5px 5px 0 #0b1220;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 10ch;
  color: white;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(4rem, 9vw, 8.4rem);
  line-height: 0.82;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 7px 7px 0 #0b1220;
}

.start-copy p:last-child {
  max-width: 620px;
  margin-top: 24px;
  color: #e6f2ff;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  font-weight: 800;
}

.start-card,
.score-card,
.match-card,
.team-panel,
.arena-panel,
.winner-card {
  border: 3px solid #0b1220;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 8px 8px 0 #0b1220, 0 18px 48px rgba(0, 0, 0, 0.25);
}

.start-card {
  display: grid;
  gap: 16px;
  padding: clamp(20px, 2.5vw, 30px);
}

.start-card h2 {
  font-size: clamp(1.7rem, 3vw, 2.35rem);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 900;
}

select,
input {
  min-height: 52px;
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 900;
}

.big-button,
.nav-button,
.small-button,
.answer {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  font-weight: 950;
}

a.nav-button {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.big-button {
  min-height: 62px;
  background: linear-gradient(180deg, #ffe078, var(--yellow));
  color: #1c1400;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15);
}

.small-button {
  min-height: 44px;
  padding: 0 14px;
  background: #0b1220;
  color: white;
}

.music-button {
  background: #263244;
}

.game-screen {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: clamp(8px, 1vw, 14px);
  height: 100dvh;
  padding: clamp(10px, 1.4vw, 18px);
}

.game-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.game-topbar .start-round-button {
  justify-self: center;
}

.game-topbar .nav-button:last-child {
  justify-self: end;
}

.start-round-button {
  min-width: clamp(140px, 16vw, 220px);
}

.start-round-button.is-play {
  background: linear-gradient(180deg, #7ee787, #20c45a);
}

.start-round-button.is-pause {
  background: linear-gradient(180deg, #ffe078, var(--yellow));
}

.nav-button {
  min-height: 44px;
  border: 3px solid #0b1220;
  background: #ffffff;
  color: #0b1220;
  padding: 0 16px;
  box-shadow: 4px 4px 0 #0b1220;
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr minmax(230px, 0.7fr) 1fr;
  gap: clamp(10px, 1.2vw, 16px);
}

.score-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 16px;
  padding: clamp(10px, 1.2vw, 15px);
}

.blue-card {
  background: linear-gradient(180deg, #dbf3ff, #fff);
}

.red-card {
  background: linear-gradient(180deg, #ffe2e2, #fff);
}

.score-card strong {
  grid-row: 1 / 3;
  grid-column: 2;
  display: grid;
  place-items: center;
  min-width: clamp(66px, 6vw, 102px);
  aspect-ratio: 1;
  border-radius: 8px;
  color: white;
  font-size: clamp(2.5rem, 5vw, 5rem);
  line-height: 1;
}

.blue-card strong {
  background: var(--blue);
}

.red-card strong {
  background: var(--red);
}

.score-card span {
  color: var(--muted);
  font-weight: 950;
}

.stars {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 28px;
  padding: 6px;
  border: 2px solid rgba(11, 18, 32, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.star {
  display: grid;
  place-items: center;
  width: clamp(22px, 2vw, 32px);
  aspect-ratio: 1;
  background: #ffd400;
  clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
  animation: starPop 260ms ease-out;
}

@keyframes starPop {
  from {
    transform: scale(0.1) rotate(-25deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.match-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  text-align: center;
  background: #fff8db;
}

.match-card span {
  display: block;
  color: var(--muted);
  font-weight: 900;
}

.match-card strong {
  display: block;
  color: #0b1220;
  font-size: clamp(2.3rem, 5vw, 5rem);
  line-height: 0.9;
}

.match-card.warning {
  animation: timerPulse 520ms infinite alternate;
}

@keyframes timerPulse {
  from { background: #fff8db; }
  to { background: #ffe0e0; }
}

.board {
  display: grid;
  grid-template-columns: minmax(220px, 24vw) minmax(440px, 1fr) minmax(220px, 24vw);
  gap: clamp(10px, 1.2vw, 16px);
  min-height: 0;
}

.team-panel {
  display: grid;
  grid-template-rows: auto minmax(76px, 0.52fr) minmax(0, 1fr) auto;
  gap: clamp(5px, 0.65vh, 9px);
  min-height: 0;
  padding: clamp(8px, 1vw, 14px);
}

.team-one {
  background: linear-gradient(180deg, #c9ecff 0%, #fff 42%);
}

.team-two {
  background: linear-gradient(180deg, #ffd0d0 0%, #fff 42%);
}

.panel-title span {
  display: block;
  color: var(--muted);
  font-weight: 900;
}

.panel-title strong {
  display: block;
  font-size: clamp(1.35rem, 2.15vw, 2.55rem);
  line-height: 1;
}

.question-card {
  display: grid;
  gap: 5px;
  place-items: center;
  min-height: clamp(72px, 9.8vh, 112px);
  border: 3px solid #0b1220;
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  text-align: center;
  box-shadow: 5px 5px 0 rgba(11, 18, 32, 0.18);
}

.question-card span {
  color: var(--muted);
  font-weight: 900;
  font-size: clamp(0.7rem, 0.82vw, 0.92rem);
}

.question-card strong {
  color: #0b1220;
  font-size: clamp(1.55rem, 3vw, 3.55rem);
  line-height: 0.95;
  word-break: break-word;
}

.answers {
  display: grid;
  gap: clamp(5px, 0.65vh, 8px);
  align-content: start;
  min-height: 0;
  overflow: hidden;
  padding: 2px 2px 4px;
}

.answers.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: stretch;
}

.answer {
  min-height: clamp(44px, 6.1vh, 68px);
  border: 3px solid #0b1220;
  background: #f8fafc;
  color: #0b1220;
  font-size: clamp(0.9rem, 1.18vw, 1.32rem);
  box-shadow: 3px 3px 0 #0b1220;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.answers.compact .answer {
  min-height: clamp(40px, 5.3vh, 56px);
  font-size: clamp(0.76rem, 0.88vw, 1rem);
  padding: 4px;
  box-shadow: 2px 2px 0 #0b1220;
}

.answers.dense .answer {
  min-height: clamp(34px, 4.55vh, 48px);
  font-size: clamp(0.68rem, 0.78vw, 0.9rem);
}

.team-one .answer {
  background: #dff5ff;
}

.team-two .answer {
  background: #ffe4e4;
}

.answer:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #0b1220;
}

.answer.correct {
  background: #bbf7d0;
  color: #14532d;
}

.answer.wrong {
  background: #fecaca;
  color: #7f1d1d;
}

.answer:disabled {
  cursor: default;
  opacity: 0.78;
}

.feedback {
  min-height: clamp(34px, 4.3vh, 50px);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.92);
  padding: 8px;
  color: #334155;
  font-weight: 900;
  font-size: clamp(0.82rem, 0.95vw, 1rem);
  line-height: 1.25;
}

.feedback.good {
  color: #166534;
  background: #dcfce7;
}

.feedback.bad {
  color: #991b1b;
  background: #fee2e2;
}

.arena-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  overflow: hidden;
  background: #f9fbff;
}

.arena-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 3px solid #0b1220;
  background: linear-gradient(90deg, #e0f2fe, #fff8db, #ffe1e1);
}

.arena-top strong {
  font-size: clamp(1.5rem, 2.5vw, 2.6rem);
  line-height: 1;
}

.arena-top span {
  color: #334155;
  font-weight: 950;
}

.arena {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(7, 151, 232, 0.22), transparent 28%, transparent 72%, rgba(242, 75, 75, 0.22)),
    repeating-linear-gradient(0deg, rgba(15, 23, 42, 0.08) 0 2px, transparent 2px 58px),
    linear-gradient(180deg, #f8fdff 0%, #dff4ff 100%);
}

.arena::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  background: linear-gradient(180deg, rgba(67, 209, 122, 0), rgba(67, 209, 122, 0.28));
}

.center-line {
  position: absolute;
  top: 7%;
  bottom: 7%;
  left: 50%;
  width: 0;
  border-left: clamp(4px, 0.5vw, 7px) dashed rgba(11, 18, 32, 0.6);
  transform: translateX(-50%);
  z-index: 6;
}

.center-line::before {
  content: "MIDTE";
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translate(-50%, -100%);
  padding: 6px 10px;
  border: 3px solid #0b1220;
  border-radius: 8px;
  background: white;
  font-size: clamp(0.72rem, 0.9vw, 0.95rem);
  font-weight: 950;
}

.finish {
  position: absolute;
  top: 9%;
  bottom: 9%;
  display: grid;
  place-items: start center;
  width: 52px;
  padding-top: 10px;
  border: 4px solid;
  border-radius: 8px;
  color: white;
  font-weight: 950;
  writing-mode: vertical-rl;
  letter-spacing: 0;
  opacity: 0.85;
  z-index: 1;
}

.finish-left {
  left: 5%;
  background: var(--blue);
  border-color: var(--blue-dark);
}

.finish-right {
  right: 5%;
  background: var(--red);
  border-color: var(--red-dark);
}

.tug-group {
  position: absolute;
  top: 51%;
  left: 50%;
  width: min(92%, 1080px);
  aspect-ratio: 2124 / 369;
  height: auto;
  transform: translate(calc(-50% + var(--pull)), -50%);
  transition: transform 340ms cubic-bezier(.2, .9, .25, 1.15);
  z-index: 4;
}

.flag-sprite {
  --flag-height: clamp(82px, 13vh, 112px);
  position: absolute;
  left: calc(50% + var(--pull));
  top: 51%;
  width: auto !important;
  height: var(--flag-height) !important;
  max-width: none;
  transform: translate(calc(var(--flag-height) * -0.043), -100%);
  transition: left 340ms cubic-bezier(.2, .9, .25, 1.15);
  z-index: 8;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(4px 6px 0 rgba(11, 18, 32, 0.18));
}

.player {
  position: relative;
  width: clamp(58px, 6.6vw, 108px);
  height: clamp(118px, 13vw, 210px);
  transform: rotate(-9deg);
  filter: drop-shadow(6px 8px 0 rgba(11, 18, 32, 0.16));
}

.player-small {
  scale: 0.86;
  translate: 0 18px;
  opacity: 0.92;
}

.head,
.hair,
.shirt,
.arm,
.leg {
  position: absolute;
  display: block;
}

.head {
  left: 36%;
  top: 2%;
  width: 31%;
  aspect-ratio: 1;
  border: 3px solid #0b1220;
  border-radius: 50%;
  background: #f0b887;
  z-index: 3;
}

.hair {
  left: 31%;
  top: -1%;
  width: 41%;
  height: 18%;
  border: 3px solid #0b1220;
  border-radius: 999px 999px 8px 8px;
  background: #182033;
  z-index: 4;
}

.shirt {
  left: 27%;
  top: 28%;
  width: 48%;
  height: 35%;
  border: 3px solid #0b1220;
  border-radius: 18px 18px 12px 12px;
  background: var(--blue);
  rotate: -8deg;
  z-index: 2;
}

.red-player .shirt {
  background: var(--red);
}

.arm {
  left: 0;
  top: 39%;
  width: 76%;
  height: 10%;
  border: 3px solid #0b1220;
  border-radius: 999px;
  background: #f0b887;
  transform-origin: right center;
  z-index: 7;
}

.arm::after {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  width: 18px;
  aspect-ratio: 1;
  border: 3px solid #0b1220;
  border-radius: 50%;
  background: #f0b887;
  transform: translateY(-50%);
}

.arm-front {
  rotate: -7deg;
}

.arm-back {
  top: 46%;
  rotate: 7deg;
}

.leg {
  top: 60%;
  width: 17%;
  height: 42%;
  border: 3px solid #0b1220;
  border-radius: 999px;
  background: #1f2937;
  transform-origin: top center;
}

.leg-front {
  left: 34%;
  rotate: 28deg;
}

.leg-back {
  left: 55%;
  rotate: -28deg;
}

.hint-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: clamp(56px, 7vh, 78px);
  padding: 10px 16px;
  border-top: 3px solid #0b1220;
  background: #fff8db;
  font-size: clamp(1rem, 1.25vw, 1.25rem);
  font-weight: 850;
}

.shake {
  animation: shake 300ms ease;
}

.winner-flash {
  animation: winnerFlash 760ms ease-in-out 2;
}

@keyframes shake {
  0%, 100% { translate: 0 0; }
  35% { translate: -9px 0; }
  70% { translate: 8px 0; }
}

@keyframes winnerFlash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12) saturate(1.25); }
}

.winner-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(11, 18, 32, 0.72);
  z-index: 20;
}

.winner-card {
  width: min(560px, 100%);
  padding: clamp(24px, 4vw, 42px);
  text-align: center;
  background: linear-gradient(180deg, #fff8db, #fff);
}

.winner-burst {
  margin: 0 auto 8px;
  color: var(--yellow);
  font-size: clamp(4rem, 8vw, 7rem);
  text-shadow: 4px 4px 0 #0b1220;
  animation: bounce 680ms infinite alternate;
}

.winner-card h2 {
  font-size: clamp(2rem, 5vw, 4rem);
}

.winner-card p {
  margin: 12px 0 22px;
  color: #334155;
  font-size: 1.25rem;
  font-weight: 850;
}

@keyframes bounce {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-10px) scale(1.06); }
}

.confetti {
  position: fixed;
  top: -24px;
  width: 14px;
  height: 24px;
  border: 2px solid #0b1220;
  background: var(--yellow);
  pointer-events: none;
  z-index: 30;
  animation: confettiFall 2.6s linear forwards;
}

.tug-sprite {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(8px 12px 0 rgba(11, 18, 32, 0.18));
}

.countdown-modal,
.round-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.countdown-modal {
  background: rgba(11, 18, 32, 0.62);
  z-index: 19;
}

.countdown-card {
  display: grid;
  place-items: center;
  gap: 12px;
  width: min(520px, 100%);
  border: 5px solid #0b1220;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff8db, #ffffff);
  padding: clamp(28px, 5vw, 56px);
  text-align: center;
  box-shadow: 12px 12px 0 #0b1220, 0 24px 80px rgba(0, 0, 0, 0.34);
}

.countdown-card p {
  color: #334155;
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
  font-weight: 950;
}

.countdown-card strong {
  color: #0b1220;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(6rem, 16vw, 13rem);
  line-height: 0.82;
  text-shadow: 6px 6px 0 #ffd400;
}

.round-modal {
  background: rgba(11, 18, 32, 0.58);
  z-index: 18;
}

.round-card {
  width: min(640px, 100%);
  border: 4px solid #0b1220;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fff8db);
  padding: clamp(24px, 4vw, 44px);
  text-align: center;
  box-shadow: 10px 10px 0 #0b1220, 0 22px 70px rgba(0, 0, 0, 0.3);
}

.round-card h2 {
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.95;
}

.round-card p:not(.kicker) {
  margin: 14px 0 24px;
  color: #334155;
  font-size: clamp(1.1rem, 1.8vw, 1.45rem);
  font-weight: 900;
}

.mini-kicker {
  margin-bottom: 16px;
}

@keyframes confettiFall {
  to {
    transform: translateY(110vh) rotate(420deg);
    opacity: 0;
  }
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .game-screen {
    height: auto;
    min-height: 100dvh;
  }

  .start-stage,
  .scoreboard,
  .board {
    grid-template-columns: 1fr;
  }

  .arena-panel {
    min-height: 58vh;
    order: -1;
  }
}

@media (max-width: 720px) {
  .score-card,
  .match-card,
  .arena-top {
    grid-template-columns: 1fr;
  }

  .score-card strong {
    grid-row: auto;
    grid-column: auto;
  }

  .tug-group {
    width: 102%;
    gap: 8px;
  }

  .finish {
    width: 36px;
  }
}
