.game-root,
.game-root * {
  box-sizing: border-box;
}

.game-root {
  --match3-cursor-default: url("/static/img/cursors/cursor_cat.54234ab9b215.png") 0 0, auto;
  --match3-cursor-action: url("/static/img/cursors/cursor_hand.7271d4ef0443.png") 12 4, pointer;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #e8e5dc;
  color: #33434d;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: var(--match3-cursor-default);
}

.match3-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #e8e5dc;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  cursor: var(--match3-cursor-default);
}

.match3-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  cursor: var(--match3-cursor-default);
}

.match3-canvas canvas {
  display: block;
  image-rendering: auto;
}

.match3-hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  z-index: 6;
  width: min(72vw, 720px);
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 14px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(44, 57, 64, 0.17);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  pointer-events: none;
}

.match3-score {
  min-width: 116px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #34454e;
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.match3-score-star {
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  object-fit: contain;
  color: #e1a91d;
  font-size: 31px;
  filter: drop-shadow(0 2px 2px rgba(106, 80, 7, 0.18));
}

.match3-score-star[hidden] {
  display: none;
}

.match3-progress {
  min-width: 90px;
  height: 15px;
  flex: 1;
  overflow: hidden;
  border: 2px solid rgba(96, 119, 129, 0.22);
  border-radius: 999px;
  background: #ece8dc;
}

.match3-progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f0c34a, #e49d32);
  transition: width 420ms ease;
}

.match3-collected {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.match3-collected-item {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid rgba(224, 171, 40, 0.6);
  border-radius: 9px;
  background: #fffdf7;
  box-shadow: 0 4px 10px rgba(45, 58, 65, 0.14);
}

.match3-collected-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 3px;
}

.match3-collected-count {
  position: absolute;
  right: -5px;
  bottom: -5px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 999px;
  padding: 0 4px;
  background: #8b6ab1;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.match3-sounds {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 12px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(44, 57, 64, 0.18);
  backdrop-filter: blur(8px);
}

.match3-sounds-label {
  padding: 0 3px;
  color: #4e5c68;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.match3-sound,
.match3-hint {
  min-width: 42px;
  min-height: 42px;
  border: 2px solid #ffffff;
  border-radius: 9px;
  padding: 0 10px;
  background: #d9e2ea;
  color: #334450;
  font-size: 19px;
  font-weight: 900;
  box-shadow: 0 5px 12px rgba(39, 59, 72, 0.14);
  cursor: var(--match3-cursor-action);
}

.match3-hint {
  flex: 0 0 auto;
  background: #8b6ab1;
  color: #ffffff;
  font-size: 22px;
  pointer-events: auto;
}

.match3-sound[aria-pressed="true"] {
  background: #f2b93d;
  color: #26313f;
  box-shadow: 0 6px 14px rgba(192, 132, 13, 0.25);
}

.match3-sound:disabled,
.match3-hint:disabled {
  opacity: 0.65;
  cursor: var(--match3-cursor-default);
}

.match3-help {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: none;
}

.match3-status {
  max-width: min(43vw, 470px);
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 11px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.86);
  color: #45515d;
  box-shadow: 0 10px 24px rgba(44, 57, 64, 0.14);
  font-size: clamp(12px, 1.4vw, 16px);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  pointer-events: none;
}

.match3-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(72px, calc(env(safe-area-inset-top) + 60px))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: rgba(64, 72, 72, 0.22);
  backdrop-filter: blur(4px);
}

.match3-overlay[hidden] {
  display: none;
}

.match3-card {
  width: min(100%, 570px);
  max-height: 100%;
  overflow: auto;
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 34px);
  background: rgba(255, 252, 243, 0.98);
  box-shadow: 0 24px 64px rgba(43, 53, 57, 0.24);
  color: #354650;
  text-align: center;
}

.match3-card h2 {
  margin: 0 0 10px;
  color: #4a4f72;
  font-size: clamp(26px, 5vw, 42px);
  line-height: 1.05;
}

.match3-card p {
  margin: 8px 0 18px;
  font-size: clamp(15px, 2.2vw, 19px);
  line-height: 1.45;
}

