/* Linkedbits Games portal — arcade cabinet, kawaii slime theme. No frameworks. */

:root {
  --bg: #0e1712;
  --bg-alt: #131f19;
  --card: #17251e;
  --card-border: #24382e;
  --text: #e8f2ec;
  --text-dim: #9db3a8;
  --accent: #7ee067;
  --accent-dim: #4e8a44;
  --danger: #e0677e;
  --gold: #f4d03f;
  --silver: #bdc3c7;
  --bronze: #cd7f32;
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  background: radial-gradient(circle at top, var(--bg-alt), var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

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

h1, h2, h3 {
  margin: 0 0 0.5rem;
}

button {
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  min-height: 44px;
  min-width: 44px;
  background: var(--accent);
  color: #0e1712;
  font-weight: 700;
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  filter: brightness(1.1);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.avatar-option:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text);
}

button.secondary:hover {
  border-color: var(--accent-dim);
}

input[type="email"],
input[type="text"] {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--bg-alt);
  color: var(--text);
  width: 100%;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent-dim);
}

/* ---- Layout containers ---- */

.page-content,
.site-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.page-content > section,
.site-footer {
  opacity: 0;
  transform: translateY(18px);
  animation: fadeInUp 0.7s ease forwards;
}

.page-content > section:nth-child(1) { animation-delay: 0.05s; }
.page-content > section:nth-child(2) { animation-delay: 0.12s; }
.page-content > section:nth-child(3) { animation-delay: 0.20s; }
.page-content > section:nth-child(4) { animation-delay: 0.28s; }
.page-content > section:nth-child(5) { animation-delay: 0.36s; }
.site-footer { animation-delay: 0.44s; }

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Hero ---- */

.hero {
  position: relative;
  text-align: center;
  padding: 4rem 1rem 3.5rem;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.hero-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(14, 23, 18, 0.35) 0%, rgba(14, 23, 18, 0.85) 75%, var(--bg) 100%),
    url("assets/img/hero_bg.jpg") center/cover no-repeat;
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
  animation: heroFloat 6s ease-in-out infinite;
}

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

.tagline {
  color: rgba(232, 242, 236, 0.88);
  font-size: 1.15rem;
  margin: 0.5rem 0 0;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

/* ---- Sign-in strip ---- */

.signin-strip {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.signin-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.signin-form input {
  flex: 1 1 240px;
  height: 48px;
  min-height: 44px;
}

.auth-landing {
  max-width: 480px;
  margin: 12vh auto;
  padding: 2rem;
  text-align: center;
}

.auth-status {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-top: 1rem;
}

.signin-error {
  flex-basis: 100%;
  font-size: 0.9rem;
  color: var(--danger);
  min-height: 1.2em;
}

.signin-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

#signedInAs {
  color: var(--text-dim);
}

#signedInAs strong {
  color: var(--text);
}

/* ---- Profile card ---- */

.profile-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.profile-card h2 {
  margin-bottom: 1rem;
}

.profile-card label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.avatar-label {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 1.25rem 0 0.5rem;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 0.65rem;
  max-width: 520px;
}

