:root {
  color-scheme: light;
  --bg: #f8fafc;
  --ink: #1a1f24;
  --muted: #7a8693;
  --line: #e8eef3;
  --tile: #ffffff;
  --tile-soft: #f4f7f9;
  --tile-active: #cfdde7;
  --tile-good: #3d6e8e;
  --tile-bad: #d46a5f;
  --black: #1a1f24;
  --accent: #3d6e8e;
  --accent-dark: #2f5872;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  padding-bottom: 118px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(61, 110, 142, 0.06), transparent 34%),
    radial-gradient(circle at right top, rgba(207, 221, 231, 0.32), transparent 28%),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1060px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  flex: 0 0 auto;
  width: clamp(48px, 5.5vw, 68px);
  height: clamp(48px, 5.5vw, 68px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  font-size: clamp(2.35rem, 4.8vw, 3.1rem);
  font-weight: 900;
  line-height: 0.94;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand p {
  color: var(--muted);
  font-size: 0.98rem;
  margin-top: 5px;
}

.stats-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stats {
  display: grid;
  min-width: 96px;
  justify-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.74);
  box-shadow: none;
}

.stats span:first-child {
  font-size: 1.2rem;
  font-weight: 800;
}

.stats span:last-child {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.best-time-card {
  min-width: 112px;
}

.account-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  box-shadow: none;
}

.header-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.92rem;
  box-shadow: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.admin-link {
  text-decoration: none;
}

.header-button:hover {
  border-color: #151515;
  background: #fffdf8;
  color: var(--ink);
}

.header-button:hover .header-button-icon {
  color: #151515;
}

.header-button-icon {
  width: 20px;
  height: 20px;
  color: #b58b1c;
  fill: currentColor;
}

.account-avatar,
.account-preview-avatar {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.84rem;
  font-weight: 900;
  place-items: center;
  overflow: hidden;
}

.account-preview-avatar {
  width: 48px;
  height: 48px;
  font-size: 1rem;
}

.account-avatar-image,
.account-preview-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  gap: 0;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: none;
  overflow: hidden;
}

.board-panel,
.side-panel {
  background: transparent;
  box-shadow: none;
}

.completed-button {
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  transition:
    background-color 140ms ease,
    border-color 140ms ease;
}

.completed-button:hover {
  border-color: #151515;
  background: #fffdf8;
}

.board-panel {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.board-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.board-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.board-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--tile);
  cursor: pointer;
}

.board-actions .button-icon,
.restart-puzzle-button .button-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.restart-puzzle-button,
.next-puzzle-button,
.solve-puzzle-button {
  font-weight: 800;
}

.restart-puzzle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 0;
  padding: 0 14px;
  border: 1px solid #151515;
  border-radius: 8px;
  border-color: #151515;
  color: #f8ffff;
  background: #151515;
  box-shadow: none;
  cursor: pointer;
}

.restart-puzzle-button:hover {
  border-color: #151515;
  color: #f8ffff;
  background: #151515;
}

.solve-puzzle-button {
  border-color: #151515;
  color: #151515;
  background: #fffdf8;
}

.board-actions button:hover,
.word-button.can-open:hover,
.key:hover {
  border-color: #151515;
}

.board-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.shortcut-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
}

.shortcut-strip span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.shortcut-strip kbd {
  display: inline-grid;
  min-width: 28px;
  min-height: 22px;
  place-items: center;
  padding: 1px 6px;
  border: 1px solid #d6dedf;
  border-bottom-color: #bec8ca;
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: inset 0 -1px 0 rgba(21, 21, 21, 0.08);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 900;
}

.board-word-stat,
.board-timer-stat {
  min-width: 104px;
  min-height: 38px;
  padding: 6px 12px;
  box-shadow: none;
}

.board-word-stat span:first-child,
.board-timer-stat span:first-child {
  font-size: 1.2rem;
}

.board-timer-stat span:first-child {
  min-width: 46px;
  font-variant-numeric: tabular-nums;
}

.board-timer-stat {
  position: relative;
  overflow: visible;
}

.timer-penalty-flash {
  animation: timer-penalty-flash 480ms ease;
}

.board-stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.board {
  --cols: 18;
  --rows: 13;
  --cell-size: min(38px, calc((100cqw - 6px - ((var(--cols) - 1) * 1px)) / var(--cols)));
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  grid-auto-rows: var(--cell-size);
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  gap: 1px;
  padding: 1px;
  border: 2px solid #151515;
  border-radius: 2px;
  background: #151515;
}

