/* Rock Paper Scissors — hands only, balanced layout */

:root {
  --bg: #f4f1ec;
  --text: #1c1917;
  --text-muted: #78716c;
  --player: #2563eb;
  --computer: #dc2626;
  --win: #16a34a;
  --lose: #dc2626;
  --draw: #ca8a04;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --bounce-low: 22px;
  --bounce-high: -10px;
  --hand-w: clamp(100px, 34vw, 165px);
  --hand-h: clamp(120px, 40vw, 195px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#effects-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
}

.game-container {
  width: 100%;
  max-width: 720px;
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 10px;
  position: relative;
  margin: 0 auto;
}

/* Score — small, clear top padding */
.score-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.score-item strong {
  font-size: 0.95rem;
  font-weight: 800;
  margin-left: 4px;
}

.score-you strong { color: var(--player); }
.score-cpu strong { color: var(--computer); }

.score-vs {
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.55;
}

.score-pop { animation: score-pop 0.35s ease; }

@keyframes score-pop {
  50% { transform: scale(1.2); }
}

/* Arena */
.arena-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
}

/* Result banner — top of arena, clear of hands */
.result-banner {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 10px 16px;
  margin: 0 auto;
  width: min(100%, 320px);
  min-height: 72px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  box-shadow: 0 1px 6px rgba(28, 25, 23, 0.06);
}

.game-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  animation: prompt-pulse 1.4s ease-in-out infinite;
}

.game-prompt.hidden { display: none; }

.prompt-main {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.prompt-sub {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.35;
}

@keyframes prompt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.result-status {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.2;
}

.result-win { color: var(--win); }
.result-lose { color: var(--lose); }
.result-draw { color: var(--draw); }

.trophy-wrapper {
  display: none;
  height: 22px;
  align-items: center;
}

.trophy-wrapper.show { display: flex; }

.trophy-img { width: 22px; height: 22px; }

.result-explanation {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.4;
}

.result-explanation .hl-player { color: var(--player); font-weight: 700; }
.result-explanation .hl-computer { color: var(--computer); font-weight: 700; }

.btn-next {
  display: none;
  margin-top: 2px;
  padding: 7px 16px;
  border: none;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-next.show { display: inline-block; }

/* Hands row — equal columns, same baseline */
.hands-row {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 8px;
  padding-bottom: 4px;
}

.fighter {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 100%;
  min-height: 0;
}

.hand-pit {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  padding-bottom: 6px;
}

.hand-pit::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 20%;
  right: 20%;
  height: 6px;
  border-radius: 50%;
  background: rgba(28, 25, 23, 0.1);
  filter: blur(2px);
}

.hand-pit:has(.hand-bouncer.bouncing)::after {
  animation: shadow-bounce 0.45s ease-in-out infinite;
}

@keyframes shadow-bounce {
  0%, 100% { transform: scaleX(1); opacity: 0.6; }
  50% { transform: scaleX(0.72); opacity: 0.28; }
}

.hand-bouncer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  will-change: transform;
}

.hand-bouncer.bouncing {
  animation: hand-bounce 0.45s ease-in-out infinite;
}

.hand-bouncer.bouncing.computer-delay {
  animation-delay: 0.07s;
}

@keyframes hand-bounce {
  0%, 100% { transform: translateY(var(--bounce-low)); }
  50% { transform: translateY(var(--bounce-high)); }
}

.hand-bouncer.locked {
  animation: hand-lock 0.28s ease forwards;
}

@keyframes hand-lock {
  0% { transform: translateY(var(--bounce-high)); }
  60% { transform: translateY(4px); }
  100% { transform: translateY(0); }
}

.hand-bouncer.reveal-pop {
  animation: reveal-pop 0.4s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

@keyframes reveal-pop {
  0% { transform: translateY(var(--bounce-low)) scale(0.92); }
  70% { transform: translateY(-4px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

.hand-img {
  width: var(--hand-w);
  height: var(--hand-h);
  object-fit: contain;
  object-position: bottom center;
  mix-blend-mode: multiply;
  pointer-events: none;
  display: block;
}

.hand-img.mirrored {
  transform: scaleX(-1);
}

/* Mobile tap hints */
.tap-zones {
  position: absolute;
  left: 0;
  right: 0;
  top: 52px;
  bottom: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  z-index: 2;
}

.tap-zones.disabled {
  pointer-events: none;
}

.tap-zone {
  background: transparent;
  border: none;
  cursor: pointer;
}

.tap-zone:disabled { cursor: default; }

/* Short iframe / mobile */
@media (max-height: 480px) {
  :root {
    --hand-w: clamp(80px, 28vw, 130px);
    --hand-h: clamp(96px, 34vw, 155px);
    --bounce-low: 16px;
    --bounce-high: -8px;
  }

  .game-container { padding: 8px 12px 6px; }
  .score-bar { padding: 4px 6px 6px; font-size: 0.72rem; }
  .result-banner { min-height: 58px; padding: 8px 12px; }
  .result-status { font-size: 0.95rem; }
}

@media (min-width: 520px) {
  :root {
    --hand-w: 165px;
    --hand-h: 195px;
  }
}
