:root {
  --bg: #0a0f14;
  --panel: #111923;
  --panel-strong: #172332;
  --text: #eaf7f2;
  --muted: #9fb3bd;
  --mint: #00f5a0;
  --cyan: #00d9ff;
  --pink: #f72585;
  --line: rgba(234, 247, 242, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(0, 217, 255, 0.15), transparent 34%),
    radial-gradient(circle at bottom right, rgba(247, 37, 133, 0.12), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.intro-active {
  overflow: hidden;
}

.lobby-intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(0, 245, 160, 0.24), transparent 28%),
    linear-gradient(135deg, #05080b, #101926 58%, #071015);
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.lobby-intro::before,
.lobby-intro::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(0, 217, 255, 0.22);
  border-radius: 8px;
  animation: introPulse 1.4s ease-in-out infinite alternate;
}

.lobby-intro::after {
  inset: 20%;
  border-color: rgba(247, 37, 133, 0.24);
  animation-delay: 0.3s;
}

.lobby-intro.intro-exit {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-logo-wrap {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 28px;
  animation: introLift 2s ease forwards;
}

.intro-logo {
  width: clamp(180px, 34vw, 360px);
  max-height: 38vh;
  object-fit: contain;
  filter: drop-shadow(0 0 28px rgba(0, 217, 255, 0.35));
  animation: logoCharge 2s ease forwards;
}

.intro-card-row {
  display: flex;
  gap: 10px;
}

.intro-card-row span {
  width: 42px;
  height: 58px;
  border: 1px solid rgba(234, 247, 242, 0.32);
  border-radius: 6px;
  background: linear-gradient(145deg, rgba(234, 247, 242, 0.95), rgba(0, 217, 255, 0.55));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  transform-origin: bottom center;
  animation: cardFan 1.1s ease-in-out infinite alternate;
}

.intro-card-row span:nth-child(1) {
  transform: rotate(-18deg);
}

.intro-card-row span:nth-child(2) {
  animation-delay: 0.08s;
  transform: rotate(-9deg);
}

.intro-card-row span:nth-child(3) {
  animation-delay: 0.16s;
}

.intro-card-row span:nth-child(4) {
  animation-delay: 0.24s;
  transform: rotate(9deg);
}

.intro-card-row span:nth-child(5) {
  animation-delay: 0.32s;
  transform: rotate(18deg);
}

.lobby-shell {
  width: min(94vw, 1180px);
  margin: 0 auto;
  padding:
    max(34px, env(safe-area-inset-top))
    max(0px, env(safe-area-inset-right))
    max(44px, env(safe-area-inset-bottom))
    max(0px, env(safe-area-inset-left));
  display: grid;
  gap: 24px;
}

.lobby-header,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.3rem, 6vw, 5.2rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.7rem, 3vw, 2.7rem);
}

h3 {
  margin: 0;
  font-size: 1.25rem;
}

.account-action,
.account-link {
  font-weight: 800;
  text-decoration: none;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.account-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition:
    transform 0.18s ease,
    filter 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.tutorial-action {
  border-color: rgba(0, 217, 255, 0.42);
  background: linear-gradient(135deg, rgba(0, 245, 160, 0.18), rgba(0, 217, 255, 0.15));
  color: var(--cyan);
}

.signout-action {
  border-color: rgba(247, 37, 133, 0.35);
  color: #ff8fbd;
}

.signin-action {
  border-color: rgba(0, 217, 255, 0.42);
  color: var(--cyan);
}

.signup-action {
  border-color: transparent;
  background: linear-gradient(135deg, var(--mint), var(--cyan));
  color: #061014;
}

.account-action[hidden] {
  display: none;
}

.online-presence-badge {
  gap: 0;
  border-color: var(--mint);
  background: rgba(0, 245, 160, 0.18);
  color: var(--mint) !important;
  cursor: default;
  pointer-events: none;
}

.online-presence-badge strong {
  color: inherit;
  font-size: 1.04rem;
  line-height: 1;
}

.account-action:hover,
.account-action:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.12);
  text-decoration: none;
}

.online-presence-badge:hover {
  transform: none;
  filter: none;
}

.account-action:focus-visible {
  outline: 3px solid rgba(0, 217, 255, 0.28);
  outline-offset: 3px;
}

.play-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.play-button {
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  align-content: end;
  gap: 8px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
}

