:root {
  color-scheme: light;
  --blue: #2e73ff;
  --blue-deep: #1751cf;
  --blue-soft: #d9ecff;
  --red: #ff3f64;
  --red-deep: #d91d41;
  --red-soft: #ffe0e7;
  --yellow: #ffd84d;
  --yellow-deep: #f2b900;
  --mint: #2fc7a0;
  --ink: #10233f;
  --muted: #64748b;
  --paper: #ffffff;
  --line: #d7e6f6;
  --green: #20bc7a;
  --tug-bg: #f5faff;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(46, 115, 255, 0.05) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(0deg, rgba(32, 188, 122, 0.05) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(180deg, #f6fbff 0%, #eef8ff 58%, #f8fcff 100%);
}

button {
  font: inherit;
}

.game-shell {
  width: min(1740px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.language-switcher {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 8px 6px 14px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 28px rgba(30, 56, 88, 0.14);
  color: #29415f;
  font-size: 14px;
  font-weight: 900;
}

.language-switcher select {
  height: 32px;
  padding: 0 32px 0 12px;
  border: 2px solid #cfe0f3;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f3f9ff);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.scorebar {
  display: grid;
  grid-template-columns: 190px 1fr 230px;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  visibility: hidden;
  pointer-events: none;
}

.round-info {
  text-align: center;
}

.round-info strong {
  display: block;
  font-size: 30px;
  line-height: 1.2;
}

.round-info span {
  color: var(--muted);
  font-size: 15px;
}

.start-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  height: 38px;
  margin-top: 10px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: #15b86a;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 #0e9555, 0 8px 18px rgba(21, 184, 106, 0.22);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.start-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0e9555, 0 5px 12px rgba(21, 184, 106, 0.18);
}

.start-button[disabled] {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.score-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 16px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(24, 44, 70, 0.11);
}

.score-pill span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.score-pill.left span {
  background: var(--blue);
}

.score-pill.right span {
  background: var(--red);
}

.score-pill small {
  color: var(--muted);
  font-weight: 700;
}

.speed-button {
  height: 34px;
  margin-left: auto;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #fff4bf;
  color: #8b5d00;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 -3px rgba(175, 122, 0, 0.13), 0 3px 8px rgba(31, 45, 68, 0.08);
}

.speed-button:active {
  transform: translateY(2px);
}

.game-board {
  display: grid;
  grid-template-columns: 420px minmax(720px, 1fr) 420px;
  align-items: start;
  gap: 50px;
  justify-content: center;
}

.team-panel {
  overflow: visible;
  width: 100%;
  margin-top: 58px;
  position: relative;
  border: 4px solid #ffffff;
  border-radius: 24px;
  background: #fff;
  box-shadow:
    0 22px 42px rgba(36, 64, 104, 0.18),
    inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.panel-avatar {
  position: absolute;
  top: -66px;
  z-index: 2;
  width: 168px;
  height: 168px;
  object-fit: contain;
  filter: drop-shadow(0 12px 14px rgba(28, 54, 88, 0.2));
  pointer-events: none;
}

.panel-avatar-left {
  left: -22px;
  transform: rotate(-2deg);
}

.panel-avatar-right {
  right: -46px;
  transform: rotate(2deg);
}

.panel-avatar-right {
  top: -96px;
  width: 193px;
  height: 193px;
}

.team-panel header {
  position: relative;
  z-index: 1;
  border-radius: 18px 18px 0 0;
}

.team-panel header {
  display: grid;
  place-items: center;
  height: 78px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

.team-panel h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.team-panel-left header {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 14px, transparent 14px 28px) 0 0 / 28px 100%,
    linear-gradient(135deg, #2497ff, var(--blue));
  border-bottom: 7px solid var(--blue-deep);
}

.team-panel-right header {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 14px, transparent 14px 28px) 0 0 / 28px 100%,
    linear-gradient(135deg, #ff6d58, var(--red));
  border-bottom: 7px solid var(--red-deep);
}

.question-box {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 18px;
}

.display,
.keypad {
  position: relative;
  z-index: 2;
}

.team-panel-left .question-box {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 44%),
    linear-gradient(180deg, #4eb1ff, #2f7fff);
}

.team-panel-right .question-box {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 44%),
    linear-gradient(180deg, #ff6a77, #ff315a);
}

.objects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 22px;
  min-height: 82px;
  font-size: 48px;
  line-height: 1;
}

.objects.count-9 {
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-height: 88px;
}

.objects.count-9 .object-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  line-height: 1;
}

.objects.count-9 span {
  font-size: 40px;
}

.math-question {
  display: grid;
  place-items: center;
  min-height: 92px;
  font-size: clamp(36px, 4vw, 62px);
  font-weight: 900;
  color: #0d2443;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.38);
}

.math-question span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(100%, 320px);
  min-height: 80px;
  padding: 0 22px;
  border: 4px solid rgba(255, 255, 255, 0.56);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 -6px rgba(255, 255, 255, 0.14);
}

