body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px 0 24px;
  box-sizing: border-box;
  font-family: "Nanum Pen Script", cursive;
  font-size: 22px;
  text-transform: lowercase;
}

#container.connections-page {
  max-width: 640px;
  width: 100%;
  margin: 0 auto 32px;
  padding: 0 16px;
  box-sizing: border-box;
}

.connections-page h1 {
  font-weight: 300;
  font-size: 42px;
  letter-spacing: -0.02em;
  margin-top: 28px;
  margin-bottom: 4px;
}

.tagline {
  color: #7a7a7a;
  font-size: 22px;
  margin-bottom: 24px;
}

.board-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.board-picker label {
  margin: 0;
  font-weight: 300;
  font-size: 22px;
}

.board-picker select {
  appearance: none;
  background: #fff;
  border: 2px solid #d9d9d0;
  border-radius: 999px;
  padding: 6px 32px 6px 14px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 300;
  color: #3d3d3d;
  background-image: linear-gradient(45deg, transparent 50%, #5b5b5b 50%),
    linear-gradient(135deg, #5b5b5b 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 3px),
    calc(100% - 11px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.board-picker select:focus {
  outline: none;
  border-color: #79b7bb;
}

#play-fade {
  opacity: 1 !important;
}

#game {
  position: relative;
}

.board-switch-snapshot {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  box-sizing: border-box;
  background: #fff;
  opacity: 1;
}

.board-switch-snapshot.is-leaving {
  opacity: 0;
}

.board-header {
  position: absolute;
  bottom: 100%;
  right: 0;
  z-index: 3;
  margin: 0 0 10px;
}

.guess-history {
  position: relative;
}

.guess-history-btn {
  display: inline-flex;
  padding: 4px 6px;
  color: #cfcfc6;
  line-height: 1;
  cursor: default;
}

.guess-history-icon {
  width: 28px;
  height: 28px;
  display: block;
}

.guess-history-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  max-width: min(360px, calc(100vw - 48px));
  background: #1a1a1a;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 20px;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 5;
}

.guess-history-btn:hover + .guess-history-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.guess-history-empty {
  color: #cfcfc6;
}

.guess-history-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.guess-history-item:first-child {
  padding-top: 0;
}

.guess-history-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.guess-history-words {
  line-height: 1.35;
}

.guess-history-result {
  flex-shrink: 0;
  white-space: nowrap;
}

.guess-history-result.correct {
  color: #a0c35a;
}

.guess-history-result.one-away {
  color: #f9df6d;
}

.guess-history-result.wrong {
  color: #e8a0a0;
}

.board-wrap {
  position: relative;
}

.board-stage {
  position: relative;
}

.tile-grid,
#solved-categories {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

#solved-categories:empty {
  display: none;
}

#solved-categories:not(:empty) {
  margin-bottom: 8px;
}

.tile {
  background: #efefe6;
  border: none;
  border-radius: 8px;
  min-height: 82px;
  padding: 8px 6px;
  font-family: inherit;
  font-size: 24px;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: #1a1a1a;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.tile.long {
  font-size: 20px;
}

.tile:hover:not(:disabled) {
  transform: translateY(-1px);
}

.tile-grid.is-animating .tile {
  pointer-events: none;
}

.tile-grid.is-animating .tile:hover {
  transform: none;
}

.tile.selected {
  background: #5a594e;
  color: #fff;
}

.tile:disabled {
  cursor: default;
}

.solved-row {
  grid-column: 1 / -1;
  border-radius: 8px;
  min-height: 82px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #1a1a1a;
  animation: pop-in 0.28s ease;
}

.solved-row.no-pop {
  animation: none;
}

.flying-tile {
  position: fixed;
  z-index: 5;
  pointer-events: none;
  margin: 0;
  box-sizing: border-box;
  cursor: default;
}

.solved-title {
  font-weight: 900;
  letter-spacing: 0.04em;
  font-size: 24px;
  -webkit-text-stroke: 0.7px currentColor;
}

.solved-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 2px;
  margin-top: 4px;
  font-weight: 300;
  -webkit-text-stroke: 0;
}

.solved-tile {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 300;
  font-size: 22px;
  -webkit-text-stroke: 0;
}

.solved-comma {
  margin-right: 6px;
  font-weight: 300;
  -webkit-text-stroke: 0;
}

.solved-tile.has-visual {
  flex-direction: column;
  gap: 2px;
  min-width: 64px;
}

.solved-tile.bonus {
  background: rgba(255, 255, 255, 0.45);
  border: 1.5px dashed rgba(0, 0, 0, 0.28);
  border-radius: 999px;
  padding: 4px 10px;
}

.solved-emoji {
  font-size: 22px;
  line-height: 1;
}

.solved-image {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.solved-suffix {
  font-weight: 300;
}

.mistakes-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 18px;
  font-weight: 300;
}

#mistake-dots {
  display: inline-flex;
  gap: 6px;
}

.mistake-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d8d8d0;
}

.mistake-dot.filled {
  background: #5a594e;
}

#controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.connections-page .btn {
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 300;
  font-family: inherit;
  font-size: 18px;
  min-width: 100px;
  margin: 0 4px;
}

.connections-page .btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.connections-page .btn-outline {
  background: transparent;
  color: #3d3d3d;
  border: 2px solid #cfcfc6;
}

.connections-page .btn-outline:hover,
.connections-page .btn-outline:focus,
.connections-page .btn-outline:active {
  background: #efefe6;
  color: #3d3d3d;
  border-color: #cfcfc6;
}

.game-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}

.result-banner {
  display: grid;
  grid-template-rows: 0fr;
  justify-items: center;
  width: 100%;
  margin-bottom: 0;
  transition:
    grid-template-rows 0.4s cubic-bezier(0.25, 1, 0.5, 1),
    margin-bottom 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.result-banner.open {
  grid-template-rows: 1fr;
  margin-bottom: 10px;
}

.result-banner-slot {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#replay-btn,
#share-btn {
  display: none;
  min-width: 140px;
  font-size: 22px;
  padding: 8px 22px;
  margin: 0 0 4px;
}

#replay-btn.visible,
#share-btn.visible {
  display: inline-block;
}

.banner-msg {
  display: none;
  background: #1a1a1a;
  color: #fff;
  font-weight: 300;
  font-size: 22px;
  line-height: 1.2;
  padding: 10px 18px;
  border-radius: 8px;
  white-space: nowrap;
}

#toast.banner-msg {
  display: inline-block;
  position: absolute;
  left: 50%;
  top: 12px;
  z-index: 7;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

#toast.banner-msg.visible {
  opacity: 1;
  visibility: visible;
}

#result.banner-msg {
  display: inline-block;
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 0.35s ease 0.05s,
    transform 0.35s cubic-bezier(0.25, 1, 0.5, 1) 0.05s;
}

#result.banner-msg.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .result-banner,
  #result.banner-msg,
  .board-switch-snapshot {
    transition: none;
  }
}

#result-title {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

#result-body:empty {
  display: none;
}

#result-body {
  margin: 0;
  color: inherit;
}

.tile-grid.shake .tile.selected {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 520px) {
  #container.connections-page {
    margin: 0 auto 16px;
  }

  .tile {
    min-height: 68px;
    font-size: 20px;
    padding: 6px 4px;
  }

  .tile.long {
    font-size: 16px;
  }

  .solved-row {
    min-height: 68px;
    padding: 10px;
  }

  .solved-title,
  .solved-tile {
    font-size: 18px;
  }

  .connections-page .btn {
    min-width: 0;
    font-size: 16px;
  }
}