.play-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.play-button span {
  font-size: 1.35rem;
  font-weight: 900;
}

.play-button small {
  color: rgba(234, 247, 242, 0.78);
  font-size: 0.92rem;
  line-height: 1.35;
}

.play-button.computer {
  background: linear-gradient(135deg, rgba(0, 245, 160, 0.9), rgba(0, 217, 255, 0.68));
  color: #061014;
}

.play-button.computer small {
  color: rgba(6, 16, 20, 0.76);
}

.play-button.private {
  background: linear-gradient(135deg, rgba(23, 35, 50, 0.96), rgba(247, 37, 133, 0.2));
}

.play-button.public {
  background: linear-gradient(135deg, rgba(23, 35, 50, 0.96), rgba(0, 217, 255, 0.22));
}

.computer-difficulty-panel {
  padding: 22px;
  border: 1px solid rgba(0, 217, 255, 0.24);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(0, 245, 160, 0.1), rgba(0, 217, 255, 0.08)),
    color-mix(in srgb, var(--panel) 94%, black);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.computer-difficulty-panel[hidden] {
  display: none;
}

.computer-difficulty-panel h2 {
  font-size: clamp(1.45rem, 2.2vw, 2rem);
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.difficulty-button {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  align-content: end;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.difficulty-button span {
  font-size: 1.18rem;
  font-weight: 950;
}

.difficulty-button small {
  color: var(--muted);
  line-height: 1.35;
}

.difficulty-button.recommended {
  border-color: rgba(0, 245, 160, 0.42);
  background: linear-gradient(135deg, rgba(0, 245, 160, 0.18), rgba(0, 217, 255, 0.12));
}

.difficulty-button:hover,
.difficulty-button:focus-visible {
  transform: translateY(-2px);
  border-color: var(--cyan);
  box-shadow: 0 14px 32px rgba(0, 217, 255, 0.16);
}

.difficulty-button:focus-visible {
  outline: 3px solid rgba(0, 217, 255, 0.28);
  outline-offset: 3px;
}

.private-room,
.stats-section,
.feedback-section {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, black);
}

.private-room {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.room-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  text-transform: uppercase;
  outline: none;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.18);
}

textarea {
  width: 100%;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  resize: vertical;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  outline: none;
}

textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.18);
}

.room-code-row button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  background: var(--cyan);
  color: #061014;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.lobby-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.stats-section {
  position: relative;
  display: grid;
  gap: 18px;
}

.stats-section.locked .dashboard-view,
.stats-section.locked .section-heading {
  filter: blur(3px) saturate(0.55);
  opacity: 0.42;
  pointer-events: none;
  user-select: none;
}

.dashboard-auth-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  min-height: 100%;
  padding: 22px;
  display: grid;
  place-items: center;
  background: rgba(10, 15, 20, 0.46);
  backdrop-filter: blur(2px);
}

.dashboard-auth-overlay[hidden] {
  display: none;
}

.dashboard-auth-panel {
  width: min(100%, 520px);
  padding: 22px;
  border: 1px solid rgba(0, 217, 255, 0.32);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  background: color-mix(in srgb, var(--panel-strong) 94%, black);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.36);
}

