:root {
  --bg: #0d1b2a;
  --bg-soft: #152a3d;
  --card: #132738;
  --accent: #f0b429;
  --accent-dark: #d99a18;
  --text: #f7f4ee;
  --muted: #a3b5c5;
  --good: #3ecf8e;
  --warn: #f87171;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #213b55 0%, var(--bg) 55%);
  min-height: 100vh;
}

body.light {
  --bg: #f6f5f1;
  --bg-soft: #ecebe6;
  --card: #ffffff;
  --accent: #c9b458;
  --accent-dark: #b59f3b;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --good: #6aaa64;
  --warn: #d9534f;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
  background: #f6f5f1;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 4px 10px 8px;
  position: relative;
}

.wordle-layout {
  display: grid;
  gap: 6px;
}

.badge {
  display: inline-block;
  background: var(--accent);
  color: #2b1c05;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.58rem;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.topbar-title {
  text-align: center;
}

.topbar-title h1 {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(1.9rem, 3.8vw, 3.1rem);
  margin: 0;
  letter-spacing: 0.04em;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar-left {
  justify-content: flex-start;
}

.topbar-right {
  justify-content: flex-end;
}

.icon-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  min-width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  padding: 0 10px;
  text-decoration: none;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  display: block;
}

.icon-button#theme-toggle {
  width: 36px;
  min-width: 36px;
  padding: 0;
}

.icon-text {
  width: auto;
  min-width: 0;
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-size: clamp(0.66rem, 2.2vw, 0.98rem);
  padding: 0 8px;
}

.icon-moon {
  display: none !important;
}

body.light .icon-sun {
  display: none !important;
}

body.light .icon-moon {
  display: block !important;
}

.admin-link {
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-link:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.4);
}

.board {
  display: grid;
  gap: 4px;
  align-content: start;
}

.countdown {
  position: fixed;
  right: 16px;
  bottom: 16px;
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(13, 27, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 10px;
  border-radius: 999px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 20;
}

.result-modal {
  position: fixed;
  inset: 0;
  background: transparent;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.result-modal.active {
  display: flex;
}

.result-card {
  position: relative;
  width: min(420px, 88vw);
  background: #f2f1ed;
  border-radius: 18px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  text-align: center;
  overflow: hidden;
  margin-top: 120px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid rgba(255, 107, 107, 0.6);
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 1rem;
}

.modal-visual {
  width: 120px;
  height: 120px;
  margin: 10px auto 12px;
  display: grid;
  place-items: center;
}

.modal-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-width: 120px;
  max-height: 120px;
  animation: pop 0.45s ease-out;
}

.modal-visual .big-x {
  font-size: 4rem;
  color: #ff6b6b;
  animation: pop 0.45s ease-out;
}

.modal-message {
  font-weight: 700;
  margin-bottom: 16px;
}

.howto-card {
  width: min(720px, 92vw);
  min-height: 70vh;
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #b4b0a8;
}

.howto-body {
  margin-bottom: 14px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

.howto-body p {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.howto-body p:last-child {
  border-bottom: 0;
}

.modal-actions {
  display: grid;
  gap: 8px;
}

.modal-home {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent);
  color: #2b1c05;
  text-decoration: none;
  font-weight: 700;
}

.modal-dismiss {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

#howto-modal .modal-dismiss {
  background: #1d1b16;
  color: #f7f4ee;
  border-color: transparent;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: fall 1.2s ease-out forwards;
}

@keyframes fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(220px) rotate(220deg);
    opacity: 0;
  }
}

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