.avatar-picker .avatar-option {
  background: none;
  padding: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  min-height: 0;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.avatar-picker .avatar-option:hover {
  transform: scale(1.12);
}

.avatar-picker .avatar-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(126, 224, 103, 0.25);
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-summary .avatar {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
}

.profile-summary strong {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 700;
}

.toast {
  font-size: 0.95rem;
  color: var(--text-dim);
  min-height: 1.2em;
}

.toast.success {
  color: var(--accent);
}

.toast.error {
  color: var(--danger);
}

/* ---- Avatars (shared: picker, leaderboard, online list) ---- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
  user-select: none;
}

.avatar-picker .avatar {
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
}

.avatar.slime_01 { background: hsl(100 55% 45%); }
.avatar.slime_02 { background: hsl(130 55% 45%); }
.avatar.slime_03 { background: hsl(160 55% 42%); }
.avatar.slime_04 { background: hsl(190 55% 42%); }
.avatar.slime_05 { background: hsl(210 60% 50%); }
.avatar.slime_06 { background: hsl(250 55% 55%); }
.avatar.slime_07 { background: hsl(280 50% 52%); }
.avatar.slime_08 { background: hsl(320 55% 52%); }
.avatar.slime_09 { background: hsl(350 60% 52%); }
.avatar.slime_10 { background: hsl(20 65% 50%); }
.avatar.slime_11 { background: hsl(45 70% 48%); }
.avatar.slime_12 { background: hsl(70 55% 45%); }
.avatar.slime_13 { background: hsl(40 55% 48%); }
.avatar.slime_14 { background: hsl(10 55% 48%); }
.avatar.slime_15 { background: hsl(85 55% 45%); }
.avatar.slime_16 { background: hsl(145 55% 45%); }
.avatar.slime_17 { background: hsl(200 55% 50%); }
.avatar.slime_18 { background: hsl(230 55% 50%); }
.avatar.slime_19 { background: hsl(265 55% 50%); }
.avatar.slime_20 { background: hsl(300 55% 50%); }
.avatar.slime_21 { background: hsl(335 55% 52%); }
.avatar.slime_22 { background: hsl(25 45% 40%); }
.avatar.slime_23 { background: hsl(210 25% 45%); }
.avatar.slime_24 { background: hsl(220 15% 30%); }

.avatar.avatar-sprite {
  background: transparent;
}

.avatar-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ---- Game grid ---- */

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.game-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 10px 24px rgba(0, 0, 0, 0.35),
    0 3px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.game-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 20px 40px rgba(0, 0, 0, 0.45),
    0 0 28px rgba(126, 224, 103, 0.16);
}

.game-card:hover .mascot {
  animation: mascotWobble 0.5s ease-in-out;
}

@keyframes mascotWobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-4deg); }
  75% { transform: rotate(4deg); }
}

.cabinet-panel {
  position: relative;
  height: 180px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1rem;
  border-bottom: 1px solid var(--card-border);
}

.cabinet-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(14, 23, 18, 0.55) 100%);
  pointer-events: none;
}

.emoji-chip {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  background: rgba(14, 23, 18, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  backdrop-filter: blur(4px);
}

.mascot {
  position: relative;
  z-index: 1;
  max-height: 170px;
  max-width: 90%;
  object-fit: contain;
  margin-bottom: -28px;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.4));
  transform-origin: bottom center;
  animation: mascotBob 3.5s ease-in-out infinite;
}

.game-card:nth-child(1) .mascot { animation-delay: 0s; }
.game-card:nth-child(2) .mascot { animation-delay: 0.7s; }

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

.cabinet-body {
  padding: 2.25rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.game-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
}

.game-card .desc {
  color: var(--text-dim);
  flex: 1;
  margin: 0;
  font-size: 0.95rem;
}

.game-card .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  align-self: flex-start;
  margin-top: 0.25rem;
}

.game-card .badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.65; }
}

.game-card .play-link {
  display: block;
  text-align: center;
  background: var(--accent);
  color: #0e1712;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.85rem 1rem;
  min-height: 48px;
  text-decoration: none;
  margin-top: 0.75rem;
  letter-spacing: 0.02em;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.game-card .play-link:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 20px rgba(126, 224, 103, 0.3);
}

.game-card .play-link:active {
  transform: translateY(2px) scale(0.99);
}

/* ---- Leaderboard section ---- */

.leaderboard-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tabs .tab-btn {
  background: var(--bg-alt);
  color: var(--text-dim);
  border: 1px solid var(--card-border);
  font-weight: 600;
  padding: 0.6rem 1.1rem;
}

.tabs .tab-btn.active {
  background: var(--accent);
  color: #0e1712;
  border-color: var(--accent);
}

.leaderboard-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Podium */

.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 0.75rem;
  align-items: end;
  justify-items: center;
  min-height: 150px;
  padding: 0.5rem 0 0;
}

#leaderboardPodium:empty {
  display: none;
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  padding: 1rem 0.5rem 0.75rem;
  border-radius: 18px 18px 8px 8px;
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  position: relative;
}

