* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at top, rgba(255, 204, 120, 0.18), transparent 30%),
    linear-gradient(180deg, #130d09 0%, #20140d 22%, #3a2416 56%, #100905 100%);
  color: #fff7ee;
}

body.word-bowling-strike::after,
body.word-bowling-miss::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 120;
}

body.word-bowling-strike::after {
  background:
    radial-gradient(circle at center, rgba(255, 232, 158, 0.34), transparent 42%),
    linear-gradient(180deg, rgba(255, 185, 76, 0.18), transparent 55%);
  animation: wordBowlingFlash 640ms ease-out;
}

body.word-bowling-miss::after {
  background: rgba(188, 64, 45, 0.18);
  animation: wordBowlingFlash 340ms ease-out;
}

@keyframes wordBowlingFlash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

#gameScreen {
  position: fixed;
  inset: 0;
}

#gameScreen .full-game-card {
  position: relative;
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
}

#wordBowlingThreeRoot,
#wordBowlingThreeRoot canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#wordBowlingThreeRoot {
  z-index: 1;
}

.word-bowling-backdrop {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 241, 222, 0.09), transparent 20%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 24%, transparent 70%, rgba(0, 0, 0, 0.22));
}

#gameScreen .topbar {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px;
  right: 12px;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  margin: 0;
  padding: 0;
}

#gameScreen .topbar-title {
  display: none;
}

#gameScreen .game-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  max-width: min(44vw, 270px);
}

#gameScreen .back {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 10px;
  z-index: 80;
  width: auto;
  max-width: 128px;
  min-height: 44px;
  padding: 7px 12px;
  border-radius: 18px;
  font-size: 12px;
  line-height: 1.1;
  white-space: normal;
}

.word-bowling-hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 138px);
  left: 12px;
  right: 12px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.word-bowling-kicker {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(26, 14, 7, 0.62);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.word-bowling-source {
  min-width: min(86vw, 420px);
  max-width: min(92vw, 560px);
  padding: 15px 20px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.98), rgba(255, 234, 207, 0.92));
  color: #351a0d;
  box-shadow:
    0 24px 55px rgba(3, 10, 18, 0.2),
    0 0 0 2px rgba(255, 245, 228, 0.82);
  text-align: center;
  font-size: clamp(28px, 7vw, 48px);
  font-weight: 900;
  line-height: 1.06;
  letter-spacing: 0.01em;
  text-wrap: balance;
  word-break: break-word;
}

.word-bowling-tts {
  pointer-events: auto;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(255, 241, 228, 0.14);
  color: #fff7ee;
  font-size: 15px;
  font-weight: 800;
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.18);
}

.word-bowling-tts:active {
  transform: scale(0.98);
}

.word-bowling-feedback {
  min-height: 28px;
  max-width: min(90vw, 620px);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  text-wrap: balance;
  color: #fff7ee;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  transition: opacity 180ms ease, transform 180ms ease;
}

.word-bowling-feedback.is-hidden {
  opacity: 0;
  transform: translateY(-6px);
}

.word-bowling-feedback.is-good {
  background: rgba(204, 134, 42, 0.24);
}

.word-bowling-feedback.is-warn {
  background: rgba(168, 71, 53, 0.24);
}

.word-bowling-strike {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 230px);
  z-index: 50;
  width: min(86vw, 430px);
  min-height: 108px;
  padding: 18px 24px;
  border-radius: 32px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.9), transparent 18%),
    linear-gradient(135deg, rgba(255, 245, 185, 0.98), rgba(255, 178, 54, 0.96) 48%, rgba(255, 112, 51, 0.96));
  color: #3d1707;
  text-align: center;
  font-size: clamp(25px, 7vw, 44px);
  font-weight: 950;
  line-height: 1.08;
  letter-spacing: 0.03em;
  text-transform: none;
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow:
    0 26px 58px rgba(0, 0, 0, 0.36),
    0 0 42px rgba(255, 186, 64, 0.52),
    inset 0 2px 0 rgba(255, 255, 255, 0.78),
    inset 0 -8px 20px rgba(122, 43, 6, 0.15);
  transform: translate(-50%, 18px) scale(0.82) rotate(-1.5deg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 260ms cubic-bezier(.2, 1.35, .28, 1);
}

.word-bowling-strike.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1) rotate(-1.5deg);
}

.word-bowling-loading {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(15, 9, 5, 0.76), rgba(11, 6, 3, 0.82));
  backdrop-filter: blur(10px);
}

.word-bowling-loading[hidden] {
  display: none;
}

.word-bowling-loading-card {
  width: min(84vw, 320px);
  padding: 24px 20px;
  border-radius: 28px;
  background: rgba(42, 23, 13, 0.9);
  border: 1px solid rgba(255, 243, 228, 0.1);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.28);
  text-align: center;
  font-size: 18px;
  font-weight: 800;
}

.word-bowling-loading-pins {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 12px;
  margin: 0 auto 16px;
  height: 64px;
}

.word-bowling-loading-pins span {
  display: block;
  width: 20px;
  height: 58px;
  border-radius: 10px 10px 8px 8px;
  background:
    linear-gradient(180deg, #fff 0 34%, #c43b25 35% 42%, #fff 43% 52%, #c43b25 53% 60%, #fff 61% 100%);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.2);
  transform-origin: 50% 90%;
  animation: wordBowlingPinBounce 900ms ease-in-out infinite;
}

.word-bowling-loading-pins span:nth-child(2) {
  animation-delay: 120ms;
}

.word-bowling-loading-pins span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes wordBowlingPinBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-6px) rotate(-6deg); }
  60% { transform: translateY(0) rotate(5deg); }
}

@media (max-width: 900px) {
  .word-bowling-hud {
    top: calc(env(safe-area-inset-top, 0px) + 92px);
  }

  .word-bowling-source {
    max-width: min(94vw, 520px);
    font-size: clamp(24px, 7vw, 40px);
  }

  .word-bowling-strike {
    top: calc(env(safe-area-inset-top, 0px) + 190px);
  }
}

@media (max-width: 640px) {
  #gameScreen .topbar {
    right: 10px;
    left: 10px;
  }

  #gameScreen .game-stats {
    max-width: min(52vw, 240px);
    gap: 6px;
  }

  .word-bowling-kicker {
    font-size: 12px;
  }

  .word-bowling-source {
    min-width: min(92vw, 360px);
    padding: 13px 16px;
  }

  .word-bowling-feedback {
    font-size: 15px;
    max-width: min(94vw, 540px);
  }

  .word-bowling-strike {
    min-width: 140px;
    max-width: 80vw;
    padding: 12px 18px;
  }
}
.word-bowling-strike-img {
  display: block;
  width: min(62vw, 260px);
  height: min(62vw, 260px);
  object-fit: contain;
  margin: -18px auto 4px;
  filter:
    drop-shadow(0 18px 24px rgba(66, 22, 4, 0.42))
    drop-shadow(0 0 28px rgba(255, 204, 82, 0.55));
}

.word-bowling-strike-title {
  font-size: clamp(26px, 7vw, 44px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.word-bowling-strike-pair {
  margin-top: 8px;
  font-size: clamp(18px, 4.6vw, 28px);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: 0;
  text-transform: none;
}

body.pvp-searching #wordBowlingThreeRoot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: grayscale(1) blur(2px);
  pointer-events: auto;
}

html body #pvpSearchBtn,
html body #pvpCancelBtn,
html body #pvpHint {
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 118px);
}

@media (max-width: 640px) {
  html body #pvpSearchBtn,
  html body #pvpCancelBtn,
  html body #pvpHint {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 132px);
  }
}
