:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-light: #334155;
  --accent: #38bdf8;
  --accent-dark: #0ea5e9;
  --good: #22c55e;
  --bad: #ef4444;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --radius: 14px;
  --max-width: 720px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--panel-light);
  padding: 10px 16px;
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.brand span {
  color: var(--accent);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.stat .stat-value {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
}

.stat .stat-label {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.progress-track {
  max-width: var(--max-width);
  margin: 8px auto 0;
  height: 6px;
  background: var(--panel-light);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  transition: width 0.3s ease;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 16px 90px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--panel-light);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 8px;
}

p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #08131f;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  transition: transform 0.1s ease, background 0.2s ease, opacity 0.2s ease;
}

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

.btn:disabled,
.btn.disabled {
  background: var(--panel-light);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.btn.secondary {
  background: var(--panel-light);
  color: var(--text);
}

.btn.block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.name-input {
  flex: 1;
  min-width: 140px;
  background: var(--panel-light);
  border: 1px solid var(--panel-light);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}

.name-input:focus {
  outline: none;
  border-color: var(--accent);
}

.rank-cell {
  color: var(--muted);
  font-weight: 700;
  width: 2em;
}

.footer-nav {
  position: sticky;
  bottom: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.97);
  border-top: 1px solid var(--panel-light);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.footer-nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.game-status.ready {
  color: var(--good);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-light);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}

.ad-slot {
  background: var(--panel);
  border: 1px dashed var(--panel-light);
  border-radius: var(--radius);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 10px;
}

canvas {
  touch-action: none;
  display: block;
  max-width: 100%;
  border-radius: 10px;
}

.center {
  text-align: center;
}

.big-number {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--accent);
}

.result-msg {
  font-size: 1.1rem;
  font-weight: 700;
}

table.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.results-table th,
table.results-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--panel-light);
}

table.results-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.score-cell {
  font-weight: 700;
  color: var(--accent);
}

.share-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.share-btn {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: 12px 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  color: #fff;
}

.share-btn.twitter { background: #1d9bf0; }
.share-btn.facebook { background: #1877f2; }
.share-btn.whatsapp { background: #25d366; }

.game-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 420px;
  margin: 0 auto;
  background: var(--panel-light);
  border-radius: var(--radius);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.dot-target {
  position: absolute;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.25);
  pointer-events: none;
}

.reaction-box {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4/3;
  margin: 0 auto;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease;
  text-align: center;
  padding: 20px;
}

.smiley-grid {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 1px;
  background: var(--panel-light);
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.smiley-cell {
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4vw;
  cursor: pointer;
  aspect-ratio: 1 / 1;
}

@media (max-width: 600px) {
  .smiley-cell {
    font-size: 3.6vw;
  }
}

.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 2 / 3;
  margin: 0 auto;
  background: var(--panel-light);
  border-radius: 10px;
  overflow: hidden;
}

.puzzle-piece {
  background-size: 320px 480px;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
}

.puzzle-piece.selected {
  border-color: var(--accent);
}

.puzzle-piece.correct {
  border-color: var(--good);
}

.map-wrap {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
}

.map-wrap img {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  border-radius: var(--radius);
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}

.continent-prompt {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  min-height: 1.6em;
  color: var(--accent);
}

.map-pulse {
  position: absolute;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: -18px;
  border-radius: 50%;
  pointer-events: none;
  animation: map-pulse-anim 0.5s ease-out forwards;
}

.map-pulse-good {
  background: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.8);
}

.map-pulse-bad {
  background: rgba(239, 68, 68, 0.55);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.8);
}

@keyframes map-pulse-anim {
  from {
    transform: scale(0.4);
    opacity: 1;
  }
  to {
    transform: scale(1.8);
    opacity: 0;
  }
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.75);
  z-index: 5;
  border-radius: var(--radius);
}

.click-target {
  position: absolute;
  width: 46px;
  height: 46px;
  margin-left: -23px;
  margin-top: -23px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
}

.hero {
  text-align: center;
  padding: 30px 0 10px;
}

.game-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-list li {
  background: var(--panel);
  border: 1px solid var(--panel-light);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-list .num {
  background: var(--accent);
  color: #08131f;
  font-weight: 800;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}
