/* ============================================
   GUILDLE — Design System
   ============================================ */

/* --- CSS Custom Properties (Dark Theme) --- */
:root {
  /* Background */
  --bg-primary: #121213;
  --bg-secondary: #1a1a1b;
  --bg-elevated: #2a2a2b;
  --bg-surface: rgba(255, 255, 255, 0.06);

  /* Text */
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a5;
  --text-muted: #6a6a6e;

  /* Match Colors */
  --color-full-match: #538d4e;
  --color-partial-match: #b59f3b;
  --color-no-match: #3a3a3c;
  --color-unknown: #818384;

  /* Accent */
  --color-accent: #6c63ff;
  --color-accent-hover: #7f78ff;
  --color-accent-glow: rgba(108, 99, 255, 0.25);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-tile: rgba(255, 255, 255, 0.2);

  /* Success / Error */
  --color-success: #538d4e;
  --color-error: #d94444;
  --color-warning: #b59f3b;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--color-accent-glow);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  background: radial-gradient(circle at 15% 50%, rgba(108, 99, 255, 0.08), transparent 40%), radial-gradient(circle at 85% 30%, rgba(83, 141, 78, 0.06), transparent 40%), var(--bg-primary);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* --- App Shell --- */
#main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Header --- */
.app-header {
  text-align: center;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-lg);
}

.app-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff, var(--color-accent), #a39eff, #ffffff);
  background-size: 300% 300%;
  animation: gradientPan 8s ease infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 20px rgba(108, 99, 255, 0.2);
}

/* --- Guild Tabs --- */
.guild-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-lg);
}

.guild-tab {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
}

.guild-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  text-decoration: none;
}

.guild-tab.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  font-weight: 600;
  box-shadow: var(--shadow-glow);
}

.guild-tab .invite-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.guild-tab .invite-badge:hover {
  background: rgba(255, 255, 255, 0.3);
}

.guild-tab.create-tab {
  border-style: dashed;
  color: var(--text-muted);
}

.guild-tab.create-tab:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.create-guild-input {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-accent);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  min-width: 160px;
  transition: box-shadow var(--transition-fast);
}

.create-guild-input:focus {
  box-shadow: var(--shadow-glow);
}

/* --- Guess Grid --- */
.guess-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-md) 0;
  flex-shrink: 0;
}

.guess-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

/* --- Letter Tiles --- */
.letter-block {
  width: 56px;
  height: 56px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.6rem;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-tile);
  background: transparent;
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
  user-select: none;
}

.letter-block.has-letter {
  border-color: var(--text-muted);
  animation: pop 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
}

/* Match state tiles */
.letter-block.full_match {
  background-color: var(--color-full-match);
  border-color: var(--color-full-match);
  color: #fff;
  box-shadow: 0 0 16px rgba(83, 141, 78, 0.4);
}

.letter-block.partial_match {
  background-color: var(--color-partial-match);
  border-color: var(--color-partial-match);
  color: #fff;
  box-shadow: 0 0 16px rgba(181, 159, 59, 0.4);
}

.letter-block.no_match {
  background-color: var(--color-no-match);
  border-color: var(--color-no-match);
  color: var(--text-secondary);
}

.letter-block.unknown_match {
  background: transparent;
  border-color: var(--border-tile);
}

/* Tile flip animation for revealed guesses */
.letter-block.revealed.full_match {
  animation: flip-full 0.6s ease both;
}

.letter-block.revealed.partial_match {
  animation: flip-partial 0.6s ease both;
}

.letter-block.revealed.no_match {
  animation: flip-no 0.6s ease both;
}

.letter-block.revealed:nth-child(1) {
  animation-delay: 0ms;
}

.letter-block.revealed:nth-child(2) {
  animation-delay: 150ms;
}

.letter-block.revealed:nth-child(3) {
  animation-delay: 300ms;
}

.letter-block.revealed:nth-child(4) {
  animation-delay: 450ms;
}

.letter-block.revealed:nth-child(5) {
  animation-delay: 600ms;
}

@keyframes flip-full {
  0% {
    transform: rotateX(0deg);
    background-color: transparent;
    border-color: var(--border-tile);
    box-shadow: none;
    color: var(--text-primary);
  }

  49.9% {
    transform: rotateX(90deg);
    background-color: transparent;
    border-color: var(--border-tile);
    box-shadow: none;
    color: var(--text-primary);
  }

  50% {
    transform: rotateX(90deg);
    background-color: var(--color-full-match);
    border-color: var(--color-full-match);
    box-shadow: 0 0 16px rgba(83, 141, 78, 0.4);
    color: #fff;
  }

  100% {
    transform: rotateX(0deg);
    background-color: var(--color-full-match);
    border-color: var(--color-full-match);
    box-shadow: 0 0 16px rgba(83, 141, 78, 0.4);
    color: #fff;
  }
}

