:root {
  --primary: #6C35FF;
  --secondary: #2CD7FF;
  --dark: #111827;
  --text: #374151;
  --muted: #6B7280;
  --white: #FFFFFF;
  --soft: #F7FBFF;
  --card: rgba(255, 255, 255, 0.9);
  --border: rgba(108, 53, 255, 0.14);
  --shadow: 0 24px 70px rgba(75, 48, 180, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(44, 215, 255, 0.26), transparent 34%),
    radial-gradient(circle at bottom right, rgba(108, 53, 255, 0.28), transparent 35%),
    linear-gradient(135deg, #ffffff 0%, #f5f8ff 48%, #eef8ff 100%);
  color: var(--dark);
}

body.game-page {
  overscroll-behavior: none;
}

a {
  color: inherit;
}

.page-shell {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.hero-card {
  width: 100%;
  max-width: 980px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 34px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.narrow-card {
  max-width: 620px;
}

.topbar,
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.center-topbar {
  justify-content: center;
}

.logo {
  width: 150px;
  height: auto;
  display: block;
}

.brand-link {
  text-decoration: none;
}

.small-link {
  text-decoration: none;
  color: var(--primary);
  font-weight: 800;
  background: rgba(108, 53, 255, 0.09);
  padding: 10px 14px;
  border-radius: 999px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 26px;
  align-items: stretch;
  margin-top: 28px;
}

.hero-copy,
.leader-card {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 24px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(108, 53, 255, 0.1);
  color: var(--primary);
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.14;
  margin-bottom: 16px;
  margin-top: 18px;
}

h2 {
  font-size: 24px;
  margin-bottom: 14px;
}

p {
  color: var(--text);
  line-height: 1.85;
  font-size: 17px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.actions.centered {
  justify-content: center;
}

.btn {
  border: 0;
  min-height: 50px;
  padding: 0 22px;
  border-radius: 16px;
  font-weight: 900;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  font-family: inherit;
}

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

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-primary {
  color: var(--white);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 12px 30px rgba(108, 53, 255, 0.26);
}

.btn-secondary {
  color: var(--primary);
  background: rgba(108, 53, 255, 0.09);
}

.microcopy {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.leaderboard {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(108, 53, 255, 0.12);
  padding: 12px;
  border-radius: 16px;
  color: var(--dark);
}

.leaderboard .rank {
  font-size: 20px;
}

.leaderboard .player {
  direction: ltr;
  text-align: left;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.leaderboard .points {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  min-width: 50px;
  text-align: center;
}

.leaderboard-big {
  margin: 26px 0;
}

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

.game-shell {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.game-header {
  margin-bottom: 10px;
}

.mini-logo {
  width: 92px;
  height: auto;
  display: block;
}

.game-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.game-stats span {
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(108, 53, 255, 0.13);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 900;
}

.game-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.72);
  background: #ffffff;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.overlay-panel {
  position: absolute;
  inset: 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  text-align: center;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(108, 53, 255, 0.14);
  border-radius: 24px;
  padding: 20px;
  backdrop-filter: blur(16px);
}

.overlay-panel h1,
.overlay-panel h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.hidden {
  display: none !important;
}

.input-label {
  margin-top: 8px;
  margin-bottom: 8px;
  font-weight: 900;
  color: var(--dark);
}

.text-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(108, 53, 255, 0.22);
  border-radius: 16px;
  padding: 0 14px;
  font-size: 16px;
  direction: ltr;
  text-align: left;
  font-weight: 800;
  outline-color: var(--primary);
  font-family: inherit;
}

.message {
  min-height: 22px;
  margin-top: 12px;
  margin-bottom: 0;
  font-weight: 800;
  color: var(--primary);
  font-size: 14px;
}

.message.error {
  color: #b91c1c;
}

.result-leaders {
  margin-top: 12px;
}

.result-leaders h3 {
  margin-bottom: 8px;
}

.leaderboard.small {
  gap: 6px;
}

.leaderboard.small li {
  padding: 8px;
  border-radius: 12px;
  font-size: 14px;
}

.game-hint {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin: 12px 0 0;
  font-weight: 700;
}

@media (max-width: 800px) {
  .page-shell {
    padding: 14px;
  }

  .hero-card {
    padding: 18px;
    border-radius: 28px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .leader-card {
    padding: 18px;
    border-radius: 22px;
  }

  .logo {
    width: 132px;
  }
}

@media (max-width: 480px) {
  .topbar {
    align-items: flex-start;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .leaderboard li {
    grid-template-columns: 34px 1fr auto;
    padding: 10px;
  }

  .game-shell {
    padding: 8px;
  }

  .overlay-panel {
    inset: 10px;
    padding: 16px;
  }

  .game-stats span {
    font-size: 13px;
    padding: 7px 9px;
  }
}