.mixed-question {
  font-size: clamp(30px, 3.1vw, 44px);
}

.mixed-question span {
  width: min(100%, 360px);
  min-width: 0;
  padding: 0 14px;
  white-space: nowrap;
}

.display {
  display: block;
  width: calc(100% - 32px);
  height: 64px;
  margin: 18px auto 14px;
  padding: 15px 20px;
  border: 2px solid #cfe0f3;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
  line-height: 28px;
  box-shadow:
    inset 0 2px 5px rgba(40, 65, 98, 0.08),
    0 2px 0 rgba(205, 220, 237, 0.9);
}

.display::after {
  content: "";
  display: inline-block;
  height: 24px;
  border-right: 2px solid #a9b6c7;
  animation: blink 0.9s steps(1) infinite;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 18px 20px;
  touch-action: none;
}

.keypad button {
  height: 64px;
  border: 2px solid #dbe8f5;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  color: #17304f;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 5px 0 #c4d6e8, 0 8px 16px rgba(45, 69, 102, 0.08);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.keypad button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #c9d5e2;
}

.keypad .clear {
  border-color: #ffc8cf;
  background: linear-gradient(180deg, #fff0f2, #ffd9de);
  color: #e4153d;
  box-shadow: 0 5px 0 #ffb0ba, 0 8px 16px rgba(228, 21, 61, 0.1);
}

.keypad .ok {
  border-color: #1b62e2;
  background: linear-gradient(180deg, #45a0ff, #2478ff);
  color: #fff;
  box-shadow: 0 5px 0 #145fd0, 0 8px 16px rgba(36, 120, 255, 0.2);
}

.keypad.disabled {
  opacity: 0.52;
  pointer-events: none;
  filter: grayscale(0.12);
}

.keypad.disabled .ok {
  background: #7f9bc8;
  box-shadow: 0 4px 0 #657da5;
}

.stage {
  min-height: 620px;
  margin-top: 38px;
}

.lane {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 620px;
  margin-top: 30px;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.7);
  border-radius: 26px;
  background: var(--tug-bg);
  box-shadow: none;
}

.lane::before {
  content: none;
}

.lane::after {
  content: none;
}

.stage-hud {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: min(880px, calc(100% - 56px));
  min-height: 126px;
  padding: 22px 44px;
  border: 4px solid var(--yellow-deep);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0 18px, transparent 18px 36px) 0 0 / 36px 100%,
    linear-gradient(180deg, #fff7b7, var(--yellow));
  box-shadow:
    0 9px 0 rgba(242, 185, 0, 0.72),
    0 24px 44px rgba(174, 126, 0, 0.16);
  transform: translateX(-50%);
}

.hud-team {
  display: grid;
  gap: 8px;
  color: #705500;
  font-size: 17px;
  font-weight: 800;
}

.hud-team:last-child {
  text-align: right;
}

.hud-team strong {
  color: #0d2443;
  font-size: 38px;
  line-height: 1;
}

.hud-timer {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 170px;
  justify-content: center;
  color: #123454;
  font-size: 30px;
  font-weight: 900;
}

.timer-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #29b6e8;
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.5),
    0 0 0 3px rgba(41, 182, 232, 0.2);
}

