@import url('fonts.css');

:root {
  --sea: #42b9b2;
  --sea-dark: #2a9d96;
  --sea-light: #e8f7f6;
  --white: #ffffff;
  --black: #333333;
  --text: #333333;
  --split: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Gotham Pro', sans-serif;
  font-weight: 700;
}

.game {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.game__stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: #ffffff;
}

.game__stage--art {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5.5rem 2.75rem 1.5rem;
}

.game__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 104px;
  height: auto;
  background: var(--white);
  border-top: 3px solid var(--sea-light);
  padding: 0.7rem 1rem;
  gap: 0.6rem 1rem;
}

.controls-start,
.controls-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.1rem;
  min-width: 0;
}

.controls-start {
  justify-content: flex-end;
}

.controls-end {
  justify-content: flex-start;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.top-left {
  position: fixed;
  top: 0.85rem;
  left: 1rem;
  z-index: 130;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.method-btn {
  position: fixed;
  top: 0.85rem;
  right: 1rem;
  z-index: 130;
}

.back-btn,
.method-btn,
.lang-btn,
.play-btn,
.method-panel__close {
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.back-btn,
.method-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid var(--sea-light);
  border-radius: 999px;
  color: var(--sea-dark);
  font-size: 0.9rem;
  text-decoration: none;
  backdrop-filter: blur(8px);
  transition: background 0.15s, border-color 0.15s;
}

.back-btn:hover,
.method-btn:hover {
  background: var(--white);
  border-color: var(--sea);
}

.game-logo {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  color: var(--sea);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  line-height: 1;
  pointer-events: none;
}

.play-btn {
  width: 84px;
  height: 84px;
  border: none;
  border-radius: 50%;
  background: var(--sea);
  color: var(--white);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 20px rgba(42, 157, 150, 0.28);
  transition: background 0.15s, transform 0.15s;
}

.play-btn:hover {
  background: var(--sea-dark);
  transform: scale(1.04);
}

.play-btn--stop {
  background: #e53935;
  box-shadow: 0 8px 20px rgba(229, 57, 53, 0.28);
}

.play-btn--stop:hover {
  background: #c62828;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 160px;
}

.control-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--sea-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 180px;
  height: 6px;
  border-radius: 999px;
  background: var(--sea-light);
  outline: none;
  cursor: pointer;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sea);
  border: 3px solid var(--white);
  box-shadow: 0 2px 8px rgba(42, 185, 178, 0.4);
}

input[type='range']::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sea);
  border: 3px solid var(--white);
  box-shadow: 0 2px 8px rgba(42, 185, 178, 0.4);
}

.speed-ticks {
  display: flex;
  justify-content: space-between;
  width: 180px;
  font-size: 0.75rem;
  color: var(--sea-dark);
  font-weight: 700;
}

.pair-switch {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.pair-switch__label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  max-width: 7.8rem;
  text-align: center;
}

.pair-switch__toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pair-switch__track {
  display: block;
  width: 48px;
  height: 26px;
  background: var(--sea-light);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
  cursor: pointer;
}

.pair-switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.pair-switch__toggle input:checked + .pair-switch__track {
  background: var(--sea);
}

.pair-switch__toggle input:checked + .pair-switch__track::after {
  transform: translateX(22px);
}

.idle-layer,
.celebrate-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.idle-layer {
  background: #ffffff;
  z-index: 42;
}

.idle-layer[hidden],
.celebrate-layer[hidden] {
  display: none;
}

.mosya {
  width: min(38vmin, 280px);
  height: min(38vmin, 280px);
  object-fit: contain;
}

.countdown {
  font-size: min(28vw, 34vh);
  line-height: 1;
  color: var(--sea);
  user-select: none;
}

.countdown--pop {
  animation: count-pop 0.65s ease;
}

@keyframes count-pop {
  0% {
    transform: scale(0.55);
    opacity: 0.2;
  }
  55% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.celebrate-layer {
  z-index: 44;
  background: transparent;
}

.super-text {
  font-size: min(12vw, 5.5rem);
  color: var(--sea);
  text-shadow: 0 4px 0 rgba(42, 157, 150, 0.15);
  animation: count-pop 0.6s ease;
  z-index: 2;
}

.firework {
  position: absolute;
  width: 8px;
  height: 8px;
  top: 38%;
  border-radius: 50%;
}

.firework--left {
  left: 12%;
}

.firework--right {
  right: 12%;
}

.firework::before,
.firework::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow:
    0 -52px 0 #e53935,
    36px -36px 0 #fdd835,
    52px 0 0 #1e88e5,
    36px 36px 0 #43a047,
    0 52px 0 #42b9b2,
    -36px 36px 0 #e53935,
    -52px 0 0 #fdd835,
    -36px -36px 0 #1e88e5;
  animation: firework-burst 1.1s ease-out infinite;
}

