:root {
  --bg-top: #fff7d9;
  --bg-bottom: #d8f3ff;
  --card: rgba(255, 255, 255, 0.9);
  --text: #203040;
  --primary: #ff6b35;
  --primary-strong: #db4f20;
  --secondary: #2a9d8f;
  --secondary-strong: #1f7f74;
  --ghost: #607d8b;
  --ghost-strong: #4e6672;
  --ok: #217a36;
  --error: #9e2a2b;
  --shadow: 0 12px 30px rgba(32, 48, 64, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Nunito", "Segoe UI", sans-serif;
  background: linear-gradient(170deg, var(--bg-top), var(--bg-bottom));
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(2px);
  z-index: -1;
  animation: float 8s ease-in-out infinite;
}

.bg-shape-1 {
  width: 360px;
  height: 360px;
  background: rgba(255, 107, 53, 0.18);
  top: -120px;
  left: -110px;
}

.bg-shape-2 {
  width: 300px;
  height: 300px;
  background: rgba(42, 157, 143, 0.2);
  bottom: -80px;
  right: -70px;
  animation-delay: 1.2s;
}

.container {
  width: min(980px, 92vw);
  margin: 0 auto;
}

.hero {
  padding: 2.2rem 0 1.2rem;
  animation: riseIn 600ms ease-out;
}

.badge {
  display: inline-block;
  margin: 0;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: #ffd166;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.1rem;
}

h1,
h2 {
  font-family: "Baloo 2", "Nunito", sans-serif;
  line-height: 1.1;
  margin: 0.45rem 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.hero-text {
  max-width: 52ch;
  margin: 0;
  font-size: 1.1rem;
}

.top-nav {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.version-note {
  margin: 0;
  font-weight: 800;
  color: #46637a;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 0.5rem;
}

.footer-link {
  color: #245a7d;
  font-weight: 800;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.top-nav-link {
  text-decoration: none;
  font-weight: 800;
  color: #245a7d;
  background: #eaf5ff;
  border: 2px solid #d4e8ff;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
}

.top-nav-link:hover {
  border-color: #9fcbff;
}

.top-nav-link.active {
  color: white;
  background: var(--secondary);
  border-color: var(--secondary);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding-bottom: 1.2rem;
}

.legal-layout {
  padding-bottom: 1rem;
}

.legal-card {
  display: grid;
  gap: 1.1rem;
  animation: riseIn 700ms ease-out;
}

.legal-card section {
  display: grid;
  gap: 0.45rem;
}

.legal-card h2 {
  margin: 0;
}

.legal-card p,
.legal-card li {
  margin: 0;
  line-height: 1.6;
}

.legal-card ul {
  margin: 0;
  padding-left: 1.2rem;
}

.legal-note {
  padding: 0.8rem 0.95rem;
  border: 2px solid #ffd59d;
  border-radius: 14px;
  background: #fff6e7;
  font-weight: 800;
}

.game-link-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 2px solid #d4e8ff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.game-link-card:hover {
  transform: translateY(-2px);
  border-color: #9fcbff;
}

.game-link-card h2 {
  margin-top: 0;
}

.game-link-card p {
  margin: 0;
  font-weight: 700;
  color: #46637a;
}

.grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  align-items: start;
  padding-bottom: 1rem;
}

.left-col,
.right-col {
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--card);
  backdrop-filter: blur(6px);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.mode-card h2 {
  margin-bottom: 0.65rem;
}

.game-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.game-tile {
  border: 2px solid #d4e8ff;
  background: #fff;
  border-radius: 14px;
  padding: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.game-tile:hover {
  transform: translateY(-2px);
  border-color: #9fcbff;
}

.game-tile.active {
  border-color: #ffb088;
  box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
}

.game-tile-title {
  display: block;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
}

.game-tile-text {
  display: block;
  margin-top: 0.2rem;
  color: #46637a;
  font-weight: 700;
  font-size: 0.95rem;
}

.chip {
  margin: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: #eaf5ff;
  font-size: 0.9rem;
  white-space: nowrap;
}

.auth-form {
  display: grid;
  gap: 0.5rem;
}

.auth-form label {
  font-weight: 800;
  margin-top: 0.15rem;
}

.auth-form input {
  border: 2px solid #c6ddf5;
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  font: inherit;
}

.auth-form input:focus {
  outline: none;
  border-color: #7fb7f0;
}

.auth-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quiz-area {
  margin-top: 0.55rem;
}

.question {
  margin-top: 0.3rem;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 800;
}

.question-image {
  margin-top: 0.35rem;
  width: min(100%, 380px);
  border-radius: 14px;
  border: 2px solid #d8e9ff;
  background: white;
}

.hint {
  margin: 0.45rem 0 0;
  font-weight: 700;
  color: #46637a;
}

.answers {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.snake-area {
  margin-top: 0.8rem;
}

.snake-canvas {
  width: min(100%, 336px);
  aspect-ratio: 1 / 1;
  background: #132231;
  border: 3px solid #8fc8ff;
  border-radius: 14px;
  display: block;
  touch-action: none;
  overscroll-behavior: contain;
}

.snake-controls {
  display: none;
  margin-top: 0.65rem;
  grid-template-columns: repeat(3, 54px);
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 0.45rem;
  justify-content: start;
}

.snake-btn {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  padding: 0;
  font-size: 1.25rem;
}

.snake-btn.up {
  grid-area: up;
}

.snake-btn.left {
  grid-area: left;
}

.snake-btn.down {
  grid-area: down;
}

.snake-btn.right {
  grid-area: right;
}

.answer-btn {
  border: 2px solid #d4e8ff;
  border-radius: 14px;
  padding: 0.75rem;
  background: white;
  color: inherit;
  text-align: left;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.answer-btn:hover:enabled {
  transform: translateY(-2px);
  border-color: #9fcbff;
}

.answer-btn.correct {
  border-color: #95d5b2;
  background: #edfced;
}

.answer-btn.wrong {
  border-color: #ffadad;
  background: #fff0f0;
}

.answer-btn:disabled {
  cursor: default;
}

.feedback {
  min-height: 1.5rem;
  margin-top: 0.7rem;
  font-weight: 800;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.error {
  color: var(--error);
}

.actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.btn:hover:enabled {
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:enabled {
  background: var(--primary-strong);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover:enabled {
  background: var(--secondary-strong);
}

.btn-ghost {
  background: var(--ghost);
  color: white;
}

.btn-ghost:hover:enabled {
  background: var(--ghost-strong);
}

.side-card {
  animation: riseIn 800ms ease-out;
}

.score-number {
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  margin: 0.35rem 0;
  font-weight: 800;
}

.side-note {
  margin-top: 0;
}

.stars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 2rem;
}

.star {
  font-size: 1.1rem;
  font-weight: 800;
  color: #b37f00;
  animation: popIn 260ms ease-out;
}

.rank-list,
.stats-list,
.achievements-list {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.rank-list li,
.stats-list li,
.achievements-list li {
  margin: 0.24rem 0;
}

.mini-title {
  margin: 0.7rem 0 0.2rem;
  font-weight: 800;
}

.footer {
  text-align: center;
  padding: 0.4rem 0 2rem;
  font-weight: 700;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(10px);
  }
}

@media (max-width: 800px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .game-tiles {
    grid-template-columns: 1fr;
  }

  .auth-actions {
    flex-direction: column;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .answer-btn {
    padding: 0.95rem 1rem;
    font-size: 1rem;
    min-height: 64px;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.35rem;
  }

  .snake-controls {
    display: none;
  }
}
