* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-0: #0b0f23;
  --bg-1: #131736;
  --panel: rgba(28, 32, 64, 0.55);
  --panel-strong: rgba(28, 32, 64, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ecff;
  --text-dim: #9aa0c2;
  --accent: #7c5cff;
  --accent-2: #43c59e;
  --accent-pink: #ff5577;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg-0);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg, .auth-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 600px at 10% -10%, rgba(124, 92, 255, 0.35), transparent 60%),
    radial-gradient(800px 500px at 110% 10%, rgba(67, 197, 158, 0.22), transparent 60%),
    radial-gradient(700px 600px at 50% 110%, rgba(255, 85, 119, 0.18), transparent 60%),
    linear-gradient(180deg, #0a0d22 0%, #0b0f23 100%);
}

/* === Topbar === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.5rem;
  align-items: center;
  padding: 0.85rem 1.5rem;
  background: rgba(11, 15, 35, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-logo {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 12px rgba(124, 92, 255, 0.6));
}
.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, #fff, #b9b1ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
}
.tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.35), rgba(67, 197, 158, 0.25));
  border-color: rgba(124, 92, 255, 0.55);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.3), 0 8px 20px rgba(124, 92, 255, 0.2);
}

.user-bar { display: flex; align-items: center; gap: 0.6rem; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.65rem 0.3rem 0.3rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
}
.user-name { font-size: 0.9rem; color: var(--text); }
.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}
.logout-btn:hover {
  background: rgba(255, 85, 119, 0.12);
  border-color: rgba(255, 85, 119, 0.45);
  color: #ffb6c5;
}

.content { padding: 2rem; max-width: 1400px; margin: 0 auto; }

/* === Kanban === */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.column {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 480px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.column-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}
.column-head h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-todo { background: #6b8afd; box-shadow: 0 0 8px #6b8afd; }
.dot-progress { background: #ffc04d; box-shadow: 0 0 8px #ffc04d; }
.dot-done { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
.count {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.cards {
  flex: 1;
  min-height: 200px;
  margin-bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(67, 197, 158, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  animation: card-in 0.25s ease;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  border-color: var(--border-strong);
}
.card.removing { opacity: 0; transform: scale(0.95); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-title { flex: 1; word-break: break-word; font-size: 0.92rem; }

.card-actions { display: flex; gap: 0.25rem; }

.card-actions button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}
.card-actions button:hover {
  background: rgba(124, 92, 255, 0.25);
  border-color: rgba(124, 92, 255, 0.55);
  color: #fff;
}
.card-actions button[data-action="delete"]:hover {
  background: rgba(255, 85, 119, 0.25);
  border-color: rgba(255, 85, 119, 0.55);
  color: #fff;
}

.add-card-form {
  display: flex;
  gap: 0.5rem;
}

.add-card-form input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.add-card-form input::placeholder { color: var(--text-dim); }
.add-card-form input:focus {
  border-color: rgba(124, 92, 255, 0.6);
  background: rgba(255, 255, 255, 0.06);
}

.add-card-form button {
  padding: 0.55rem 0.9rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.add-card-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(124, 92, 255, 0.35);
}
.add-card-form button:active { transform: translateY(0); }

/* === Snake === */
.snake-grid {
  display: grid;
  grid-template-columns: auto 320px;
  gap: 1.5rem;
  align-items: start;
}

.snake-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

#snake, #flappy, #blockstack, #racer {
  display: block;
  border-radius: 10px;
  width: 100%;
  max-width: 400px;
  height: auto;
  margin: 0 auto;
  touch-action: none;
}

.football-controls {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0.9rem auto 0;
  width: min(260px, 90%);
}
/* 2048 board */
.g2048-board-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}
.g2048-board {
  width: min(400px, 100%);
  aspect-ratio: 1 / 1;
  background: rgba(10, 14, 32, 0.58);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  position: relative;
  overflow: hidden;
}
.g2048-bg {
  position: absolute;
  inset: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.g2048-bg-cell {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}
.g2048-tiles,
.g2048-ovl-wrap,
.g2048-anim-layer {
  position: absolute;
  inset: 0;
}
.g2048-tile {
  position: absolute;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  user-select: none;
  -webkit-user-select: none;
  color: #d8deff;
  font-size: clamp(1rem, 5vw, 1.7rem);
  transition: transform 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.g2048-tile.moving {
  z-index: 2;
}
.g2048-tile.spawn {
  animation: g2048-spawn 170ms ease;
}
@keyframes g2048-spawn {
  from { opacity: 0.35; filter: brightness(1.35); }
  to { opacity: 1; filter: brightness(1); }
}
.g2048-tile.v-2 { background: #f5f7ff; color: #27344f; }
.g2048-tile.v-4 { background: #e8f0ff; color: #27344f; }
.g2048-tile.v-8 { background: #a8e8c9; color: #11322b; }
.g2048-tile.v-16 { background: #7fdcb5; color: #0f2f25; }
.g2048-tile.v-32 { background: #6ecce7; color: #0f2f3a; }
.g2048-tile.v-64 { background: #57addd; color: #0b2a3f; }
.g2048-tile.v-128 { background: #8c93ff; color: #f2f4ff; font-size: clamp(0.9rem, 4vw, 1.45rem); }
.g2048-tile.v-256 { background: #9f7bff; color: #f6f1ff; font-size: clamp(0.9rem, 4vw, 1.45rem); }
.g2048-tile.v-512 { background: #bf66ff; color: #fff1ff; font-size: clamp(0.9rem, 4vw, 1.35rem); }
.g2048-tile.v-1024 { background: #ff6ca2; color: #fff2f8; font-size: clamp(0.75rem, 3.5vw, 1.15rem); }
.g2048-tile.v-2048 { background: #ffd16f; color: #4f3600; font-size: clamp(0.75rem, 3.5vw, 1.15rem); box-shadow: 0 0 18px rgba(255, 209, 111, 0.5); }
.g2048-tile.v-super { background: linear-gradient(135deg, #ffd16f, #ff7cd4); color: #33103f; font-size: clamp(0.7rem, 3.3vw, 1.05rem); }
.g2048-overlay {
  position: absolute;
  inset: 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  z-index: 4;
}
.g2048-controls {
  grid-template-columns: repeat(4, 1fr);
  max-width: 340px;
}
.blockstack-controls {
  grid-template-columns: repeat(5, 1fr);
  max-width: 380px;
}
.racer-controls {
  grid-template-columns: repeat(3, 1fr);
  max-width: 280px;
}
.football-controls button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 0.65rem 0;
  touch-action: manipulation;
  transition: background 0.1s ease, transform 0.05s ease;
}
.football-controls button:active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transform: scale(0.96);
  color: #fff;
}
@media (pointer: coarse) {
  .football-controls { display: grid; }
  #racer-controls { display: none; }
}

/* === D-pad === */
.dpad {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  width: min(220px, 80%);
  aspect-ratio: 1 / 1;
  margin: 1rem auto 0;
  user-select: none;
  -webkit-user-select: none;
}
.dpad button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.2rem;
  touch-action: manipulation;
  transition: background 0.1s ease, transform 0.05s ease;
}
.dpad button:active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transform: scale(0.95);
  color: #fff;
}
.dpad button[data-dir="up"]    { grid-column: 2; grid-row: 1; }
.dpad button[data-dir="left"]  { grid-column: 1; grid-row: 2; }
.dpad button[data-dir="right"] { grid-column: 3; grid-row: 2; }
.dpad button[data-dir="down"]  { grid-column: 2; grid-row: 3; }
@media (pointer: coarse) {
  .dpad { display: grid; }
}

.snake-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.snake-info, .leaderboard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.score-block {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px dashed var(--border);
}
.score-label { color: var(--text-dim); font-size: 0.85rem; }
.score-value {
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hint { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 0.85rem; }

.primary-btn {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: white;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(124, 92, 255, 0.35);
}

.leaderboard h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
}
.leaderboard ol { list-style: none; padding: 0; }
.leaderboard li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
}
.leaderboard li + li { border-top: 1px solid var(--border); }
.leaderboard .rank { font-size: 0.95rem; text-align: center; }
.leaderboard .who { color: var(--text); font-size: 0.9rem; word-break: break-word; }
.leaderboard .who.me {
  color: var(--accent-2);
  font-weight: 600;
}
.leaderboard .pts {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* === Auth page === */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem; }
.auth-main { width: 100%; display: flex; justify-content: center; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel-strong);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 2rem 1.75rem;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: auth-in 0.35s ease;
}

@keyframes auth-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  font-size: 2.4rem;
  margin-bottom: 0.4rem;
  filter: drop-shadow(0 0 16px rgba(124, 92, 255, 0.7));
}
.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, #b9b1ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0.3rem 0 1.4rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 1.25rem;
}
.auth-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}
.auth-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35);
}

.auth-form { display: flex; flex-direction: column; gap: 0.85rem; text-align: left; }
.auth-form label { display: flex; flex-direction: column; gap: 0.3rem; }
.auth-form label span {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auth-form input {
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.auth-form input::placeholder { color: var(--text-dim); }
.auth-form input:focus {
  border-color: rgba(124, 92, 255, 0.6);
  background: rgba(255, 255, 255, 0.06);
}

.auth-error {
  background: rgba(255, 85, 119, 0.12);
  border: 1px solid rgba(255, 85, 119, 0.45);
  color: #ffb6c5;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.auth-submit {
  margin-top: 0.4rem;
  padding: 0.8rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: white;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(124, 92, 255, 0.35);
}
.auth-submit:disabled { opacity: 0.7; cursor: wait; transform: none; }
.auth-submit.loading .auth-submit-text::after {
  content: '…';
  animation: dots 1s infinite steps(4);
}
@keyframes dots {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
}

.auth-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.auth-hint a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}
.auth-hint a:hover { text-decoration: underline; }

/* === Responsive === */
@media (max-width: 880px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand user" "tabs tabs";
    gap: 0.5rem;
    padding: 0.7rem 1rem;
  }
  .brand { grid-area: brand; }
  .user-bar { grid-area: user; justify-self: end; }
  .tabs {
    grid-area: tabs;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -1rem;
    padding: 0 1rem;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; padding: 0.45rem 0.85rem; font-size: 0.85rem; }
  .user-name { display: none; }
  .logout-btn { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
  .content { padding: 1rem; }
  .kanban { grid-template-columns: 1fr; gap: 0.75rem; }
  .column { min-height: auto; }
  .snake-grid { grid-template-columns: 1fr; gap: 1rem; }
  .snake-card { padding: 0.75rem; }
  .snake-info, .leaderboard { padding: 1rem; }
  .brand-name { font-size: 0.95rem; }
}
