:root {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  font-weight: 400;
  color: #f8fafc;
  background-color: #020617;
  --tile-size: clamp(2rem, 8vw, 3.5rem);
  --gap: 0.4rem;
  --correct: #10b981;
  --present: #f59e0b;
  --absent: #475569;
  --border: rgba(255, 255, 255, 0.15);
  --primary: #38bdf8;
  --primary-dark: #0891b2;
  --secondary: rgba(56, 189, 248, 0.15);
  --panel-bg: rgba(2, 6, 23, 0.75);
  --panel-border: rgba(148, 163, 184, 0.15);
  --text-muted: #94a3b8;
  --keyboard-max-width: 34rem;
  --key-min-width: clamp(0.9rem, 3.2vw, 1.4rem);
  --key-max-width: clamp(2.2rem, 5vw, 3.4rem);
  --key-height: clamp(2.3rem, 6vw, 3rem);
  --key-gap: clamp(0.2rem, 1.5vw, 0.45rem);
  --key-wide-scale: 1.65;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% -10%, #38bdf8 0%, rgba(56, 189, 248, 0) 35%),
    radial-gradient(circle at 80% 0%, #818cf8 0%, rgba(129, 140, 248, 0) 40%),
    #020617;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(1rem, 4vw, 3rem) 1rem;
  touch-action: manipulation;
}

.app {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem);
}

.panel {
  background: var(--panel-bg);
  border-radius: 2rem;
  padding: clamp(1.75rem, 4vw, 3rem);
  box-shadow: 0 35px 65px rgba(2, 6, 23, 0.45);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(18px);
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto 1.5rem;
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  width: fit-content;
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.45rem 1.4rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.mode-tab.is-active {
  background: rgba(56, 189, 248, 0.18);
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.mode-tab:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.5);
  outline-offset: 2px;
}

.daily-status {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px dashed rgba(148, 163, 184, 0.4);
  color: var(--text-muted);
}

