:root {
  --bg: #0c0a14;
  --bg2: #14101f;
  --card: #1a1528;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f3f0ff;
  --muted: #9b93b5;
  --primary: #ff4d6d;
  --primary2: #c9184a;
  --accent: #7b2cbf;
  --win: #34d399;
  --draw: #fbbf24;
  --loss: #f87171;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

input {
  user-select: text;
  -webkit-user-select: text;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(255, 77, 109, 0.22), transparent 55%),
    radial-gradient(700px 400px at 100% 20%, rgba(123, 44, 191, 0.2), transparent 50%),
    radial-gradient(600px 300px at 50% 100%, rgba(52, 211, 153, 0.08), transparent 45%),
    var(--bg);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-top)) 16px calc(20px + var(--safe-bot));
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.screen.active {
  display: flex;
}

.hero {
  text-align: center;
  padding: 20px 8px 4px;
}

.logo-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 2rem;
  filter: drop-shadow(0 8px 20px rgba(255, 77, 109, 0.35));
}

.logo-row .hand {
  animation: bob 2.4s ease-in-out infinite;
}
.logo-row .hand:nth-child(2) {
  animation-delay: 0.2s;
}
.logo-row .hand:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

h1 {
  margin: 12px 0 6px;
  font-size: 2.2rem;
  letter-spacing: -0.04em;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 30%, #ff8fa3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 50%), var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stack.center {
  align-items: center;
  text-align: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field .opt {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.8;
}

.field input {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  border-radius: 12px;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  outline: none;
  text-transform: none;
  letter-spacing: normal;
}

#home-code {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-family: var(--mono);
  text-align: center;
  font-size: 1.25rem;
}

.field input:focus {
  border-color: rgba(255, 77, 109, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.15);
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.avatar-opt {
  appearance: none;
  border: 2px solid transparent;
  background: var(--bg2);
  border-radius: 14px;
  aspect-ratio: 1;
  font-size: 1.45rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.1s ease, border-color 0.15s;
}

.avatar-opt.on {
  border-color: var(--primary);
  background: rgba(255, 77, 109, 0.12);
  transform: scale(1.06);
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.15);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 15px 18px;
  font: inherit;
  font-weight: 750;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, #ff6b85, var(--primary));
  color: white;
  box-shadow: 0 10px 28px rgba(255, 77, 109, 0.35);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn.small {
  padding: 8px 12px;
  font-size: 0.85rem;
  border-radius: 10px;
}

.hidden {
  display: none !important;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.bottom-links {
  text-align: center;
  margin-top: 4px;
}

.linkish {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 10px;
}

.linkish:active {
  color: var(--text);
}

/* Play */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.room-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.room-badge strong {
  font-family: var(--mono);
  letter-spacing: 0.18em;
  font-size: 1.1rem;
}

.muted {
  color: var(--muted);
}

.muted.small {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.stake-banner {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 14px;
  padding: 10px 14px;
  text-align: center;
}

.stake-text {
  font-weight: 750;
  font-size: 1.05rem;
  margin-top: 2px;
}

.vs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
}

.vs-player {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.vs-player.them {
  flex-direction: row-reverse;
  text-align: right;
}

.vs-av {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.vs-meta {
  min-width: 0;
}

.vs-meta .n {
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vs-meta .s {
  font-size: 0.75rem;
  color: var(--muted);
}

.vs-mid {
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  opacity: 0.7;
}

.phase {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-height: 0;
}

.big-wait {
  font-size: 1.25rem;
  font-weight: 750;
  margin: 0;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.hint.center {
  text-align: center;
}

.prompt {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 750;
  margin: 0 0 4px;
}

.move-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.move-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 20px;
  padding: 22px 10px;
  color: var(--text);
  font: inherit;
  font-weight: 750;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}

.move-btn:active {
  transform: scale(0.96);
}

.move-btn.selected {
  border-color: var(--primary);
  background: rgba(255, 77, 109, 0.14);
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.18);
}

.move-btn.locked {
  opacity: 0.55;
  pointer-events: none;
}

.move-emoji {
  font-size: 2.6rem;
  line-height: 1;
}

/* Reveal arena */
.arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px;
  padding: 20px 0 8px;
  min-height: 240px;
}

.fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.fighter-avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  background: var(--bg2);
  border: 1px solid var(--border);
}

.fighter-name {
  font-weight: 750;
  font-size: 0.85rem;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fist {
  font-size: 4.5rem;
  line-height: 1;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.4));
  transform-origin: 50% 80%;
}

.arena.pumping .fist {
  animation: pump 0.45s ease-in-out infinite;
}

.arena.pumping .fighter.right .fist {
  animation-delay: 0.08s;
}

@keyframes pump {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-18px) rotate(-8deg);
  }
}

.fighter.right .fist {
  transform: scaleX(-1);
}

.arena.pumping .fighter.right .fist {
  animation-name: pump-mirror;
}

@keyframes pump-mirror {
  0%,
  100% {
    transform: scaleX(-1) translateY(0) rotate(0deg);
  }
  50% {
    transform: scaleX(-1) translateY(-18px) rotate(8deg);
  }
}

.arena.reveal .fist {
  animation: pop-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes pop-in {
  0% {
    transform: scale(0.3) translateY(20px);
    opacity: 0.2;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.arena.reveal .fighter.right .fist {
  animation: pop-in-mirror 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes pop-in-mirror {
  0% {
    transform: scaleX(-1) scale(0.3) translateY(20px);
    opacity: 0.2;
  }
  100% {
    transform: scaleX(-1) scale(1) translateY(0);
    opacity: 1;
  }
}

.vs-flash {
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  color: var(--primary);
  padding-bottom: 48px;
  opacity: 0.85;
  text-shadow: 0 0 24px rgba(255, 77, 109, 0.5);
}

.chant {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  min-height: 2em;
}

.chant.shoot {
  color: var(--primary);
  font-size: 2.2rem;
  animation: shoot-flash 0.5s ease;
}

@keyframes shoot-flash {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  40% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* Result */
.result-emoji {
  font-size: 3.2rem;
  line-height: 1;
}

.result-card h2 {
  margin: 0;
  font-size: 1.7rem;
}

.result-moves {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-size: 2.4rem;
  padding: 8px 0;
}

.result-moves .sep {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 800;
}

.scoreline {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Stats */
.stats-hero {
  text-align: center;
}

.stat-big .num {
  font-size: 3rem;
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-big .lab {
  color: var(--muted);
  font-weight: 650;
  margin-top: 6px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.stat-row div {
  background: var(--bg2);
  border-radius: 12px;
  padding: 10px 6px;
  border: 1px solid var(--border);
}

.stat-row span {
  display: block;
  font-weight: 800;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.stat-row small {
  color: var(--muted);
  font-size: 0.75rem;
}

h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100px;
  padding-top: 8px;
}

.bar-chart .bar {
  flex: 1;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  position: relative;
  opacity: 0.9;
}

.bar-chart .bar span {
  display: none;
}

.country-list,
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.country-row,
.recent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg2);
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.country-row .left,
.recent-row .left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 650;
}

.country-row .right {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.flag {
  font-size: 1.2rem;
}

.recent-row {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.recent-row .top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.recent-row .bot {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
}

.empty-note {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 12px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bot));
  transform: translateX(-50%);
  z-index: 100;
  background: #1e1530;
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 650;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
  max-width: calc(100% - 32px);
  text-align: center;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