.board.board-locked {
  background: #151515;
}

.puzzle-start-overlay {
  position: absolute;
  inset: 2px;
  z-index: 5;
  display: grid;
  place-items: center;
  border-radius: 2px;
  backdrop-filter: none;
}

.puzzle-start-overlay.hidden {
  display: none;
}

.start-puzzle-button {
  min-height: 58px;
  padding: 0 28px;
  border: 2px solid #151515;
  border-radius: 8px;
  color: #fffdf8;
  background: #151515;
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(17, 24, 39, 0.26);
}

.start-puzzle-button:hover {
  background: #151515;
}

.mobile-input {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: -1;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0.01;
  pointer-events: none;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: var(--cell-size);
  height: var(--cell-size);
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: #fffdf8;
  font-size: clamp(0.7rem, 2.5vw, 1.48rem);
  font-weight: 760;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.cell.black {
  background: #151515;
  cursor: default;
}

.cell:disabled {
  cursor: default;
}

.cell.void-cell {
  background: #fffdf8;
  cursor: default;
}

.cell.locked {
  background: #eee8dc;
  color: var(--accent-dark);
}

.cell.correct {
  background: #dcebd6;
}

.cell.located {
  background: #cce7e4;
  color: #123f42;
}

.cell.title-found {
  background: #cce7e4;
  color: #123f42;
}

.cell.selected {
  background: #fff1a8;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.2);
}

.cell.cursor {
  background: #ffd957;
  box-shadow: inset 0 0 0 2px #111827;
}

.cell.incorrect {
  background: #f3b0aa;
  color: #5d1917;
}

.cell.incorrect.cursor {
  box-shadow: inset 0 0 0 2px #5d1917;
}

.cell-letter {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.confetti-burst {
  position: fixed;
  left: var(--x);
  top: var(--y);
  z-index: 80;
  width: 0;
  height: 0;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--size);
  height: calc(var(--size) * 1.75);
  border-radius: 2px;
  background: var(--color);
  opacity: 0;
  box-shadow: 0 0 0 1px rgba(18, 22, 24, 0.12), 0 4px 10px rgba(18, 22, 24, 0.18);
  transform: translate(-50%, -50%) rotate(0deg) scale(0.8);
  animation: confetti-pop var(--duration) linear var(--delay) forwards;
}

.confetti-piece.round {
  height: var(--size);
  border-radius: 999px;
}

.confetti-piece.wide {
  width: calc(var(--size) * 1.6);
  height: calc(var(--size) * 0.8);
}

@keyframes confetti-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(0deg) scale(0.65);
  }

  8% {
    opacity: 1;
    transform: translate(
        calc(-50% + var(--dx-early)),
        calc(-50% + var(--dy-early))
      )
      rotate(var(--early-rot))
      scale(1.04);
  }

  46% {
    opacity: 1;
    transform: translate(
        calc(-50% + var(--dx-mid)),
        calc(-50% + var(--dy-mid))
      )
      rotate(var(--mid-rot))
      scale(1.12);
  }

  78% {
    opacity: 1;
    transform: translate(
        calc(-50% + var(--dx-late)),
        calc(-50% + var(--dy-late))
      )
      rotate(var(--late-rot))
      scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--dx) + var(--drift)),
        calc(-50% + var(--dy) + var(--fall))
      )
      rotate(var(--rot))
      scale(0.92);
  }
}

@keyframes timer-penalty-flash {
  0% {
    color: #9f2d20;
    transform: scale(1);
  }

  35% {
    color: #d92d20;
    transform: scale(1.08);
  }

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

@media (prefers-reduced-motion: reduce) {
  .confetti-burst {
    display: none;
  }

  .timer-penalty-flash {
    animation: none;
  }
}

.message {
  min-height: 26px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 650;
}

.message.complete-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--ink);
}

.final-time {
  font-variant-numeric: tabular-nums;
}

.time-delta {
  display: inline-grid;
  min-width: 54px;
  min-height: 24px;
  place-items: center;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.time-delta.better,
.time-delta.best {
  border-color: #9fd8b0;
  background: #e3f7e8;
  color: #166534;
}

.time-delta.worse {
  border-color: #e5aaa1;
  background: #fde7e3;
  color: #9f2d20;
}

.time-delta.even {
  color: var(--muted);
}

.side-panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-left: 1px solid var(--line);
  min-height: 100%;
}