.firework::after {
  transform: scale(0.55) rotate(22deg);
  animation-delay: 0.35s;
}

@keyframes firework-burst {
  0% {
    transform: scale(0.15);
    opacity: 0.9;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

.method-panel {
  position: fixed;
  top: 4.6rem;
  right: 1rem;
  left: auto;
  width: min(420px, calc(100vw - 2rem));
  max-height: min(70vh, calc(100% - 9rem));
  overflow: auto;
  background: #ffffff;
  border: 3px solid var(--sea-light);
  border-radius: 18px;
  padding: 1.15rem 1.35rem 1.4rem;
  z-index: 200;
  box-shadow: 0 16px 40px rgba(42, 157, 150, 0.16);
}

.method-panel[hidden] {
  display: none;
}

.method-panel h2 {
  color: var(--sea-dark);
  font-size: 1.2rem;
  margin: 0.2rem 0 0.75rem;
}

.method-panel p {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
  font-weight: 700;
}

.method-panel ul {
  margin: 0.55rem 0 0.6rem;
  padding-left: 1.15rem;
}

.method-panel li {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
  margin-bottom: 0.4rem;
}

.method-panel ul ul {
  margin: 0.4rem 0 0.35rem;
}

.method-panel__close {
  float: right;
  border: 0;
  background: var(--sea-light);
  color: var(--sea-dark);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

.changing {
  animation: pulse-change 0.45s ease;
}

@keyframes pulse-change {
  0%,
  100% {
    opacity: 1;
  }
  35% {
    opacity: 0.72;
  }
}

@keyframes flash-bg {
  0% {
    filter: brightness(1);
  }
  40% {
    filter: brightness(0.75);
  }
  100% {
    filter: brightness(1);
  }
}

.flash-bg {
  animation: flash-bg 0.45s ease;
}

.limb,
.art-shape {
  overflow: visible;
  background: transparent;
  line-height: 0;
  flex-shrink: 1;
}

.limb svg,
.art-shape svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  max-width: 100%;
  max-height: 100%;
}

.split-screen {
  display: flex;
  width: 100%;
  height: 100%;
  background: #ffffff;
  gap: var(--split);
  padding: var(--split);
}

.split-screen--horizontal {
  flex-direction: column;
}

.split-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  transition: background-color 0.35s ease;
}

.quads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  width: 100%;
  height: 100%;
  background: #ffffff;
  gap: var(--split);
  padding: var(--split);
}

.quad {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 2%;
}

.quads--carpet .quad:nth-child(1) {
  background: #e53935;
}

.quads--carpet .quad:nth-child(2) {
  background: #fdd835;
}

.quads--carpet .quad:nth-child(3) {
  background: #43a047;
}

.quads--carpet .quad:nth-child(4) {
  background: #1e88e5;
}

.quad .limb {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  transform: scale(1.7);
  transform-origin: center center;
}

.quads--carpet .limb svg {
  filter: drop-shadow(0 0 3px rgba(51, 51, 51, 0.35));
}

.quad-number {
  font-size: min(18vw, 22vh);
  line-height: 1;
  color: #333333;
  user-select: none;
}

@media (max-width: 760px) {
  .game__controls {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 0;
    padding: 0.65rem 0.75rem 0.85rem;
  }

  .play-btn {
    order: -1;
    width: 72px;
    height: 72px;
  }

  .controls-start,
  .controls-end {
    justify-content: center;
    width: 100%;
  }

  .top-left {
    left: 0.45rem;
    top: 0.5rem;
    gap: 0.35rem;
  }

  .method-btn {
    top: 0.5rem;
    right: 0.45rem;
  }

  .back-btn,
  .method-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.78rem;
  }

  .pair-switch__label {
    max-width: 6.2rem;
    font-size: 0.66rem;
  }

  .game__stage--art {
    padding: 4.6rem 1.1rem 1rem;
  }
}
