/* ================================================================
   ROCK PAPER SCISSORS — STYLES
   ================================================================ */

:root {
  --violet-deep: #3E1F6B;
  --violet-mid: #6B2FA0;
  --pink-hot: #F72585;
  --blue-electric: #3A86FF;
  --orange-sunny: #FF9F1C;
  --lime-zing: #B9FF66;
  --cream: #FFF8F0;
  --cream-dim: #EDE3FF;
  --ink: #241436;
  --shadow-hard: 0 8px 0 rgba(36, 20, 54, 0.9);
  --shadow-hard-sm: 0 5px 0 rgba(36, 20, 54, 0.9);
  --radius: 26px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Nunito', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 159, 28, 0.35), transparent 40%),
    radial-gradient(circle at 88% 15%, rgba(58, 134, 255, 0.35), transparent 42%),
    radial-gradient(circle at 50% 100%, rgba(247, 37, 133, 0.30), transparent 55%),
    linear-gradient(160deg, var(--violet-deep), var(--violet-mid));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-x: hidden;
}

.app { width: 100%; max-width: 520px; }
h1, h2, h3 { font-family: 'Baloo 2', sans-serif; margin: 0; }

.card {
  background: var(--cream);
  border-radius: var(--radius);
  border: 4px solid var(--ink);
  box-shadow: var(--shadow-hard);
  padding: 32px 28px;
  position: relative;
}

.screen { display: none; animation: pop-in .35s ease; }
.screen.active { display: block; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Header / hero ---------- */
.hero { text-align: center; margin-bottom: 22px; }
.hero .emoji-row { font-size: 44px; line-height: 1; margin-bottom: 6px; letter-spacing: 6px; }
.hero h1 { font-size: 32px; font-weight: 800; color: var(--ink); letter-spacing: .5px; }
.hero h1 span { color: var(--pink-hot); }
.hero p { margin: 6px 0 0; font-weight: 700; color: #6b5a85; font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: block; width: 100%; text-align: center;
  font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 19px;
  color: var(--ink);
  background: var(--lime-zing);
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow-hard-sm);
  padding: 14px 18px;
  cursor: pointer;
  transition: transform .08s ease;
  margin-top: 14px;
}
.btn:active { transform: translateY(5px); box-shadow: none; }
.btn.secondary { background: var(--blue-electric); color: var(--cream); }
.btn.pink { background: var(--pink-hot); color: var(--cream); }
.btn.ghost {
  background: transparent; box-shadow: none; border: 3px dashed #b7a6d6;
  color: #6b5a85; font-size: 15px; padding: 10px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

input[type=text] {
  width: 100%; font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 17px;
  padding: 14px 16px; border: 3px solid var(--ink); border-radius: 14px;
  background: #fff; color: var(--ink); outline: none; margin-top: 6px;
}
input[type=text]:focus { border-color: var(--pink-hot); }

label { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: #6b5a85; }
.field { margin-bottom: 16px; }
.error-msg { color: var(--pink-hot); font-weight: 800; font-size: 14px; margin-top: 8px; display: none; }

.tabs { display: flex; gap: 10px; margin-bottom: 20px; }
.tab {
  flex: 1; text-align: center; padding: 10px; border-radius: 14px; border: 3px solid var(--ink);
  font-family: 'Baloo 2'; font-weight: 700; cursor: pointer; background: #fff;
}
.tab.active { background: var(--orange-sunny); }

/* ---------- Lobby ---------- */
.code-box {
  text-align: center; background: var(--violet-deep); color: var(--cream);
  border-radius: 18px; padding: 18px; margin: 16px 0;
}
.code-box .code {
  font-family: 'Space Mono', monospace; font-size: 38px; font-weight: 700; letter-spacing: 8px;
  color: var(--lime-zing);
}
.code-box .label { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; opacity: .85; margin-bottom: 4px; }

.waiting-dots span {
  display: inline-block; width: 9px; height: 9px; margin: 0 3px;
  border-radius: 50%; background: var(--pink-hot); animation: bounce 1.2s infinite ease-in-out;
}
.waiting-dots span:nth-child(2) { animation-delay: .15s; }
.waiting-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } }

.players-row { display: flex; justify-content: space-between; align-items: center; margin: 18px 0; }
.player-chip { text-align: center; flex: 1; }
.player-chip .avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--orange-sunny);
  border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin: 0 auto 6px;
}
.player-chip.p2 .avatar { background: var(--blue-electric); }
.player-chip .name { font-weight: 800; font-size: 14px; }
.vs-mid { font-family: 'Baloo 2'; font-weight: 800; font-size: 20px; color: #b7a6d6; padding: 0 8px; }

/* ---------- Game arena ---------- */
.score-track { display: flex; justify-content: center; gap: 8px; margin-bottom: 6px; }
.pip { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; }
.pip.p1-win { background: var(--orange-sunny); }
.pip.p2-win { background: var(--blue-electric); }
.score-labels { display: flex; justify-content: space-between; font-weight: 800; font-size: 13px; color: #6b5a85; margin-bottom: 18px; }
.round-label { text-align: center; font-family: 'Baloo 2'; font-weight: 700; font-size: 15px; color: #6b5a85; margin-bottom: 8px; letter-spacing: 1px; text-transform: uppercase; }

.arena { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 8px; }
.fighter { flex: 1; text-align: center; }
.fist { font-size: 56px; display: inline-block; transform-origin: center; }
.fist.shaking { animation: shake .4s infinite; }
@keyframes shake { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.fist.impact { animation: impact .45s ease; }
@keyframes impact { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.fighter .who { font-weight: 800; font-size: 13px; margin-top: 4px; color: #6b5a85; }
.vs-big { font-family: 'Baloo 2'; font-size: 22px; font-weight: 800; color: var(--pink-hot); padding: 0 6px; }

.choices { display: flex; gap: 12px; margin-top: 18px; }
.choice-btn {
  flex: 1; background: #fff; border: 4px solid var(--ink); border-radius: 18px;
  padding: 16px 6px; text-align: center; cursor: pointer; box-shadow: var(--shadow-hard-sm);
  transition: transform .08s ease;
}
.choice-btn:active { transform: translateY(5px); box-shadow: none; }
.choice-btn .ic { font-size: 34px; display: block; margin-bottom: 6px; }
.choice-btn .lb { font-family: 'Baloo 2'; font-weight: 700; font-size: 13px; }
.choice-btn.rock { background: var(--orange-sunny); }
.choice-btn.paper { background: var(--blue-electric); color: var(--cream); }
.choice-btn.scissors { background: var(--pink-hot); color: var(--cream); }
.choice-btn.picked { outline: 4px solid var(--lime-zing); }
.choice-btn:disabled { opacity: .35; cursor: not-allowed; }

.status-line { text-align: center; font-weight: 800; color: #6b5a85; margin-top: 14px; font-size: 14px; }

.result-banner {
  text-align: center; margin: 14px 0 4px; font-family: 'Baloo 2'; font-weight: 800; font-size: 24px;
  padding: 10px; border-radius: 14px; display: none;
}
.result-banner.win { background: var(--lime-zing); }
.result-banner.lose { background: #ffd1e6; }
.result-banner.tie { background: #ffe9b3; }

/* ---------- Match over ---------- */
.trophy { text-align: center; font-size: 64px; margin-bottom: 6px; }
.final-title { text-align: center; font-size: 26px; margin-bottom: 4px; }
.final-sub { text-align: center; color: #6b5a85; font-weight: 700; margin-bottom: 16px; }

.rules-footer { text-align: center; font-size: 12px; color: #8a7aab; font-weight: 700; margin-top: 16px; }

/* ---------- Effects ---------- */
.confetti { position: fixed; top: -10px; width: 10px; height: 14px; z-index: 5; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(400deg); opacity: .9; } }

.connecting-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 3px solid rgba(36, 20, 54, 0.2);
  border-top-color: var(--pink-hot);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .fist.shaking, .fist.impact, .confetti, .connecting-spinner { animation: none !important; }
}