.center-dash {
  position: absolute;
  top: 275px;
  height: 250px;
  bottom: auto;
  left: 50%;
  z-index: 4;
  border-left: 6px dashed #ffcf00;
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 2px 0 rgba(125, 91, 0, 0.1));
}

.finish-line {
  display: none;
}

.finish-left {
  left: 15%;
  background: var(--blue);
}

.finish-right {
  right: 15%;
  background: var(--red);
}

.center-line {
  display: none;
}

.center-line::before {
  content: "";
  position: absolute;
  top: -30px;
  left: 4px;
  width: 44px;
  height: 28px;
  border-radius: 0 8px 8px 0;
  background: linear-gradient(135deg, #ff5b7b, #ff8a3d);
  box-shadow: 0 6px 0 rgba(255, 130, 62, 0.18);
}

.center-line::after {
  content: "GO!";
  position: absolute;
  top: -24px;
  left: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.tug-group {
  --pull: 0px;
  position: relative;
  width: min(840px, 96vw);
  height: 380px;
  margin-top: 130px;
  overflow: hidden;
  transform: translateX(var(--pull));
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 2;
}

.tug-video-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  aspect-ratio: 1494 / 640;
  overflow: hidden;
  background: var(--tug-bg);
  transform: translate(-50%, -50%);
  isolation: isolate;
}

.tug-video-source {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.tug-canvas {
  display: block;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  margin: -2px;
  image-rendering: auto;
  user-select: none;
  pointer-events: none;
}

.team {
  display: none;
  position: relative;
  height: 166px;
}

.team-blue {
  transform: translateX(-4px);
}

.team-red {
  transform: translateX(4px) scaleX(-1);
}

.kid {
  position: absolute;
  width: 118px;
  height: 132px;
  background: center / contain no-repeat;
  transform-origin: 50% 90%;
  animation: tugIdle 980ms ease-in-out infinite alternate;
}

.kid > span {
  display: none;
}

.kid-b,
.kid-d {
  animation-delay: 160ms;
}

.kid-a,
.kid-c {
  left: 0;
  top: 20px;
}

.kid-b,
.kid-d {
  left: 72px;
  top: 4px;
  transform: scale(0.96);
}

.team-blue .kid {
  background-image: url("assets/player-blue.svg");
}

.team-red .kid {
  background-image: url("assets/player-red.svg");
}

.head {
  position: absolute;
  top: 2px;
  left: 27px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 62%, #ff9fba 0 8%, transparent 9%),
    radial-gradient(circle at 71% 62%, #ff9fba 0 8%, transparent 9%),
    #ffd8ad;
  box-shadow:
    inset 0 -4px rgba(177, 101, 42, 0.12),
    0 5px 0 rgba(57, 40, 28, 0.08);
  z-index: 5;
}

.head::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -9px;
  width: 52px;
  height: 23px;
  border-radius: 28px 28px 9px 9px;
  transform: rotate(-7deg);
}

.head::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 22px;
  width: 6px;
  height: 7px;
  border-radius: 50%;
  background: #202a3a;
  box-shadow:
    18px 0 0 #202a3a,
    9px 13px 0 -2px #d86e5f;
}

.body {
  position: absolute;
  top: 48px;
  left: 24px;
  width: 50px;
  height: 54px;
  border-radius: 18px 18px 16px 16px;
  transform: rotate(-14deg);
  box-shadow:
    inset 0 -7px rgba(0, 0, 0, 0.08),
    0 5px 0 rgba(26, 38, 62, 0.08);
  z-index: 3;
}

.team-blue .body {
  background: linear-gradient(160deg, #39a9ff, #1f62ff);
}

.team-red .body {
  background: linear-gradient(160deg, #ff7b8f, #f00618);
}

.team-blue .head::before {
  background:
    radial-gradient(circle at 10px 8px, #ffd85a 0 3px, transparent 4px),
    linear-gradient(#1f62ff, #174ed1);
}

.team-red .head::before {
  background:
    radial-gradient(circle at 10px 8px, #ffd85a 0 3px, transparent 4px),
    linear-gradient(#ff3c61, #d8071d);
}

.body::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 11px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 0 -6px rgba(255, 255, 255, 0.46);
}

.body::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: -15px;
  height: 20px;
  border-radius: 7px 7px 12px 12px;
  background: #28456f;
  box-shadow: inset 0 -5px rgba(0, 0, 0, 0.12);
}

.arm {
  position: absolute;
  top: 69px;
  left: 55px;
  width: 62px;
  height: 12px;
  border-radius: 999px;
  background: #ffd0a6;
  transform: rotate(-8deg);
  transform-origin: left center;
  z-index: 4;
  box-shadow: inset -6px 0 rgba(201, 112, 59, 0.12);
}

.arm::after {
  content: "";
  position: absolute;
  right: -5px;
  top: -3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ffd8ad;
}

.leg {
  position: absolute;
  top: 96px;
  width: 14px;
  height: 39px;
  border-radius: 999px;
  background: #ffd0a6;
  transform-origin: top center;
  z-index: 1;
}

.leg-one {
  left: 34px;
  transform: rotate(32deg);
}

.leg-two {
  left: 58px;
  transform: rotate(-26deg);
}

.leg::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: -7px;
  width: 29px;
  height: 12px;
  border-radius: 999px;
  background: #111827;
}

.team-red .leg::after {
  background: #f70451;
}

.team-blue .leg::after {
  background: #1285ff;
}

.rope {
  display: none;
  position: relative;
  height: 18px;
  background: url("assets/rope.svg") center / 100% 100% no-repeat;
  border-radius: 999px;
  box-shadow:
    0 4px 0 rgba(71, 47, 20, 0.12),
    0 6px 14px rgba(71, 47, 20, 0.12);
  z-index: 6;
}

.rope-knot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 26px;
  border-radius: 9px;
  background:
    linear-gradient(90deg, transparent 0 8px, rgba(255, 255, 255, 0.3) 8px 11px, transparent 11px),
    #ff5275;
  transform: translate(-50%, -50%) rotate(14deg);
  box-shadow: 0 4px 0 rgba(169, 42, 78, 0.24);
}

.setup-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(135deg, rgba(46, 115, 255, 0.9), rgba(47, 199, 160, 0.78) 52%, rgba(255, 216, 77, 0.82));
  backdrop-filter: blur(6px);
}

.setup-modal[hidden] {
  display: none;
}

.setup-card {
  width: min(780px, 100%);
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.86);
  border-radius: 26px;
  background: #fff;
  box-shadow:
    0 14px 0 rgba(21, 85, 143, 0.18),
    0 34px 86px rgba(19, 25, 52, 0.28);
}

.setup-header {
  display: grid;
  place-items: center;
  padding: 34px 24px 30px;
  color: #fff;
  text-align: center;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.15) 0 18px, transparent 18px 36px) 0 0 / 36px 100%,
    linear-gradient(135deg, #1e8fff, #25c59f);
}