.podium-place.first {
  order: 2;
  padding-top: 1.35rem;
  padding-bottom: 1rem;
  background: linear-gradient(180deg, rgba(244, 208, 63, 0.12) 0%, var(--bg-alt) 60%);
  border-color: rgba(244, 208, 63, 0.35);
  box-shadow: 0 8px 24px rgba(244, 208, 63, 0.1);
}

.podium-place.second {
  order: 1;
  background: linear-gradient(180deg, rgba(189, 195, 199, 0.1) 0%, var(--bg-alt) 60%);
  border-color: rgba(189, 195, 199, 0.25);
}

.podium-place.third {
  order: 3;
  background: linear-gradient(180deg, rgba(205, 127, 50, 0.1) 0%, var(--bg-alt) 60%);
  border-color: rgba(205, 127, 50, 0.25);
}

.podium-crown {
  font-size: 1.2rem;
  line-height: 1;
  margin-bottom: 0.15rem;
  color: var(--gold);
}

.podium-place .avatar {
  width: 56px;
  height: 56px;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  border: 2px solid transparent;
}

.podium-place.first .avatar {
  width: 72px;
  height: 72px;
  font-size: 2rem;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(244, 208, 63, 0.18);
}

.podium-place.second .avatar {
  border-color: var(--silver);
}

.podium-place.third .avatar {
  border-color: var(--bronze);
}

.podium-name {
  font-weight: 700;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.25rem;
}

.podium-score {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.podium-rank {
  position: absolute;
  bottom: -0.5rem;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--card-border);
}

.leaderboard-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--card-border);
  vertical-align: middle;
}

.leaderboard-table td.rank {
  color: var(--text-dim);
  width: 2rem;
}

.leaderboard-table td.score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
}

.leaderboard-table td.when {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 1.5rem 0;
}

/* ---- Online now ---- */

.online-panel {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--card-border);
}

.online-panel h3 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.online-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.online-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.online-list li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem 0.35rem 0.45rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  min-height: 40px;
}

.online-list .avatar {
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
}

.online-list strong {
  color: var(--text);
  font-weight: 600;
}

.online-list .online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulseDot 2s ease-in-out infinite;
  flex-shrink: 0;
}

.online-list .online-game {
  color: var(--text-dim);
}

/* ---- Message board ---- */

.board-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 28px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.board-list {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.board-list li {
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.board-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.board-meta strong {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}

.board-time {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.board-body {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

#boardCompose {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#boardInput {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  min-height: 88px;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--bg-alt);
  color: var(--text);
  width: 100%;
  resize: vertical;
}

#boardInput:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent-dim);
}

.board-compose-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

#boardCount {
  color: var(--text-dim);
  font-size: 0.9rem;
}

#boardSend {
  min-width: 96px;
}

#boardSignin {
  margin: 0;
}

.site-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 2.5rem;
}

/* ---- Responsive ---- */

@media (max-width: 640px) {
  .hero {
    padding: 2.5rem 1rem 2rem;
  }

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

  .cabinet-panel {
    height: 150px;
  }

  .mascot {
    max-height: 120px;
    margin-bottom: -22px;
  }

  .avatar-picker {
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    max-width: none;
  }

  .signin-form {
    flex-direction: column;
  }

  .signin-form input {
    flex: 0 0 auto;
    width: 100%;
  }

  .signin-form button {
    width: 100%;
  }

  .podium {
    gap: 0.5rem;
    min-height: 120px;
  }

  .podium-place {
    padding: 0.75rem 0.35rem 0.6rem;
  }

  .podium-place.first {
    padding-top: 1rem;
    padding-bottom: 0.8rem;
  }

  .podium-place .avatar {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
  }

  .podium-place.first .avatar {
    width: 54px;
    height: 54px;
    font-size: 1.55rem;
  }

  .podium-name {
    font-size: 0.85rem;
  }

  .podium-score {
    font-size: 0.95rem;
  }
}

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .page-content > section,
  .site-footer {
    opacity: 1;
    transform: none;
  }
}
