:root {
  color-scheme: light;
  font-family:
    "Casual Puzzle Game", "Baloo 2", Baloo, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #ffffff;
  color: #111827;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 30px;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  padding: 0 9px;
  background: #ffffff;
  color: #111827;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  background: #f3f4f6;
}

input {
  min-width: 0;
  min-height: 30px;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  padding: 0 8px;
  background: #ffffffe8;
  color: #111827;
  font-size: 12px;
  font-weight: 800;
}

#world {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

.welcome {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: auto;
  transition:
    opacity 280ms ease,
    transform 280ms ease;
}

.in-game .welcome {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
}

.welcome-card {
  display: grid;
  gap: 24px;
  width: min(1030px, calc(100vw - 48px));
  padding: 34px 16px 24px;
  border: 1px solid #c8c8c8;
  border-radius: 6px;
  background: #eeeeee;
  box-shadow: 0 1px 3px #00000018;
}

.game-logo {
  margin: 0;
  text-align: center;
  font-size: clamp(32px, 4.5vw, 44px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    -1px -1px 0 #111827,
    1px -1px 0 #111827,
    -1px 1px 0 #111827,
    1px 1px 0 #111827,
    0 1px 1px #11182788;
}

.logo-pink {
  color: #ff4f7d;
}

.logo-green {
  color: #32ff1f;
}

.logo-yellow {
  color: #fff34a;
}

.logo-cyan {
  color: #22d8ff;
}

.server-url {
  display: none;
}

.name-input {
  width: 100%;
  min-height: 68px;
  border: 1px solid #c9cfd7;
  border-radius: 5px;
  padding: 0 28px;
  background: #e7f0ff;
  color: #111827;
  font-size: 20px;
  font-weight: 800;
}

.welcome-error {
  margin-top: -10px;
  color: #b91c1c;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.start-button {
  min-height: 60px;
  border: 0;
  border-radius: 5px;
  background: #5f5f5f;
  color: #ff9f00;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 12px;
  text-indent: 12px;
  text-shadow: none;
}

.start-button:hover {
  background: #555555;
}

.hud {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  padding: max(5px, env(safe-area-inset-top)) 5px max(5px, env(safe-area-inset-bottom));
  pointer-events: none;
}

.game-hud {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.in-game .game-hud {
  opacity: 1;
}

.target-panel,
.bottom-panel,
.leaderboard,
.result,
.notice {
  pointer-events: auto;
}

.status-strip {
  position: fixed;
  right: 6px;
  bottom: 6px;
  z-index: 3;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
}

.badge,
.target-panel,
.controls,
.result,
.notice {
  border: 1px solid #ffffffaa;
  border-radius: 7px;
  background: #ffffffcc;
  box-shadow: 0 1px 4px #0000001f;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  color: #111827;
  font-size: 12px;
  font-weight: 950;
}

.badge.danger {
  border-color: #ef4444;
  background: #fee2e2dd;
}

.badge.ok {
  border-color: #22c55e;
}

.target-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 88px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 6px 82px 6px 6px;
  border: 0;
  border-radius: 0;
  background: #bdbdbd88;
  box-shadow: none;
  overflow: visible;
}

.mistake-dots {
  display: grid;
  align-content: center;
  gap: 4px;
  width: 14px;
  flex: 0 0 14px;
}

.mistake-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #00ee18;
  box-shadow:
    0 0 0 1px #ffffffcc,
    0 0 5px #00ee18;
}

.leaderboard-open .target-panel {
  padding-right: 230px;
}

.target-list {
  display: flex;
  align-items: center;
  gap: var(--target-gap, 24px);
  width: 100%;
  min-width: 0;
  overflow: visible;
}

.target-chip {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--target-size, 48px);
  height: var(--target-size, 48px);
  flex: 0 0 auto;
  --target-ring: #00ee18;
  --target-ring-glow: 0 0 0 transparent;
}