.setup-icon {
  margin: 0 0 8px;
  min-width: 58px;
  min-height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--yellow);
  color: #5b4300;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 4px 0 var(--yellow-deep);
}

.setup-header h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.setup-header span {
  margin-top: 8px;
  font-size: 15px;
  opacity: 0.9;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  padding: 36px;
  background: linear-gradient(180deg, #ffffff, #f3fbff);
}

.level-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 34px;
  background: linear-gradient(180deg, #ffffff, #f3fbff);
}

.battle-options[hidden],
.level-options[hidden] {
  display: none;
}

.battle-options {
  background: linear-gradient(180deg, #ffffff, #f3fbff);
}

.setup-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin: 20px 0 0 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: #eaf4ff;
  color: #23527c;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 -3px rgba(35, 82, 124, 0.12);
}

.setup-back::before {
  content: "←";
  margin-right: 6px;
}

.mode-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 244px;
  padding: 30px 20px;
  border: 3px solid transparent;
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(32, 47, 81, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.mode-card:hover,
.level-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px rgba(32, 47, 81, 0.13);
}

.level-card {
  display: grid;
  justify-items: center;
  gap: 9px;
  min-height: 214px;
  padding: 24px 18px;
  border: 3px solid rgba(46, 115, 255, 0.22);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff, #eff8ff);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(32, 47, 81, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.level-add-sub {
  border-color: rgba(32, 188, 122, 0.34);
  background: linear-gradient(180deg, #f4fff9, #e7fbf2);
}

.level-mul-div {
  border-color: rgba(255, 216, 77, 0.76);
  background: linear-gradient(180deg, #fffbee, #fff3bf);
}

.level-mixed {
  border-color: rgba(255, 63, 100, 0.36);
  background: linear-gradient(180deg, #fff4f7, #ffe8ef);
}

.level-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #42b2ff, var(--blue));
  color: #fff;
  font-size: 34px;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(36, 50, 98, 0.2);
}

.level-add-sub .level-icon {
  background: linear-gradient(135deg, #46d79d, var(--green));
}

.level-mul-div .level-icon {
  background: linear-gradient(135deg, #ffcf00, #ff9f1c);
}

.level-mixed .level-icon {
  background: linear-gradient(135deg, #ff8a5f, var(--red));
}

.mode-robot {
  border-color: rgba(46, 115, 255, 0.46);
  background: linear-gradient(180deg, #f1f7ff, #e6f2ff);
}

.mode-player {
  border-color: rgba(255, 63, 100, 0.42);
  background: linear-gradient(180deg, #fff4f6, #ffe8ee);
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 18px;
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(36, 50, 98, 0.24);
}

.mode-robot .mode-icon {
  background: linear-gradient(135deg, #4db5ff, var(--blue));
}

.mode-player .mode-icon {
  background: linear-gradient(135deg, #ff8a5f, var(--red));
}

.mode-card strong {
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
}

.level-card strong {
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.15;
  text-align: center;
}

.mode-card small,
.level-card small {
  color: #6f7787;
  font-size: 15px;
  text-align: center;
}

.mode-card em,
.level-card em {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: #1f62ff;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

.mode-player em {
  color: #e60032;
}

.winner-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 35, 63, 0.48);
  backdrop-filter: blur(6px);
  z-index: 1000;
}

.winner-modal[hidden] {
  display: none;
}

.winner-card {
  width: min(420px, calc(100vw - 48px));
  padding: 34px;
  border: 5px solid #fff;
  border-radius: 24px;
  background: linear-gradient(180deg, #fff7c7, #ffffff);
  text-align: center;
  box-shadow:
    0 9px 0 rgba(242, 185, 0, 0.62),
    0 28px 70px rgba(0, 0, 0, 0.22);
}

.winner-card p {
  margin: 0 0 22px;
  font-size: 30px;
  font-weight: 900;
}

.winner-card button {
  height: 50px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #37d09d, var(--green));
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 #12945e;
}

.team-panel.correct {
  animation: correctFlash 430ms ease;
}

.team-panel.wrong {
  animation: wrongShake 320ms ease;
}

.pull-left .team-blue .kid,
.pull-right .team-red .kid {
  animation: teamPower 360ms ease;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes tugIdle {
  from {
    translate: 0 0;
    rotate: -2deg;
  }
  to {
    translate: 0 3px;
    rotate: 3deg;
  }
}

@keyframes teamPower {
  0%,
  100% {
    translate: 0 0;
    rotate: -2deg;
    scale: 1;
  }
  50% {
    filter: brightness(1.16);
    translate: 9px 3px;
    rotate: -9deg;
    scale: 1.04;
  }
}

@keyframes gifPower {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.025);
    filter: saturate(1.08) brightness(1.04);
  }
}

@keyframes correctFlash {
  0%,
  100% {
    box-shadow: 0 18px 38px rgba(26, 45, 75, 0.16);
  }
  50% {
    box-shadow: 0 18px 38px rgba(21, 184, 106, 0.42);
  }
}

@keyframes wrongShake {
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@media (min-width: 981px) and (max-width: 1366px) and (orientation: landscape) {
  .game-shell {
    display: grid;
    align-content: center;
    width: 100%;
    padding: 16px 18px;
  }

  .scorebar {
    margin-bottom: 8px;
  }

  .game-board {
    grid-template-columns: clamp(330px, 28vw, 380px) minmax(500px, 1fr) clamp(330px, 28vw, 380px);
    gap: clamp(18px, 2vw, 28px);
    align-items: center;
  }

  .team-panel {
    margin-top: 50px;
    border-width: 3px;
    border-radius: 22px;
  }

  .panel-avatar {
    top: -54px;
    width: 142px;
    height: 142px;
  }

  .panel-avatar-left {
    left: -18px;
  }

  .panel-avatar-right {
    top: -78px;
    right: -38px;
    width: 164px;
    height: 164px;
  }

  .team-panel header {
    height: 68px;
  }

  .team-panel h1 {
    font-size: 24px;
  }

  .question-box {
    min-height: 126px;
    padding: 14px;
  }

  .objects {
    gap: 10px 16px;
    font-size: 40px;
  }

  .objects.count-9 {
    gap: 5px;
  }

  .objects.count-9 span {
    font-size: 34px;
  }

  .math-question {
    min-height: 80px;
    font-size: clamp(32px, 4vw, 50px);
  }

  .math-question span {
    min-height: 66px;
    padding: 0 18px;
  }

  .mixed-question {
    font-size: clamp(25px, 3vw, 36px);
  }

  .mixed-question span {
    padding: 0 10px;
  }

  .display {
    height: 54px;
    margin: 14px auto 12px;
    padding: 12px 16px;
    font-size: 24px;
  }

  .keypad {
    gap: 10px;
    padding: 0 14px 18px;
  }

  .keypad button {
    height: 54px;
    font-size: 22px;
  }

  .stage {
    min-height: 540px;
    margin-top: 34px;
  }

  .lane {
    height: 540px;
    margin-top: 20px;
  }

  .stage-hud {
    top: 16px;
    width: min(760px, calc(100% - 48px));
    min-height: 104px;
    padding: 18px 34px;
  }

  .hud-team {
    font-size: 15px;
  }

  .hud-team strong {
    font-size: 34px;
  }

  .hud-timer {
    min-width: 140px;
    font-size: 28px;
  }

  .center-dash {
    top: 250px;
    height: 210px;
  }

  .tug-group {
    width: min(700px, 100%);
    height: 320px;
    margin-top: 118px;
    transform: translateX(calc(var(--pull) * 0.82));
  }
}

@media (max-width: 980px) {
  .game-shell {
    padding: 14px;
  }

  .language-switcher {
    top: 10px;
    right: 10px;
    min-height: 38px;
    padding: 4px 6px 4px 10px;
    font-size: 12px;
  }

  .language-switcher select {
    height: 28px;
    padding-left: 8px;
  }

  .scorebar {
    grid-template-columns: 1fr;
  }

  .game-board {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .stage {
    order: -1;
    min-height: 380px;
  }

  .lane {
    height: 380px;
  }

  .stage-hud {
    top: 10px;
    width: min(360px, calc(100% - 28px));
    min-height: 70px;
    padding: 10px 14px;
    border-width: 3px;
  }

  .hud-team strong {
    font-size: 26px;
  }

  .hud-timer {
    min-width: 98px;
    font-size: 22px;
  }

  .mode-options {
    grid-template-columns: 1fr;
  }

  .level-options {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .center-dash {
    top: 166px;
    height: 128px;
    bottom: auto;
    border-left-width: 4px;
  }

  .team-panel {
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
  }

  .tug-group {
    width: min(560px, 96vw);
    height: 250px;
    margin-top: 72px;
    transform: translateX(var(--pull)) scale(0.92);
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  body {
    overflow-x: auto;
  }

  .game-shell {
    display: grid;
    align-content: center;
    width: 100%;
    min-width: 760px;
    padding: 8px 10px;
  }

  .language-switcher {
    top: 6px;
    right: 8px;
    min-height: 32px;
    padding: 3px 5px 3px 9px;
    border-width: 2px;
    font-size: 11px;
  }

  .language-switcher select {
    height: 24px;
    padding: 0 22px 0 8px;
  }

  .scorebar {
    height: 0;
    min-height: 0;
    margin: 0;
    overflow: hidden;
  }

  .game-board {
    grid-template-columns: 240px minmax(300px, 1fr) 240px;
    gap: 10px;
    align-items: center;
  }

  .team-panel {
    width: 240px;
    max-width: none;
    margin: 28px auto 0;
    border-width: 2px;
    border-radius: 16px;
  }

  .panel-avatar {
    top: -34px;
    left: -10px;
    width: 92px;
    height: 92px;
  }

  .panel-avatar-right {
    top: -50px;
    right: -20px;
    width: 108px;
    height: 108px;
  }

  .team-panel header {
    height: 44px;
    border-radius: 14px 14px 0 0;
  }

  .team-panel-left header,
  .team-panel-right header {
    border-bottom-width: 4px;
  }

  .team-panel h1 {
    font-size: 18px;
  }

  .question-box {
    min-height: 70px;
    padding: 7px;
  }

  .objects {
    gap: 5px 9px;
    min-height: 44px;
    font-size: 28px;
  }

  .objects.count-9 {
    gap: 3px;
    min-height: 50px;
  }

  .objects.count-9 .object-row {
    gap: 6px;
  }

  .objects.count-9 span {
    font-size: 24px;
  }

  .math-question {
    min-height: 52px;
    font-size: 26px;
  }

  .math-question span {
    min-height: 44px;
    padding: 0 10px;
    border-width: 2px;
    border-radius: 12px;
  }

  .mixed-question {
    font-size: 19px;
  }

  .mixed-question span {
    padding: 0 6px;
  }

  .display {
    width: calc(100% - 20px);
    height: 38px;
    margin: 8px auto;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 19px;
    line-height: 19px;
  }

  .display::after {
    height: 18px;
  }

  .keypad {
    gap: 6px;
    padding: 0 8px 10px;
  }

  .keypad button {
    height: 34px;
    border-radius: 10px;
    font-size: 18px;
    box-shadow: 0 3px 0 #c4d6e8, 0 5px 10px rgba(45, 69, 102, 0.07);
  }

  .keypad .clear {
    box-shadow: 0 3px 0 #ffb0ba, 0 5px 10px rgba(228, 21, 61, 0.08);
  }

  .keypad .ok {
    box-shadow: 0 3px 0 #145fd0, 0 5px 10px rgba(36, 120, 255, 0.16);
  }

  .stage {
    order: initial;
    min-height: 330px;
    margin-top: 26px;
  }

  .lane {
    height: 330px;
    margin-top: 0;
    border-width: 2px;
    border-radius: 18px;
  }

  .stage-hud {
    top: 8px;
    width: min(440px, calc(100% - 22px));
    min-height: 58px;
    padding: 8px 16px;
    border-width: 3px;
    border-radius: 14px;
  }

  .hud-team {
    gap: 2px;
    font-size: 12px;
  }

  .hud-team strong {
    font-size: 22px;
  }

  .hud-timer {
    gap: 6px;
    min-width: 86px;
    font-size: 20px;
  }

  .timer-dot {
    width: 12px;
    height: 12px;
    box-shadow:
      inset 0 0 0 3px rgba(255, 255, 255, 0.5),
      0 0 0 2px rgba(41, 182, 232, 0.2);
  }

  .center-dash {
    top: 155px;
    height: 110px;
    border-left-width: 4px;
  }

  .tug-group {
    width: min(420px, 100%);
    height: 200px;
    margin-top: 62px;
    transform: translateX(calc(var(--pull) * 0.58)) scale(0.88);
  }

  .setup-card {
    width: min(620px, calc(100vw - 32px));
  }

  .setup-header {
    padding: 18px 20px 16px;
  }

  .setup-header h2 {
    font-size: 26px;
  }

  .mode-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
  }

  .level-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
  }

  .level-card {
    min-height: 150px;
    padding: 14px 8px;
    gap: 7px;
  }

  .level-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 24px;
  }

  .level-card strong {
    font-size: 15px;
  }

  .level-card small {
    font-size: 11px;
  }

  .setup-back {
    min-height: 30px;
    margin: 10px 0 0 18px;
    padding: 0 12px;
    font-size: 12px;
  }

  .mode-card {
    min-height: 170px;
    padding: 18px 14px;
  }

  .mode-icon {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    font-size: 20px;
  }

  .mode-card strong {
    font-size: 20px;
  }

  .winner-card {
    padding: 24px;
  }
}