.match3-kicker {
  color: #a36f22;
  font-size: 13px !important;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.match3-button,
.match3-link {
  min-height: 48px;
  display: inline-grid;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 13px;
  padding: 10px 20px;
  background: #e9b53e;
  color: #26313f;
  box-shadow: 0 8px 18px rgba(145, 101, 15, 0.2);
  font-size: 17px;
  font-weight: 900;
  text-decoration: none;
  cursor: var(--match3-cursor-action);
}

.match3-link {
  background: #dfe7eb;
}

.match3-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.match3-final-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 20px;
}

.match3-final-word {
  width: 70px;
  border: 2px solid #f0d78b;
  border-radius: 12px;
  padding: 5px;
  background: #ffffff;
  color: #4b5660;
  font-size: 11px;
  font-weight: 800;
}

.match3-final-word img {
  width: 100%;
  height: 48px;
  display: block;
  object-fit: contain;
}

.match3-error {
  position: absolute;
  inset: 20% 10% auto;
  z-index: 30;
  border-radius: 16px;
  padding: 20px;
  background: #fffaf0;
  color: #7a3b31;
  text-align: center;
}

@media (max-width: 900px) and (orientation: portrait) {
  .match3-hud {
    top: max(62px, calc(env(safe-area-inset-top) + 58px));
    width: calc(100% - max(14px, env(safe-area-inset-left)) - max(14px, env(safe-area-inset-right)));
  }

  .match3-help {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .match3-sounds {
    left: max(8px, env(safe-area-inset-left));
    bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  .match3-hud {
    min-height: 46px;
    padding: 5px 7px;
  }

  .match3-score {
    min-width: 100px;
    gap: 4px;
    font-size: 16px;
  }

  .match3-score-star {
    width: 29px;
    height: 29px;
    font-size: 26px;
  }

  .match3-collected {
    display: none;
  }

  .match3-sounds-label {
    display: none;
  }

  .match3-sound,
  .match3-hint {
    min-width: 40px;
    min-height: 44px;
  }

  .match3-status {
    max-width: 54vw;
    padding: 7px 9px;
  }
}

@media (max-width: 520px) and (orientation: portrait) {
  .match3-help {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(70px, calc(env(safe-area-inset-bottom) + 68px));
  }

  .match3-status {
    max-width: calc(100vw - max(70px, calc(env(safe-area-inset-right) + 62px)));
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 500px) {
  .match3-hud {
    top: max(6px, env(safe-area-inset-top));
    width: min(55vw, 500px);
    min-height: 42px;
    padding: 4px 7px;
  }

  .match3-score {
    min-width: 101px;
    font-size: 16px;
  }

  .match3-score-star {
    width: 28px;
    height: 28px;
    font-size: 25px;
  }

  .match3-collected {
    display: none;
  }

  .match3-sounds {
    left: max(8px, env(safe-area-inset-left));
    bottom: max(8px, env(safe-area-inset-bottom));
    padding: 4px;
  }

  .match3-sound,
  .match3-hint {
    min-width: 38px;
    min-height: 40px;
    padding: 0 8px;
    font-size: 17px;
  }

  .match3-help {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .match3-status {
    max-width: 35vw;
    padding: 5px 9px;
    font-size: 12px;
  }

  .match3-overlay {
    padding: 62px max(70px, calc(env(safe-area-inset-left) + 58px)) 10px;
  }

  .match3-card {
    width: min(100%, 620px);
    padding: 12px 20px;
  }

  .match3-card h2 {
    margin-bottom: 4px;
    font-size: 26px;
  }

  .match3-card p {
    margin: 5px 0 10px;
    font-size: 14px;
  }

  .match3-kicker {
    display: none;
  }

  .match3-button,
  .match3-link {
    min-height: 40px;
    padding: 6px 16px;
    font-size: 15px;
  }

  .match3-final-words {
    margin: 6px 0 9px;
  }

  .match3-final-word {
    width: 56px;
    padding: 3px;
  }

  .match3-final-word img {
    height: 33px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .match3-progress-fill {
    transition: none;
  }
}