body.light .result-card {
  background: #f2f1ed;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light .modal-dismiss,
body.light .modal-close {
  color: #2b2b2b;
  border-color: rgba(0, 0, 0, 0.2);
}

.panel {
  background: var(--card);
  padding: 5px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

body.light .panel {
  border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light .icon-button,
body.light .admin-link {
  color: #3b3b3b;
  border-color: rgba(0, 0, 0, 0.2);
}

body.light input {
  background: #f0efec;
  border-color: rgba(0, 0, 0, 0.15);
}

body.light select {
  background: #f0efec;
  border-color: rgba(0, 0, 0, 0.15);
}

body.light .suggestion,
body.light .guess-pill,
body.light .tile {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light .face-wrap,
body.light .path-panel img {
  background: #f0efec;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light .countdown {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.08);
}

.panel-title {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.5rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 1px;
  text-align: center;
}

.info-panel .panel-title {
  font-size: 0.7rem;
  font-weight: 700;
}

.home-panel .panel-title {
  font-size: 0.65rem;
  font-weight: 700;
}

.panel-body {
  display: grid;
  gap: 2px;
}

.path-panel img {
  width: 100%;
  height: 135px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  object-fit: contain;
}

body.light .path-panel img {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light .path-panel .panel-body {
  background: #ffffff;
  border-radius: 12px;
  padding: 4px;
}

.image-caption {
  font-size: 0.66rem;
  color: var(--muted);
  text-align: center;
}

.input-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
}

input {
  flex: 1;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #0d1b2a;
  color: var(--text);
  font-size: 0.82rem;
}

select {
  flex: 1;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #0d1b2a;
  color: var(--text);
  font-size: 0.82rem;
}

button {
  padding: 7px 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #2b1c05;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.suggestions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-start;
  align-items: center;
  height: 26px;
  overflow: hidden;
  padding: 0 4px;
}

.suggestion {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
  flex: 0 0 auto;
}

.suggestion:hover {
  background: rgba(240, 180, 41, 0.2);
}

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

.tile {
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 10px;
  text-align: center;
  min-height: 32px;
  display: grid;
  gap: 1px;
  place-items: center;
}

.tile .label {
  display: block;
  font-size: 0.48rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.guess-list {
  margin-top: 4px;
  max-height: 60px;
}

.guess-pill {
  padding: 5px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.result {
  margin-top: 6px;
  font-weight: 600;
  text-align: center;
  min-height: 22px;
  max-height: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.tier {
  margin-top: 3px;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  min-height: 18px;
  max-height: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.tier.good {
  color: var(--good);
}

.tier.bad {
  color: var(--warn);
}

.trophy-row {
  margin-top: 6px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.trophy-slot {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
}

.trophy-slot img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.trophy-cross {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  color: #ff6b6b;
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.55);
  opacity: 0;
}

.trophy-slot.missed .trophy-cross {
  opacity: 1;
}

.trophy-row.won {
  justify-content: center;
}

.trophy-row.won .trophy-slot {
  display: none;
}

.trophy-row.won .trophy-slot.winner {
  display: grid;
  width: 70px;
  height: 70px;
}

.trophy-row.won .trophy-slot.winner img {
  width: 58px;
  height: 58px;
}

.trophy-hint {
  margin-top: 6px;
  text-align: center;
  font-size: 0.76rem;
  color: var(--muted);
}

.home-board {
  min-height: calc(100vh - 160px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.home-board .home-panel {
  width: 100%;
}

.home-board .rank-panel {
  width: 100%;
}

.rank-panel {
  padding: 14px 16px;
  text-align: center;
}

.rank-text {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111;
  letter-spacing: 0.02em;
}

.rank-text span {
  color: var(--accent);
}

.home-board .today-stats-panel {
  width: 100%;
}

.home-panel {
  padding: 16px 18px;
}

.home-buttons {
  margin-top: 10px;
  display: grid;
  gap: 12px;
}

.level-button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.today-stats-panel {
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: grid;
  gap: 6px;
}

.today-stats-title {
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.today-stats-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text);
}

.today-stats-level {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.today-stats-attempts,
.today-stats-first {
  color: var(--muted);
  font-weight: 600;
}

.today-stats-bar {
  grid-column: 2 / 4;
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.today-stats-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f0b429, #6aaa64);
  transition: width 0.4s ease;
}

.level-button:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.level-status {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.level-status.trophy {
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 70% 70%;
}

.level-status.trophy img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.level-status.miss {
  color: #d9534f;
  background: rgba(217, 83, 79, 0.08);
  border-color: rgba(217, 83, 79, 0.4);
}

.level-status.pending {
  color: var(--muted);
}

body.light .level-button {
  background: #f1f0ed;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light .level-status {
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
}

.stats-board {
  align-content: center;
}

.stats-panel {
  padding: 16px 18px;
}

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

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

.analytics-grid .stats-row {
  grid-template-columns: 1fr auto;
}

.stats-column {
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: grid;
  gap: 10px;
}

.stats-header {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.stats-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 10px;
}

.stats-row.streak-row {
  grid-template-columns: 1fr auto;
  gap: 18px;
}

.stats-row img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.stats-x {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: #d9534f;
}

.stats-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.stats-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.stats-section {
  margin-top: 4px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stats-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 2px 0;
}

.stats-row:nth-of-type(even) {
  background: rgba(255, 255, 255, 0.04);
}

body.light .stats-column {
  background: #f1f0ed;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light .stats-row:nth-of-type(even) {
  background: rgba(0, 0, 0, 0.04);
}

.info-board {
  align-content: center;
}

.info-panel {
  padding: 18px 20px;
}

.info-text {
  margin: 6px 0 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.info-panel .panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #000;
  letter-spacing: 0.02em;
}

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

@media (max-width: 520px) {
  .trophy-slot {
    width: 58px;
    height: 58px;
  }

  .trophy-slot img {
    width: 48px;
    height: 48px;
  }

  .trophy-cross {
    font-size: 1.7rem;
  }

  .trophy-row.won .trophy-slot.winner {
    width: 70px;
    height: 70px;
  }

  .trophy-row.won .trophy-slot.winner img {
    width: 58px;
    height: 58px;
  }
}
.reveal-panel .panel-body {
  justify-items: center;
}

.face-wrap {
  position: relative;
  width: 175px;
  height: 175px;
  border-radius: 14px;
  overflow: hidden;
  background: #0b1725;
  border: 2px solid rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
}

#face-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  border: none;
  border-radius: 12px;
}

.face-placeholder {
  padding: 20px;
  text-align: center;
  color: var(--muted);
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.preview-grid {
  display: grid;
  gap: 12px;
}

.preview-item {
  background: #0b1725;
  border-radius: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-item img {
  width: 100%;
  border-radius: 10px;
  max-height: 240px;
  object-fit: contain;
}

.preview-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 6px;
}

.footer {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
}

.footer-note span {
  color: var(--accent);
}

@media (max-width: 720px) {
  .input-wrap {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .admin-link {
    position: static;
    display: inline-block;
    margin-top: 12px;
  }
}

@media (max-width: 520px) {
  .page {
    max-width: 100%;
    padding: 12px 12px 22px;
  }

  .topbar {
    grid-template-columns: 1fr auto 1fr;
    gap: 6px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-title h1 {
    font-size: 1.75rem;
  }

  .badge {
    font-size: 0.55rem;
    padding: 2px 7px;
  }

  .icon-button {
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    font-size: 0.85rem;
  }

  .icon-button#theme-toggle {
    width: 26px;
    min-width: 26px;
    padding: 0;
  }

  .icon-button.icon-text {
    padding: 0 6px;
    font-size: 0.68rem;
  }

  .admin-link {
    font-size: 0.56rem;
    padding: 2px 6px;
  }

  .icon-button svg {
    width: 14px;
    height: 14px;
  }

  #guess-input {
    font-size: 16px;
  }

  .panel {
    padding: 8px;
  }

  .rank-text {
    font-size: 0.95rem;
  }

  .today-stats-row {
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
  }

  .today-stats-bar {
    grid-column: 1 / -1;
  }

  .guess-panel {
    min-height: 230px;
  }

  .board {
    min-height: calc(100vh - 140px);
    align-content: start;
    gap: 13px;
  }

  .face-wrap {
    width: 195px;
    height: 195px;
  }

  .path-panel img {
    height: 155px;
  }

  .suggestion {
    font-size: 0.78rem;
  }

  .result {
    font-size: 0.8rem;
  }

  .tier {
    font-size: 0.78rem;
  }

  .countdown {
    right: 10px;
    bottom: 10px;
    font-size: 0.65rem;
  }
}

@media (max-width: 380px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .face-wrap {
    width: 130px;
    height: 130px;
  }

  .path-panel img {
    height: 100px;
  }
}