.word-panel h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.word-panel {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.word-list {
  display: grid;
  gap: 14px;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}

.word-group h3 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.word-group-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.word-button {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

.word-button:disabled {
  color: var(--ink);
  cursor: default;
  opacity: 1;
}

.word-button.done {
  border-color: #b7d3b0;
  background: #dcebd6;
  color: #244d28;
}

.keyboard-panel {
  position: relative;
  --key-gap: clamp(3px, 0.8cqw, 6px);
  --key-size: clamp(26px, calc((100cqw - 64px) / 10.6), 48px);
  --key-height: clamp(38px, calc(var(--key-size) * 1.12), 54px);
  width: min(760px, 100%);
  max-width: 100%;
  margin: 18px auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.keyboard-panel.hidden {
  display: none;
}

.keyboard {
  display: grid;
  gap: var(--key-gap);
  padding: 0;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: var(--key-gap);
  max-width: 100%;
}

.key {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  width: var(--key-size);
  height: var(--key-height);
  border: 1px solid #151515;
  border-radius: 6px;
  background: #151515;
  color: #fffdf8;
  font-weight: 850;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.key:hover {
  border-color: #151515;
  background: #2a2a2a;
}

.key.wide {
  width: calc(var(--key-size) * 1.8);
  font-size: 0.82rem;
}

.account-panel,
.puzzle-map-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
  background: rgba(31, 41, 51, 0.46);
}

.account-panel.hidden,
.puzzle-map-panel.hidden {
  display: none;
}

.account-card,
.puzzle-map-card,
.completed-card {
  width: min(720px, 100%);
  max-height: min(720px, calc(100dvh - 32px));
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 18px;
  border: 1px solid rgba(215, 210, 198, 0.96);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: none;
}

.account-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  height: auto;
  max-height: calc(100dvh - 32px);
  padding: 28px 24px 24px;
  scrollbar-gutter: stable;
}

.puzzle-map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.puzzle-map-header h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
}

.puzzle-map-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.puzzle-map-header button {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 800;
  place-items: center;
}

.account-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--tile);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.3rem;
  font-weight: 800;
}

.account-close:hover {
  background: #f1ede5;
}

.account-view {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.account-hero {
  text-align: center;
  margin: 4px 0 6px;
}

.account-hero h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  line-height: 1.1;
  color: var(--ink);
}

.account-hero p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--tile);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field select {
  appearance: none;
  padding-left: 48px;
  padding-right: 42px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 22px) 50% / 7px 7px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 16px) 50% / 7px 7px no-repeat,
    var(--tile);
  cursor: pointer;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: #151515;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.12);
}

.field input.invalid {
  border-color: var(--tile-bad);
  box-shadow: 0 0 0 3px rgba(212, 106, 95, 0.16);
}

.country-select-wrap {
  position: relative;
  display: block;
}

.country-select-flag {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 24px;
  height: 18px;
  transform: translateY(-50%);
  border: 1px solid rgba(26, 31, 36, 0.12);
  border-radius: 3px;
  object-fit: cover;
  pointer-events: none;
  box-shadow: none;
}

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.field-error {
  display: none;
  color: var(--tile-bad);
  font-size: 0.78rem;
  font-weight: 700;
}

.field-error.visible {
  display: block;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  border-radius: 8px;
}

.password-toggle:hover {
  color: var(--ink);
  background: #f1ede5;
}

.primary-button {
  width: 100%;
  min-height: 46px;
  border: 1px solid #151515;
  border-radius: 10px;
  background: #151515;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.05s;
}