.target-chip.done::after,
.target-chip.lead-marker::after {
  position: absolute;
  inset: -8px;
  border-radius: 999px;
  border: 2px solid var(--target-ring);
  box-shadow: var(--target-ring-glow);
  content: "";
  opacity: 0.95;
}

.target-chip.neon-green,
.target-chip.plain-green {
  --target-ring: #00ee18;
}

.target-chip.neon-green {
  --target-ring-glow:
    0 0 0 2px #ffffffd8,
    0 0 6px #00ee18,
    0 0 13px #00ee18;
}

.target-chip.plain-green {
  --target-ring-glow: 0 0 0 1px #ffffffcc;
}

.target-chip.danger-orange {
  --target-ring: #ff9800;
  --target-ring-glow:
    0 0 0 2px #ffffffd8,
    0 0 7px #ff9800,
    0 0 15px #ff9800;
}

.target-chip.danger-red {
  --target-ring: #ff2020;
  --target-ring-glow:
    0 0 0 2px #ffffffd8,
    0 0 7px #ff2020,
    0 0 16px #ff2020;
}

.target-chip.lead-marker::after {
  opacity: 1;
  animation: warningPulse 520ms ease-in-out infinite alternate;
}

.target-chip.current {
  filter: drop-shadow(0 0 5px #ffffffcc);
}

.target-chip.current::before {
  position: absolute;
  inset: -6px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 0 7px #ffffffcc;
  content: "";
  opacity: 0.95;
}

.shape-icon {
  width: var(--target-size, 48px);
  height: var(--target-size, 48px);
  overflow: visible;
}

.gem-icon {
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px #ffffff55);
}

.shape-icon > * {
  fill: currentColor;
  stroke: var(--shape-stroke, #ffffff);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

@keyframes warningPulse {
  from {
    transform: scale(0.96);
    filter: brightness(1);
  }

  to {
    transform: scale(1.08);
    filter: brightness(1.2);
  }
}

.notice {
  align-self: start;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 92px;
  padding: 8px 11px;
  background: #fee2e2ef;
  color: #7f1d1d;
  font-size: 13px;
}

.result {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  max-width: none;
  padding: 24px;
  color: #ffffff;
  font-size: clamp(24px, 5vw, 56px);
  font-weight: 800;
  line-height: 1.18;
  text-align: center;
  text-shadow:
    -1px -1px 0 #111827,
    1px -1px 0 #111827,
    -1px 1px 0 #111827,
    1px 1px 0 #111827,
    0 4px 16px #00000088;
  opacity: 1;
  pointer-events: auto;
  transition:
    opacity 400ms ease,
    transform 400ms ease;
}

.result.fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

.hidden {
  display: none;
}

.bottom-panel {
  align-self: end;
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  align-items: end;
}

.controls {
  padding: 5px;
}

.leaderboard {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2;
  width: 70px;
  height: 70px;
  min-height: 70px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  transition:
    width 180ms ease,
    height 180ms ease,
    background 180ms ease;
}

.leaderboard-open .leaderboard {
  width: min(220px, 24vw);
  height: 205px;
  min-height: 205px;
  padding: 0 6px 6px 9px;
  background: #60606072;
  border-radius: 0;
}

.leaderboard-toggle {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #ffffff;
  font-size: 34px;
  font-weight: 800;
  line-height: 70px;
  text-align: center;
  transition:
    color 150ms ease,
    text-shadow 150ms ease,
    transform 150ms ease;
  text-shadow:
    -1px -1px 0 #777777,
    1px -1px 0 #777777,
    -1px 1px 0 #777777,
    1px 1px 0 #777777,
    0 0 3px #ffffffcc;
}

.leaderboard-toggle:hover {
  background: transparent;
  color: #fff9ed;
  transform: scale(1.04);
  text-shadow:
    0 0 4px #ffffff,
    0 0 10px #ff9f00,
    0 0 18px #ff9f00,
    0 0 28px #ff6b00;
}

.leaderboard-open .leaderboard-toggle {
  display: none;
}

.leaderboard-title {
  display: none;
  text-align: center;
  color: #ffffff;
  font-size: clamp(17px, 1.6vw, 22px);
  font-weight: 800;
  line-height: 1;
  text-shadow:
    -1px -1px 0 #111827,
    1px -1px 0 #111827,
    -1px 1px 0 #111827,
    1px 1px 0 #111827,
    0 2px 0 #111827;
}

.leaderboard-list {
  display: none;
  gap: 0;
  margin-top: 8px;
  max-height: 128px;
  overflow: hidden;
}

.leaderboard-open .leaderboard-title {
  display: block;
}

.leaderboard-open .leaderboard-list {
  display: grid;
}

.leader-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  min-height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: clamp(12px, 1vw, 15px);
  font-weight: 800;
  line-height: 1;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    0 2px 0 #000000;
}

.leader-row.me .leader-name {
  color: #ff3030;
}

.leader-row.me .leader-score {
  color: #ffffff;
}

.leader-row.placeholder {
  color: #ffffff;
}

.leader-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-score {
  justify-self: end;
}

.controls {
  display: grid;
  bottom: 10px;
  position: fixed;
  left: 10px;
  grid-template-columns: 60px;
  gap: 5px;
}

.minimap-toggle {
  position: fixed;
  right: 12px;
  bottom: 158px;
  z-index: 3;
  min-width: 46px;
  min-height: 30px;
  border-color: #b7c5b7;
  background: #ffffffd8;
  color: #111827;
  pointer-events: auto;
  box-shadow: 0 1px 4px #00000024;
}

.minimap-toggle.off {
  bottom: 12px;
  opacity: 0.72;
}

@media (max-width: 720px) {
  .hud {
    padding: max(4px, env(safe-area-inset-top)) 4px max(4px, env(safe-area-inset-bottom));
  }

  .target-panel {
    height: 64px;
    gap: 8px;
    padding: 4px 76px 4px 4px;
  }

  .leaderboard-open .target-panel {
    padding-right: 76px;
  }

  .target-list {
    gap: var(--target-gap, 5px);
  }

  .mistake-dots {
    gap: 3px;
    width: 11px;
    flex-basis: 11px;
  }

  .mistake-dot {
    width: 8px;
    height: 8px;
  }

  .target-chip.done::after,
  .target-chip.lead-marker::after {
    inset: -5px;
    border-width: 1.5px;
  }

  .target-chip.current::before {
    inset: -4px;
    border-width: 1.5px;
  }

  .target-chip,
  .shape-icon {
    width: var(--target-size, 32px);
    height: var(--target-size, 32px);
  }

  .leaderboard {
    width: 70px;
    height: 70px;
    min-height: 70px;
    padding-left: 0;
  }

  .leaderboard-open .leaderboard {
    top: 64px;
    width: min(150px, 32vw);
    height: 154px;
    min-height: 154px;
    padding-left: 6px;
  }

  .leaderboard-list {
    margin-top: 7px;
    max-height: 92px;
  }

  .leaderboard-title {
    font-size: clamp(15px, 3.4vw, 18px);
  }

  .leader-row {
    min-height: 17px;
    font-size: clamp(10px, 2vw, 12px);
  }

  .minimap-toggle {
    right: 10px;
    bottom: 112px;
    min-width: 42px;
    min-height: 28px;
    padding: 0 8px;
    font-size: 11px;
  }

  .minimap-toggle.off {
    bottom: 10px;
  }

  .welcome-card {
    width: min(620px, calc(100vw - 24px));
    gap: 18px;
    padding: 28px 14px 18px;
  }

  .name-input {
    min-height: 58px;
    padding: 0 18px;
    font-size: 18px;
  }

  .start-button {
    min-height: 54px;
    font-size: 22px;
    letter-spacing: 8px;
    text-indent: 8px;
  }
}