.daily-card {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 1.5rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  background: rgba(15, 23, 42, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.daily-date {
  margin: 0 0 0.35rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #bae6fd;
}

.daily-clue {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.daily-meta {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
}

.daily-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.daily-archive {
  margin-top: 2.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  padding-top: 1.5rem;
}

.daily-archive-header h2 {
  margin: 0 0 0.35rem;
}

.daily-archive-header p {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
}

.daily-archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.daily-archive-item {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 1.25rem;
  padding: 1rem 1.25rem;
  background: rgba(15, 23, 42, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.daily-archive-item.is-current {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.daily-archive-date {
  margin: 0 0 0.3rem;
  font-weight: 600;
}

.daily-archive-clue {
  margin: 0 0 0.35rem;
  color: #e2e8f0;
}

.daily-archive-meta {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}

.daily-archive-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.daily-archive-empty {
  margin-top: 1.5rem;
  color: var(--text-muted);
}

/* Tighten heading-to-tagline spacing in create panel */
.panel h1 {
  margin-bottom: 0.35rem;
}

.panel .tagline {
  margin-top: 0;
}

.logo-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.logo-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.help-link {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(148, 163, 184, 0.08);
  color: #e2e8f0;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.help-link:hover {
  background: rgba(59, 130, 246, 0.2);
  color: #f8fafc;
}

.help-link:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.45);
  outline-offset: 2px;
}

.logo-text {
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  letter-spacing: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: linear-gradient(120deg, #fff, #bae6fd, #a855f7 70%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
}

.logo-accent {
  flex: 1;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(14, 165, 233, 0), rgba(14, 165, 233, 0.8), rgba(129, 140, 248, 0));
  position: relative;
  overflow: hidden;
}

.logo-accent::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -25%;
  width: 40%;
  height: 200%;
  transform: translateY(-50%);
  background: radial-gradient(circle, rgba(56, 189, 248, 0.9) 0%, rgba(56, 189, 248, 0) 65%);
  animation: shimmer 4s ease-in-out infinite;
}

.beta-badge {
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@keyframes shimmer {
  0% {
    transform: translate(-80%, -50%);
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translate(220%, -50%);
    opacity: 0.4;
  }
}

h1 {
  margin-top: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
}

.tagline {
  margin-top: -0.3rem;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Center the transient status pill below the keyboard */
.status {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1rem auto 0;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #e2e8f0;
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  box-shadow: 0 10px 25px rgba(2, 6, 23, 0.4);
  backdrop-filter: blur(8px);
  width: fit-content;
}

.rules-summary {
  margin-bottom: 1.75rem;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 1.1rem;
  background: rgba(15, 23, 42, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.rules-summary h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e2e8f0;
}

.rules-summary ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.secret-input-wrapper {
  position: relative;
  margin-top: 0.4rem; /* add space after label + hint */
  margin-bottom: 1.25rem;
}

.secret-tiles {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 1.1rem;
  background: rgba(15, 23, 42, 0.7);
  border: 2px solid var(--primary);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
  position: relative;
}

.secret-tiles::after {
  content: "Enter 4–7 letters";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.6);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.secret-tiles[data-has-value="true"]::after {
  opacity: 0;
}

.secret-tile {
  width: 100%;
  padding-top: 100%;
  border-radius: 0.6rem;
  border: 1.5px dashed rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.35);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #f8fafc;
}

.secret-tile::after {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.secret-tile.filled {
  border-style: solid;
  border-color: rgba(56, 189, 248, 0.65);
  background: rgba(56, 189, 248, 0.15);
}

.secret-input-wrapper input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: text;
  -webkit-user-select: none;
  user-select: none;
}

.secret-hint {
  margin-top: -0.25rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

#secret-hint-text {
  font-weight: 500;
}

.secret-dictionary-note {
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.8; /* slightly dimmer than the counter */
}

.secret-dictionary-note.flash {
  animation: dictionary-flash 0.9s ease;
}

.input-note {
  margin: 0.35rem 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.65);
  color: #f8fafc;
  font-size: 1rem;
  font-family: inherit;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

/* Reduce space between Creator field and Generate button */
#generate-button {
  margin-top: 1.2rem !important; /* ensure visible gap above button */
  margin-right: 0.7rem;
  display: inline-block;
}

#reset-button {
  margin-top: 1.2rem !important;
  background: #334155;
  color: #cbd5e1;
  border: 1px solid #334155;
  cursor: not-allowed;
  opacity: 0.7;
  transition: background 0.2s, color 0.2s, border 0.2s, opacity 0.2s;
  display: inline-block;
}

#create-form {
  text-align: center;
}

#create-form label,
#create-form .label-with-button,
#create-form input,
#create-form textarea,
#create-form .secret-input-wrapper,
#create-form .error {
  text-align: left;
}
#reset-button.active {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary-dark);
  cursor: pointer;
  opacity: 1;
}
#reset-button:disabled {
  pointer-events: none;
}

/* Tighten spacing below Creator input specifically */

.creator-input {
  /* ...existing styles... */
  margin-bottom: 0; /* Remove margin if button is not inside this container */
}

.generate-btn {
  margin-top: 24px;
}

/* Ensure the inline error line doesn't add spacing when empty */
#create-error {
  margin: 0;
  min-height: 0;
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: rgba(148, 163, 184, 0.6);
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.25);
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
}

.help {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.help.fine-print {
  font-size: 0.85rem;
  opacity: 0.85;
}

.label-with-button {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

.label-with-button label {
  margin-bottom: 0;
}

/* Hint text beside labels (e.g., Secret word) */
.label-with-button .label-hint {
  margin-left: 0.75rem; /* create space after label */
  color: var(--text-muted);
  display: inline-flex;
  align-items: baseline;
  font-size: 0.92rem; /* slightly smaller than body */
  font-weight: 500; /* lighter than label */
  opacity: 0.95; /* soften to reduce visual competition */
}

.label-with-button .label-hint span + span {
  margin-left: 0.6rem; /* space after (needs 4–7) */
}

/* Clue field vertical rhythm */
.label-with-button + textarea#clue-input {
  margin-top: 0; /* space between label row and textarea */
}

textarea#clue-input {
  margin-bottom: 0.4rem; /* slightly more breathing room before Creator section */
}