.primary-button:hover {
  background: #151515;
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.primary-button.secondary {
  background: var(--tile);
  color: #151515;
  border-color: #151515;
}

.primary-button.secondary:hover {
  background: #fffdf8;
}

.account-switch {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.link-button {
  border: none;
  background: transparent;
  color: #151515;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  padding: 0;
}

.link-button:hover {
  color: #151515;
}

.form-banner {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.form-banner.error {
  background: rgba(212, 106, 95, 0.12);
  color: #8a2f24;
  border: 1px solid rgba(212, 106, 95, 0.32);
}

.form-banner.success {
  background: rgba(103, 163, 107, 0.14);
  color: #2f5b34;
  border: 1px solid rgba(103, 163, 107, 0.32);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.profile-avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}

.profile-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 1.5rem;
  font-weight: 900;
  overflow: hidden;
}

.profile-avatar-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-edit {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid #fffdf8;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 0.8rem;
  box-shadow: none;
}

.avatar-edit:hover {
  background: var(--accent-dark);
}

.profile-identity {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.profile-identity strong {
  font-size: 1.15rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-email {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.profile-form:first-of-type {
  border-top: none;
  padding-top: 4px;
}

.section-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.logout-button {
  margin-top: 8px;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--tile-bad);
  border-radius: 10px;
  background: transparent;
  color: var(--tile-bad);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 800;
}

.logout-button:hover {
  background: rgba(212, 106, 95, 0.1);
}

.hidden {
  display: none !important;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-legend i {
  display: block;
  width: 14px;
  height: 14px;
  border: 1px solid #b9b2a5;
  border-radius: 2px;
  background: #fffdf8;
}

.legend-started,
.puzzle-dot.started {
  border-color: #c59a22;
  background: #f7d979;
}

.legend-completed,
.puzzle-dot.completed {
  border-color: #5f955f;
  background: #84bd7f;
}

.puzzle-map-grid {
  display: grid;
  grid-template-columns: repeat(40, 1fr);
  gap: 5px;
}

.puzzle-dot {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  padding: 0;
  border: 1px solid #b9b2a5;
  border-radius: 2px;
  background: #fffdf8;
  cursor: pointer;
}

.puzzle-dot:hover,
.puzzle-dot.current {
  border-color: #111827;
  box-shadow: 0 0 0 2px #111827;
}

.leaderboard-card {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 32px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 18px;
  border: 1px solid rgba(215, 210, 198, 0.96);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: none;
}

.completed-card {
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
}

.completed-position {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.completed-viewer {
  container-type: inline-size;
  display: grid;
  gap: 14px;
  min-height: 0;
}

.completed-board {
  --cols: 15;
  --cell-size: min(30px, calc((100cqw - 6px - ((var(--cols) - 1) * 1px)) / var(--cols)));
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  grid-auto-rows: var(--cell-size);
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  gap: 1px;
  padding: 1px;
  border: 2px solid #151515;
  border-radius: 2px;
  background: #151515;
  overflow: hidden;
}

.completed-time {
  width: fit-content;
  margin: -2px auto 0;
  padding: 5px 10px;
  border: 1px solid #d7e1e1;
  border-radius: 8px;
  color: #2f5e62;
  background: #f5fbfb;
  font-size: 0.86rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.completed-cell {
  display: grid;
  width: var(--cell-size);
  height: var(--cell-size);
  border: 0;
  background: #fffdf8;
  color: var(--ink);
  font-size: clamp(0.66rem, 2.2vw, 1.05rem);
  font-weight: 800;
  line-height: 1;
  place-items: center;
}

.completed-cell.black {
  background: #151515;
}

.completed-cell.locked {
  background: #eee8dc;
  color: var(--accent-dark);
}

.completed-cell.correct {
  background: #dcebd6;
}

.completed-nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
}

.completed-nav button {
  display: grid;
  width: 44px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.6rem;
  font-weight: 800;
  place-items: center;
}

.completed-nav button:hover:not(:disabled) {
  border-color: #151515;
  background: #fffdf8;
}

.completed-nav button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.completed-nav span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
}

.leaderboard-heading {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 14px;
  min-width: 0;
}

.leaderboard-window {
  margin-top: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: right;
}

.leaderboard-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 10px 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile-soft);
}

.leaderboard-tab {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.leaderboard-tab.active {
  background: #fffdf8;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(26, 31, 36, 0.08);
}

.leaderboard-title-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: #b58b1c;
  fill: currentColor;
}

.leaderboard-prev {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
  padding: 10px 12px;
  background: var(--tile-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.86rem;
}

.leaderboard-prev-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.leaderboard-prev-name {
  font-weight: 800;
  color: var(--ink);
}

.leaderboard-prev-flag {
  display: grid;
  place-items: center;
  width: 28px;
  height: 20px;
  flex-shrink: 0;
}

.leaderboard-prev-flag img {
  width: 24px;
  height: 18px;
  border: 1px solid rgba(26, 31, 36, 0.12);
  border-radius: 3px;
  object-fit: cover;
  box-shadow: none;
}

.leaderboard-prev-trophy {
  display: grid;
  width: 24px;
  height: 24px;
  margin-left: auto;
  color: #b58b1c;
  place-items: center;
}

.leaderboard-prev-trophy svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.leaderboard-me {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: color-mix(in oklch, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in oklch, var(--accent) 30%, var(--line));
  border-radius: 10px;
  font-size: 0.92rem;
}

.leaderboard-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.leaderboard-table-header,
.leaderboard-row {
  display: grid;
  grid-template-columns: 34px 32px minmax(0, 1fr) 34px 96px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.leaderboard-table-header {
  grid-template-columns: 34px minmax(0, 1fr) 34px 96px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.leaderboard-table-header span:last-child {
  text-align: center;
}

.leaderboard-table-header span:first-child {
  text-align: left;
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-row.is-me {
  background: color-mix(in oklch, var(--accent) 8%, transparent);
}

.leaderboard-rank {
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--muted);
}

.leaderboard-row.is-top-1 .leaderboard-rank {
  color: #b58b1c;
}

.leaderboard-row.is-top-2 .leaderboard-rank {
  color: #8a8d93;
}

.leaderboard-row.is-top-3 .leaderboard-rank {
  color: #b07744;
}

.leaderboard-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.leaderboard-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leaderboard-name {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.leaderboard-flag {
  display: grid;
  place-items: center;
  width: 30px;
  height: 22px;
  flex-shrink: 0;
}

.leaderboard-flag img {
  width: 24px;
  height: 18px;
  border: 1px solid rgba(26, 31, 36, 0.12);
  border-radius: 3px;
  object-fit: cover;
  box-shadow: none;
}

.leaderboard-score {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

.leaderboard-empty,
.completed-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 24px 0 18px;
  padding: 24px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile-soft);
  text-align: center;
  color: var(--muted);
}

.leaderboard-empty-icon {
  width: 34px;
  height: 34px;
  margin-bottom: 2px;
  color: #b58b1c;
  fill: currentColor;
}

.leaderboard-empty strong,
.completed-empty strong {
  color: var(--ink);
  font-size: 0.98rem;
}

.leaderboard-empty span,
.completed-empty span {
  font-size: 0.88rem;
  font-weight: 500;
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-wrap {
    width: 100%;
    justify-content: flex-start;
  }

  .header-button,
  .account-button {
    min-height: 50px;
  }

  .stats {
    min-height: 50px;
  }
}

@media (max-height: 840px) {
  .account-panel {
    padding: 10px;
  }

  .account-card {
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 18px 24px 16px;
  }

  .account-view {
    gap: 10px;
  }

  .form-banner {
    padding: 8px 12px;
  }

  .profile-header {
    gap: 14px;
    padding-bottom: 12px;
  }

  .profile-avatar {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
  }

  .profile-form {
    gap: 8px;
    padding-top: 12px;
  }

  .field {
    gap: 5px;
  }

  .field input,
  .field select {
    height: 38px;
  }

  .primary-button,
  .logout-button {
    min-height: 40px;
  }

  .logout-button {
    margin-top: 0;
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
  }

  .stats-wrap {
    justify-content: flex-start;
  }

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

  .side-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  body {
    padding-bottom: 18px;
  }

  .board {
    --cell-size: min(38px, calc((100cqw - 4px - ((var(--cols) - 1) * 1px)) / var(--cols)));
  }

  .keyboard-panel {
    display: none !important;
  }

  .word-list {
    max-height: none;
  }

  .side-panel {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand {
    align-items: flex-start;
  }

  .brand img {
    width: 46px;
    height: 46px;
  }

  h1 {
    font-size: clamp(2.35rem, 4.8vw, 3.1rem);
  }

  .brand p {
    max-width: 230px;
  }

  .stats {
    min-width: 78px;
    padding: 8px;
  }

  .stats-wrap {
    justify-content: flex-start;
  }

  .board-panel,
  .side-panel {
    padding: 8px 4px;
  }

  .game-layout {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .board {
    gap: 1px;
    padding: 1px;
  }

  .key-row {
    gap: 4px;
  }

  .puzzle-map-grid {
    grid-template-columns: repeat(25, 1fr);
    gap: 4px;
  }

}