@keyframes flip-partial {
  0% {
    transform: rotateX(0deg);
    background-color: transparent;
    border-color: var(--border-tile);
    box-shadow: none;
    color: var(--text-primary);
  }

  49.9% {
    transform: rotateX(90deg);
    background-color: transparent;
    border-color: var(--border-tile);
    box-shadow: none;
    color: var(--text-primary);
  }

  50% {
    transform: rotateX(90deg);
    background-color: var(--color-partial-match);
    border-color: var(--color-partial-match);
    box-shadow: 0 0 16px rgba(181, 159, 59, 0.4);
    color: #fff;
  }

  100% {
    transform: rotateX(0deg);
    background-color: var(--color-partial-match);
    border-color: var(--color-partial-match);
    box-shadow: 0 0 16px rgba(181, 159, 59, 0.4);
    color: #fff;
  }
}

@keyframes flip-no {
  0% {
    transform: rotateX(0deg);
    background-color: transparent;
    border-color: var(--border-tile);
    box-shadow: none;
    color: var(--text-primary);
  }

  49.9% {
    transform: rotateX(90deg);
    background-color: transparent;
    border-color: var(--border-tile);
    box-shadow: none;
    color: var(--text-primary);
  }

  50% {
    transform: rotateX(90deg);
    background-color: var(--color-no-match);
    border-color: var(--color-no-match);
    box-shadow: none;
    color: var(--text-secondary);
  }

  100% {
    transform: rotateX(0deg);
    background-color: var(--color-no-match);
    border-color: var(--color-no-match);
    box-shadow: none;
    color: var(--text-secondary);
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }

  100% {
    transform: scale(1);
  }
}

/* Error shake & flash */
.flash-error {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  color: var(--color-error);
  border-color: var(--color-error);
  background: rgba(217, 68, 68, 0.15);
}

@keyframes shake {

  10%,
  90% {
    transform: translate3d(-2px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(4px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-6px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(6px, 0, 0);
  }
}

/* --- Error Toast --- */
.error-toast {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 100;
  animation: toastFadeIn 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, toastFadeOut 0.2s ease-in 0.4s forwards;
  pointer-events: none;
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -20px) scale(0.9);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@keyframes toastFadeOut {
  from {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.95);
  }
}

/* Server-error toast stays longer */
.error-toast.server-error {
  animation: toastFadeIn 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, toastFadeOut 0.2s ease-in 2.6s forwards;
  background: var(--color-error, #d94444);
  color: #fff;
}

/* Error banner for failed loads (game, guilds, stats) */
.load-error-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  margin: var(--space-md) 0;
  border-radius: var(--radius-lg);
  background: rgba(217, 68, 68, 0.08);
  border: 1px solid rgba(217, 68, 68, 0.25);
  text-align: center;
  animation: fadeSlideIn 0.3s ease;
}

.load-error-banner p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0;
}

.load-error-banner button {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.load-error-banner button:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

/* Inline error for create-guild input */
.create-guild-error {
  color: var(--color-error, #d94444);
  font-size: 0.78rem;
  margin-top: var(--space-xs);
  padding-left: var(--space-md);
}

/* Win celebration bounce */
@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-20px);
  }

  50% {
    transform: translateY(-10px);
  }

  70% {
    transform: translateY(-5px);
  }
}

.letter-block.win-bounce {
  animation: bounce 0.6s ease;
}

.letter-block.win-bounce:nth-child(1) {
  animation-delay: 0ms;
}

.letter-block.win-bounce:nth-child(2) {
  animation-delay: 100ms;
}

.letter-block.win-bounce:nth-child(3) {
  animation-delay: 200ms;
}

.letter-block.win-bounce:nth-child(4) {
  animation-delay: 300ms;
}

.letter-block.win-bounce:nth-child(5) {
  animation-delay: 400ms;
}

/* --- Keyboard --- */
.keyboard {
  padding: var(--space-sm) 0;
  margin-top: auto;
}

.row {
  display: flex;
  width: 100%;
  gap: 5px;
  margin-bottom: 6px;
  justify-content: center;
}