button.small {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.clue-autogen-status {
  margin-top: 0.25rem;
  min-height: 0; /* don't reserve space by default */
  color: var(--text-muted);
  font-weight: 600;
}

/* When status is blank, collapse it entirely to remove spacing */
.clue-autogen-status:empty {
  display: none;
}

.clue-autogen-status.pending {
  color: var(--text-muted);
}

.clue-autogen-status.success {
  color: #34d399;
}

.clue-autogen-status.error {
  color: #f87171;
}

.error {
  color: #f87171;
  font-weight: 600;
  min-height: 1.2rem;
}

.player-meta {
  margin-bottom: 1.5rem;
}

.player-meta input {
  margin-top: 0.35rem;
}

.player-meta-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.guess-warning {
  margin: 0.5rem auto 0;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fca5a5;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  box-shadow: 0 0 20px rgba(248, 113, 113, 0.25);
  width: fit-content;
}

.guess-warning[hidden] {
  display: none !important;
}

.guess-warning.flash {
  animation: dictionary-glow 1.2s ease;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.45);
  outline-offset: 2px;
}

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

button.primary {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  box-shadow: 0 15px 35px rgba(14, 165, 233, 0.35);
}

/* Greyed-out look when disabled */
button.primary:disabled {
  background: linear-gradient(135deg, #64748b, #475569);
  color: #cbd5e1;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.9;
}

button.primary:hover {
  background: linear-gradient(135deg, #4ade80, var(--primary));
}

button.secondary {
  background: var(--secondary);
  color: #e2e8f0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 20px rgba(15, 23, 42, 0.45);
}

.share-result {
  margin-top: 1.5rem;
}

.share-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.share-row input {
  flex: 1;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.copy-feedback {
  min-height: 1.2rem;
  color: var(--primary);
  font-weight: 600;
}

body.modal-open {
  overflow: hidden;
}

.modal-container {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.modal-container[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  width: min(520px, calc(100% - 2rem));
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 1.5rem;
  padding: 1.75rem;
  box-shadow: 0 35px 65px rgba(2, 6, 23, 0.55);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-kicker {
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 0.2rem;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #e2e8f0;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(148, 163, 184, 0.15);
}

.modal-body {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.onboarding-steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-details {
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 1.2rem;
  margin-bottom: 1rem;
  background: rgba(2, 6, 23, 0.35);
}

.modal-details h3 {
  margin: 0 0 0.65rem;
  color: #f8fafc;
  font-size: 1rem;
}

.modal-details ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.legend-swatch {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.3rem;
  margin-right: 0.5rem;
}

.legend-swatch.correct {
  background: var(--correct);
}

.legend-swatch.present {
  background: var(--present);
}

.legend-swatch.absent {
  background: var(--absent);
}

.modal-footer-note {
  margin: 0;
  font-size: 0.9rem;
  color: #e2e8f0;
}

.share-summary {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  border-radius: 1.4rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.share-summary-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.9rem;
}

.share-summary-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.share-summary-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.share-summary-text {
  width: 100%;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(2, 6, 23, 0.35);
  color: #f8fafc;
  font-size: 0.95rem;
  font-family: inherit;
  padding: 0.9rem 1rem;
  resize: none;
  overflow: hidden;
}

.share-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.share-summary-status {
  min-height: 1.2rem;
  font-weight: 600;
  margin-top: 0.4rem;
  color: var(--text-muted);
}

.share-summary-status.success {
  color: #34d399;
}

.share-summary-status.error {
  color: #f87171;
}

.share-summary-status.pending {
  color: var(--text-muted);
}

.recent-puzzles {
  margin-top: 2.5rem;
  padding: 1.5rem;
  border-radius: 1.5rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.recent-puzzles-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.recent-puzzles-header h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.recent-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recent-item {
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(56, 189, 248, 0.15);
  background: rgba(2, 6, 23, 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.grand-leaderboard {
  width: min(960px, 100%);
  margin: clamp(2rem, 5vw, 3.5rem) auto 0;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  background: rgba(2, 6, 23, 0.9);
  border-radius: 1.8rem;
  border: 1px solid rgba(249, 115, 22, 0.4);
  box-shadow: 0 30px 60px rgba(2, 6, 23, 0.45), 0 0 25px rgba(249, 115, 22, 0.2);
  position: relative;
  overflow: visible;
  z-index: 0;
}

.grand-leaderboard::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: calc(1.8rem + 4px);
  background: radial-gradient(circle, rgba(249, 115, 22, 0.32) 0%, rgba(249, 115, 22, 0) 70%);
  border: 1px solid rgba(249, 115, 22, 0.55);
  pointer-events: none;
  z-index: -1;
}

.grand-leaderboard__container {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  position: relative;
  z-index: 1;
}

.grand-leaderboard__header {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-end;
  justify-content: space-between;
}

.grand-leaderboard__kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  font-weight: 700;
  color: #bae6fd;
}

.grand-leaderboard__summary {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
}

.grand-leaderboard__filters {
  display: inline-flex;
  gap: 0.4rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  padding: 0.3rem;
}

.grand-filter-button {
  border: none;
  background: transparent;
  color: #e2e8f0;
  font-weight: 600;
  padding: 0.35rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.grand-filter-button.is-active {
  background: var(--primary);
  color: #02101f;
}

.grand-filter-button:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.5);
  outline-offset: 2px;
}

.grand-leaderboard__content {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 2.5rem);
}

.grand-board-list,
.grand-champs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.grand-board-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.55);
}

.grand-rank {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
  min-width: 2.1rem;
  text-align: center;
}

.grand-player-name {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
}

.grand-player {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.grand-player-meta {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.grand-solve-count {
  margin-left: auto;
  font-weight: 600;
  font-size: 1rem;
}

.grand-board-empty,
.grand-champs-empty {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.grand-leaderboard__pagination {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.grand-leaderboard__pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.grand-page-status {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.grand-leaderboard__champs {
  padding: 1rem 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 1.25rem;
  background: rgba(2, 6, 23, 0.55);
}

.grand-champs-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.grand-champs-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.grand-champ-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.grand-champ-item:last-child {
  border-bottom: none;
}

.grand-champ-name {
  margin: 0;
  font-weight: 600;
}

.grand-champ-meta {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.grand-champ-link {
  color: #bfdbfe;
  text-decoration: none;
  font-weight: 600;
}

.grand-champ-link:hover,
.grand-champ-link:focus-visible {
  color: #f8fafc;
  text-decoration: underline;
}

.grand-recent {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 1.4rem;
  padding: 1.5rem;
  background: rgba(2, 6, 23, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.community-recent-container {
  width: min(960px, 100%);
  margin: clamp(2rem, 5vw, 3.5rem) auto 0;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  background: rgba(2, 6, 23, 0.9);
  border-radius: 1.8rem;
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 30px 60px rgba(2, 6, 23, 0.45), 0 0 25px rgba(56, 189, 248, 0.15);
  position: relative;
  overflow: visible;
  z-index: 0;
}

.community-recent-container::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: calc(1.8rem + 4px);
  background: radial-gradient(circle, rgba(56, 189, 248, 0.25) 0%, rgba(56, 189, 248, 0) 70%);
  border: 1px solid rgba(56, 189, 248, 0.45);
  pointer-events: none;
  z-index: -1;
}

.community-recent-wrapper {
  position: relative;
  z-index: 1;
}

.community-recent-wrapper .grand-recent {
  border: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.community-recent-wrapper .grand-recent__header h2 {
  margin: 0.3rem 0 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.grand-recent__header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.grand-recent__header h3 {
  margin: 0;
}

.grand-recent__header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.grand-recent__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.grand-recent__item {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  background: rgba(15, 23, 42, 0.55);
}

.grand-recent__top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
}

.grand-recent__link {
  color: #fcd34d;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  text-decoration: none;
}

.grand-recent__link:hover,
.grand-recent__link:focus-visible {
  text-decoration: underline;
  color: #fde68a;
}

.grand-recent__time {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.grand-recent__clue {
  margin: 0.4rem 0 0;
  font-weight: 500;
}

.grand-recent__meta {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.grand-recent__empty {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.creator-directory {
  border: 1px solid rgba(249, 115, 22, 0.5);
  border-radius: 1.25rem;
  padding: 1rem 1.25rem;
  background: rgba(2, 6, 23, 0.55);
  margin-top: 1.5rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 0 20px rgba(249, 115, 22, 0.15);
}

.creator-directory__details {
  margin: 0;
}

.creator-directory__summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: #f1f5f9;
}

.creator-directory__summary::-webkit-details-marker {
  display: none;
}

.creator-directory__count {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.creator-directory__body {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.creator-directory__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.creator-directory__label {
  font-weight: 500;
  margin-bottom: -0.35rem;
}

.creator-directory__search {
  border-radius: 999px;
}

.creator-directory__status,
.creator-directory__empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.creator-directory__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.creator-directory__item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.creator-directory__pill {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.65);
  color: #f8fafc;
  font-weight: 600;
  padding: 0.45rem 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease, transform 0.2s ease;
}

.creator-directory__pill:hover,
.creator-directory__pill:focus-visible {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

.creator-directory__meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 860px) {
  .grand-leaderboard__content {
    grid-template-columns: 1fr;
  }

  .grand-leaderboard__pagination {
    justify-content: center;
  }
}

.recent-word {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.recent-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.recent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.recent-actions button {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
}

.recent-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.clue-box {
  margin-bottom: 1.5rem;
  padding: 1.5rem 1.75rem;
  border-radius: 1.5rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 28px rgba(2, 6, 23, 0.45);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#clue-text {
  font-size: 1.2rem;
  color: #f8fafc;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.clue-label {
  font-weight: 800;
  color: #bae6fd;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.creator-tag {
  margin-top: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  color: #f8fafc;
  padding: 0.55rem 0.9rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(129, 140, 248, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Creator listing */
.creator-heading {
  color: #9ca3af;
  margin-bottom: 1rem;
}
.creator-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
  display: grid;
  gap: 0.75rem;
}
.creator-item {
  border: 1px solid #1f2937;
  background: #0b1220;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}
.creator-item .creator-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.creator-item .creator-link {
  color: #fb923c !important;
  text-decoration: none;
}
.creator-item .creator-link:visited {
  color: #c2410c !important;
}
.creator-item .creator-link:hover {
  color: #fdba74 !important;
}
.creator-item .creator-time {
  color: #6b7280;
  font-size: 0.875rem;
}
.creator-item .creator-clue {
  color: #e5e7eb;
  margin: 0.25rem 0 0.25rem 0;
}
.creator-item .creator-meta {
  color: #9ca3af;
  font-size: 0.875rem;
}
.creator-empty {
  color: #9ca3af;
}

.creator-link-inline {
  color: #fb923c !important;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s ease;
}
.creator-link-inline:visited {
  color: #c2410c !important;
}
.creator-link-inline:hover,
.creator-link-inline:focus-visible {
  color: #fdba74 !important;
}

.board {
  margin: 2rem auto;
  display: grid;
  justify-content: center;
  gap: var(--gap);
}

.board-row {
  display: grid;
  gap: var(--gap);
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1rem;
  font-size: calc(var(--tile-size) * 0.6);
  font-weight: 700;
  text-transform: uppercase;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.9));
  color: #e2e8f0;
  box-shadow: 0 15px 35px rgba(2, 6, 23, 0.45);
  transition: transform 0.35s ease, background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  transform-style: preserve-3d;
  will-change: transform;
}

.tile.filled {
  border-color: rgba(56, 189, 248, 0.5);
  color: #f8fafc;
}

.tile.revealed {
  color: #fff;
}

.tile.flip {
  animation: flip 0.6s ease forwards;
}

.tile.correct {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: #22c55e;
}

.tile.present {
  background: linear-gradient(135deg, #facc15, #f97316);
  border-color: #facc15;
}

.tile.absent {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(148, 163, 184, 0.3);
  color: #94a3b8;
}

@keyframes flip {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(90deg) scale(0.98);
  }
  100% {
    transform: rotateX(0deg) scale(1);
  }
}

@keyframes tile-shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-4px);
  }
  100% {
    transform: translateX(0);
  }
}

.board-row.shake,
.secret-tiles.shake {
  animation: tile-shake 0.4s ease;
}

@keyframes dictionary-flash {
  0%,
  100% {
    color: var(--text-muted);
  }
  50% {
    color: #f87171;
  }
}

@keyframes dictionary-glow {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(248, 113, 113, 0.25);
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.12);
  }
  50% {
    box-shadow: 0 0 28px rgba(248, 113, 113, 0.45);
    border-color: rgba(248, 113, 113, 0.8);
    background: rgba(248, 113, 113, 0.25);
  }
}


.keyboard {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  width: min(100%, var(--keyboard-max-width));
  margin: clamp(1rem, 3vw, 1.75rem) auto;
  gap: var(--key-gap);
  padding: 0 clamp(0.25rem, 2vw, 1rem);
  box-sizing: border-box;
}

.keyboard-row {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: var(--key-gap);
  flex-wrap: nowrap;
  padding: 0 clamp(0.1rem, 1vw, 0.3rem);
}

.key {
  background: #d3d6da;
  color: #1a1a1b;
  border-radius: 0.55rem;
  flex-grow: 1;
  flex-shrink: 1;
  flex-basis: var(--key-min-width);
  min-width: var(--key-min-width);
  max-width: var(--key-max-width);
  height: var(--key-height);
  font-weight: 700;
  text-transform: uppercase;
  font-size: clamp(0.85rem, 2.6vw, 1rem);
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  border: 1px solid #d3d6da;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease, background 0.2s ease, color 0.2s ease, border 0.2s;
  padding: 0 0.35rem;
}

.key:hover {
  transform: translateY(-1px);
}

.key:active {
  transform: translateY(1px);
}

.key:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.key.wide {
  flex-grow: var(--key-wide-scale);
  flex-basis: calc(var(--key-min-width) * var(--key-wide-scale));
  min-width: calc(var(--key-min-width) * var(--key-wide-scale));
  max-width: none;
}

.key.correct {
  background: #538d4e;
  border-color: #538d4e;
  color: #fff;
}

.key.present {
  background: #b59f3b;
  border-color: #b59f3b;
  color: #fff;
}

.key.absent {
  background: #3a3a3c;
  border-color: #3a3a3c;
  color: #d7dadc;
}

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1rem auto 0;
  padding: 0.6rem 0.95rem;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 999px;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 10px 25px rgba(2, 6, 23, 0.4);
  backdrop-filter: blur(8px);
  width: fit-content;
  min-height: unset;
  font-weight: 600;
}

.status[hidden] {
  display: none !important;
}

.leaderboard {
  margin-top: 2rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 1.5rem;
  padding: 1.5rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.leaderboard h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard-hint {
  margin: 0;

  .recent-puzzles {
    padding: 1.25rem;
    margin-top: 2rem;
  }

  .recent-actions {
    flex-direction: column;
  }

  .recent-actions button {
    width: 100%;
  }
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 1rem;
  box-shadow: 0 10px 20px rgba(2, 6, 23, 0.35);
}

.leaderboard-name {
  font-weight: 600;
  color: #f8fafc;
}

.leaderboard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.leaderboard-empty {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

#error-panel {
  text-align: center;
}

@media (max-width: 900px) {
  body {
    padding: 1rem;
  }

  .app {
    padding: 1.25rem;
  }

  .panel {
    border-radius: 1.35rem;
    padding: 1.5rem;
  }

  .logo-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .logo-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .beta-badge {
    order: -1;
  }

  .board {
    margin: 1.5rem 0;
    gap: 0.4rem;
  }

  .board-row {
    gap: 0.4rem;
  }

  .leaderboard {
    padding: 1.25rem;
  }

  .leaderboard-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .leaderboard-meta {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 600px) {
  :root {
    --keyboard-max-width: 100%;
    --key-height: 2.6rem;
    --key-wide-scale: 1.8;
  }

  .action-row {
    flex-direction: column;
  }

  .status {
    width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }

  .app {
    padding: 0.75rem 0.5rem;
  }

  :root {
    --tile-size: clamp(1.75rem, 11vw, 2.3rem);
    --gap: 0.35rem;
  }

  .panel {
    border-radius: 1rem;
    padding: 0.75rem;
  }

  .logo-text {
    letter-spacing: 0.35rem;
  }

  .board {
    margin: 1.25rem auto;
  }

  :root {
    --key-min-width: 0.85rem;
    --key-max-width: 2.3rem;
    --key-height: 2.35rem;
    --key-gap: 0.22rem;
    --key-wide-scale: 2;
  }

  .keyboard-row {
    padding: 0;
  }

  #clue-text {
    flex-direction: column;
    align-items: center;
    font-size: 1rem;
  }

  .player-meta input,
  input[type="text"],
  textarea {
    font-size: 1.05rem;
  }

  .leaderboard {
    padding: 1rem;
  }

  .leaderboard-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }

  .tile {
    border-radius: 0.65rem;
  }
}

/* Falling snow effect */
.snowflake {
  position: fixed;
  top: -10px;
  z-index: 9999;
  color: #fff;
  font-size: 0.5em;
  font-family: Arial, sans-serif;
  text-shadow: 0 0 5px #000;
  pointer-events: none;
  animation: fall linear infinite;
}

@keyframes fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0.3;
  }
}