.dashboard-auth-panel p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dashboard-switcher {
  margin-bottom: -10px;
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dashboard-switcher-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.dashboard-tabs {
  min-width: min(100%, 340px);
  display: flex;
  gap: 10px;
}

.dashboard-tab {
  flex: 1;
  min-height: 44px;
  border: 1px solid rgba(0, 217, 255, 0.42);
  border-radius: 999px;
  padding: 10px 18px;
  background: linear-gradient(135deg, rgba(0, 245, 160, 0.18), rgba(0, 217, 255, 0.15));
  color: var(--cyan);
  font: inherit;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition:
    transform 0.18s ease,
    filter 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.dashboard-tab:hover {
  transform: translateY(-2px);
  filter: brightness(1.12);
}

.dashboard-tab.active {
  background: linear-gradient(135deg, var(--mint), var(--cyan));
  border-color: transparent;
  color: #061014;
}

.dashboard-tab:focus-visible {
  outline: 3px solid rgba(0, 217, 255, 0.3);
  outline-offset: 3px;
}

.dashboard-view[hidden] {
  display: none;
}

.mode-stats {
  display: grid;
  gap: 18px;
}

.mode-panel {
  display: grid;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  align-content: space-between;
  background: var(--panel-strong);
}

.stat-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.stat-card strong {
  font-size: 2.1rem;
  line-height: 1;
}

.leaderboard-view {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.leaderboard-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.leaderboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-heading span {
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ranked-list {
  min-height: 84px;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
}

.ranked-player {
  min-width: 0;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid rgba(234, 247, 242, 0.1);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: rgba(10, 15, 20, 0.48);
}

.ranked-player.current-player {
  border-color: rgba(0, 245, 160, 0.56);
  background: linear-gradient(90deg, rgba(0, 245, 160, 0.13), rgba(0, 217, 255, 0.08));
}

.rank-position {
  color: var(--cyan);
  font-weight: 950;
}

.rank-name {
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranked-player strong {
  color: var(--mint);
  font-size: 0.92rem;
  white-space: nowrap;
}

.leaderboard-message {
  min-height: 84px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.feedback-section {
  display: grid;
  gap: 18px;
}

.feedback-form {
  display: grid;
  gap: 12px;
}

.feedback-submit-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  justify-self: start;
  background: linear-gradient(135deg, var(--mint), var(--cyan));
  color: #061014;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.feedback-submit-button:hover:not(:disabled),
.feedback-submit-button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.feedback-submit-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.feedback-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.feedback-status.success {
  color: var(--mint);
}

.feedback-status.error {
  color: #ffb1d1;
}

.lobby-footer {
  min-height: 58px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.feedback-footer-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 217, 255, 0.42);
  border-radius: 999px;
  padding: 9px 16px;
  background: linear-gradient(135deg, rgba(0, 245, 160, 0.14), rgba(0, 217, 255, 0.12));
  color: var(--cyan);
  font-weight: 900;
  text-decoration: none;
}

.feedback-footer-link:hover,
.feedback-footer-link:focus-visible {
  filter: brightness(1.12);
  text-decoration: none;
}

.feedback-footer-link:focus-visible {
  outline: 3px solid rgba(0, 217, 255, 0.3);
  outline-offset: 3px;
}

.feedback-page {
  min-height: 100vh;
  min-height: 100dvh;
  align-content: start;
}

.feedback-page .feedback-section {
  max-width: 760px;
  width: 100%;
}

@media (max-width: 980px) {
  .play-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .leaderboard-view {
    grid-template-columns: 1fr;
  }

  .difficulty-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .lobby-shell {
    width: min(100% - 24px, 560px);
    gap: 18px;
    padding-top: max(22px, env(safe-area-inset-top));
  }

  .lobby-header,
  .section-heading {
    display: grid;
    align-items: start;
  }

  .dashboard-switcher {
    margin-bottom: -6px;
    display: grid;
  }

  .dashboard-tabs {
    min-width: 0;
    width: 100%;
  }

  .dashboard-tab {
    flex: 1;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .account-action {
    flex: 1 1 auto;
  }

  .play-panel {
    grid-template-columns: 1fr;
  }

  .room-code-row {
    grid-template-columns: 1fr;
  }

  .play-button {
    min-height: 112px;
  }

  .private-room,
  .stats-section,
  .feedback-section {
    padding: 16px;
  }

  .lobby-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .feedback-footer-link {
    width: 100%;
  }

  .feedback-submit-button {
    width: 100%;
  }
}

@keyframes introPulse {
  from {
    transform: scale(0.97);
    opacity: 0.38;
  }

  to {
    transform: scale(1.03);
    opacity: 0.86;
  }
}

@keyframes introLift {
  0% {
    transform: translateY(18px) scale(0.94);
  }

  55% {
    transform: translateY(0) scale(1);
  }

  100% {
    transform: translateY(-14px) scale(1.04);
  }
}

@keyframes logoCharge {
  0% {
    opacity: 0;
    transform: scale(0.7) rotate(-4deg);
  }

  18% {
    opacity: 1;
  }

  72% {
    transform: scale(1) rotate(0deg);
  }

  100% {
    transform: scale(1.08) rotate(0deg);
    filter: drop-shadow(0 0 42px rgba(0, 245, 160, 0.48));
  }
}

@keyframes cardFan {
  from {
    translate: 0 6px;
  }

  to {
    translate: 0 -8px;
  }
}

@media (max-width: 420px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 92px;
  }

  .ranked-player {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .ranked-player strong {
    grid-column: 2;
  }
}