.key {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 52px;
  min-width: 0;
  border-radius: var(--radius-sm);
  border: none;
  flex: 1;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.key:hover {
  filter: brightness(1.1);
}

.key:active {
  transform: scale(0.93) translateY(2px);
  box-shadow: 0 0px 2px rgba(0, 0, 0, 0.2);
}

/* Keyboard match states */
.key.unknown_match {
  background-color: var(--color-unknown);
  color: var(--text-primary);
}

.key.full_match {
  background-color: var(--color-full-match);
  color: #fff;
}

.key.partial_match {
  background-color: var(--color-partial-match);
  color: #fff;
}

.key.no_match {
  background-color: var(--color-no-match);
  color: var(--text-muted);
}

.bigkey {
  flex: 1.5;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.cushion {
  flex: 0.5;
}

/* --- Game Result Banner --- */
.game-result {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  margin: var(--space-md) 0;
  border-radius: var(--radius-lg);
  background: rgba(42, 42, 43, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  animation: fadeSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-result .result-message {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.game-result.success .result-message {
  color: var(--color-full-match);
}

.game-result.failure .result-message {
  color: var(--color-error);
}

.game-result .answer-reveal {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.game-result .answer-word {
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  letter-spacing: 0.1em;
}

/* Share Button */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.share-btn:hover {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
  color: #fff;
  text-decoration: none;
}

/* Button variants for viewing stats */
.stats-user-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: all 0.2s ease-out;
}

.stats-user-btn:hover {
  color: var(--color-accent);
  text-decoration-color: var(--color-accent);
}

.view-guild-stats-btn {
  background: rgba(108, 99, 255, 0.1);
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}

.view-guild-stats-btn:hover {
  background: rgba(108, 99, 255, 0.2);
  transform: translateY(-1px);
}

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

.share-btn.copied {
  background: var(--color-success);
}

/* --- Stats Section --- */
.stats-section {
  padding: var(--space-lg) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.stats-card-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-md);
}

.stats-card {
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), border-color var(--transition-fast), box-shadow var(--transition-base);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.stats-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
}

.stats-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-card ol,
.stats-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stats-card li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9rem;
}

.stats-card li:last-child {
  border-bottom: none;
}

.stats-card .leader-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: var(--space-sm);
  flex-shrink: 0;
}

.stats-card li:nth-child(1) .leader-rank {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  color: #1a1a1b;
}

.stats-card li:nth-child(2) .leader-rank {
  background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
  color: #1a1a1b;
}

.stats-card li:nth-child(3) .leader-rank {
  background: linear-gradient(135deg, #cd7f32, #a0602a);
  color: #1a1a1b;
}

.stats-card .leader-name {
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-card .leader-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
  margin-left: var(--space-sm);
}

.stats-card .leader-detail a {
  color: var(--color-accent);
}

.stats-card .member-chip {
  display: inline-block;
  padding: 6px 14px;
  margin: 3px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.stats-card .member-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.stats-card .member-chip.playing {
  background: rgba(108, 99, 255, 0.15);
  border: 1px solid var(--color-accent);
  color: #fff;
  box-shadow: 0 0 10px rgba(108, 99, 255, 0.2);
}

/* --- Peek User Banner --- */
.peek-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) 0;
  border-radius: var(--radius-md);
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid rgba(108, 99, 255, 0.25);
  font-size: 0.9rem;
  color: var(--text-secondary);
  animation: fadeSlideIn 0.3s ease-out;
}

.peek-banner strong {
  color: var(--text-primary);
}

.peek-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1;
}

.peek-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  text-decoration: none;
}

/* --- Sign-in Page --- */
.signin-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: var(--space-xl);
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
}

.signin-hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 0%, var(--color-accent) 50%, #b2adff 100%);
  background-size: 200% 200%;
  animation: gradientPan 6s ease infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-sm);
  text-shadow: 0 0 30px rgba(108, 99, 255, 0.2);
}

.signin-hero .tagline {
  font-size: 1.15rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.signin-google-btn {
  display: flex;
  justify-content: center;
  transition: transform var(--transition-fast);
}

.signin-google-btn:hover {
  transform: scale(1.02);
}

.signin-invite-card {
  background: rgba(108, 99, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(108, 99, 255, 0.3);
  box-shadow: 0 8px 32px rgba(108, 99, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
  color: var(--text-primary);
  animation: fadeSlideIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.signin-invite-card strong {
  color: var(--color-accent);
}

.signin-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  max-width: 380px;
}

.signin-info .info-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  text-align: left;
}

.signin-info .info-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.signin-info .info-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.signin-info .info-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* --- Generic Content (fallback) --- */
.generic-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding: var(--space-xs);
  color: var(--text-secondary);
}

/* --- Utility Animations --- */
@keyframes gradientPan {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* --- Scrollbar (Webkit) --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Loading States & Transitions --- */
.spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: var(--space-xl);
  height: 40px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(108, 99, 255, 0.15);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-screen .signin-hero {
  animation: pulse-op 2.5s infinite ease-in-out;
}

@keyframes pulse-op {

  0%,
  100% {
    opacity: 0.7;
    transform: scale(0.98);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Game Loading Transition */
.game-content-transition {
  display: flex;
  flex-direction: column;
  flex: 1;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, filter 0.5s ease-out;
}

.game-content-transition.loading {
  opacity: 0.2;
  transform: scale(0.98);
  filter: blur(4px);
  pointer-events: none;
}

.game-content-transition.loaded {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
  pointer-events: auto;
}

/* Spinner positioning overlay */
.game-spinner-overlay {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.game-spinner-overlay.loading {
  opacity: 1;
}

.game-container {
  position: relative;
  min-height: 400px;
  /* Prevent layout shift when game disappears */
}

/* --- Personal Stats Modal --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-md);
}

.personal-stats-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: var(--space-xl);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  position: relative;
  text-align: center;
  animation: fadeSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.personal-stats-modal h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0px;
}

.stats-subtitle {
  color: var(--color-accent);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: var(--space-xl);
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s;
}

.close-btn:hover {
  color: var(--text-primary);
}

.stats-hero-grid {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.stat-num {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

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

.distribution-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-md);
  text-align: left;
}

.guess-distribution {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
}

.distribution-row {
  display: flex;
  align-items: center;
  width: 100%;
  font-size: 0.85rem;
  font-weight: 700;
}

.distribution-guess-num {
  width: 16px;
  text-align: right;
  margin-right: 8px;
}

.distribution-bar-container {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.distribution-bar {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.distribution-bar.has-guesses {
  background: var(--color-accent);
  color: white;
  justify-content: flex-end;
}

.distribution-bar.empty {
  background: transparent;
  width: 0 !important;
}

.distribution-count {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  z-index: 2;
}

.app-header .profile-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 6px 14px;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.app-header .profile-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

/* --- Empty Guilds (Onboarding) --- */
.empty-guilds {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  animation: fadeSlideIn 0.5s ease-out;
}

.empty-guilds-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-md);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

.empty-guilds-title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #ffffff, var(--color-accent), #b2adff);
  background-size: 200% 200%;
  animation: gradientPan 6s ease infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-sm);
}

.empty-guilds-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 380px;
  margin-bottom: var(--space-xl);
}

.empty-guilds-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: left;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.empty-guilds-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.empty-guilds-card.create-card {
  border-color: rgba(108, 99, 255, 0.2);
}

.empty-guilds-card.create-card:hover {
  border-color: rgba(108, 99, 255, 0.4);
  box-shadow: 0 4px 24px rgba(108, 99, 255, 0.1);
}

.empty-guilds-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.empty-guilds-card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-guilds-card-icon {
  font-size: 1.2rem;
}

.empty-guilds-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  line-height: 1.5;
}

.empty-guilds-input-row {
  display: flex;
  gap: var(--space-sm);
}

.empty-guilds-input {
  flex: 1;
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.empty-guilds-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.empty-guilds-input::placeholder {
  color: var(--text-muted);
}

.empty-guilds-create-btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--color-accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.empty-guilds-create-btn:hover:not(:disabled) {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.empty-guilds-create-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.empty-guilds-create-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.empty-guilds-error {
  color: var(--color-error);
  font-size: 0.8rem;
  margin-top: var(--space-sm);
}

.empty-guilds-divider {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 400px;
  margin: var(--space-lg) 0;
  gap: var(--space-md);
}

.empty-guilds-divider::before,
.empty-guilds-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.empty-guilds-divider span {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.empty-guilds-card.join-card {
  border-color: rgba(83, 141, 78, 0.2);
}

.empty-guilds-card.join-card:hover {
  border-color: rgba(83, 141, 78, 0.4);
  box-shadow: 0 4px 24px rgba(83, 141, 78, 0.08);
}

.empty-guilds-card.join-card .empty-guilds-card-desc {
  margin-bottom: 0;
}

/* --- Responsive --- */
@media (max-width: 520px) {
  #app {
    padding: var(--space-sm);
  }

  .letter-block {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
  }

  .key {
    height: 48px;
    font-size: 0.78rem;
  }

  .signin-hero h1 {
    font-size: 2.2rem;
  }

  .stats-card li {
    font-size: 0.85rem;
  }
}

@media (max-width: 380px) {
  .letter-block {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .key {
    height: 44px;
    gap: 3px;
  }

  .row {
    gap: 3px;
  }

  .guess-row {
    gap: 4px;
  }
}