/* Sanahakuperhe: Teemasanahaku, Salasanahaku, Vihjesanahaku, Numerohaku, Samasanahaku. */

.haku-page .container {
  width: min(100%, 1180px);
  margin: 0 auto;
}

.haku-lead {
  max-width: 760px;
  margin: 0 auto 18px;
  font-size: 17px;
  line-height: 1.6;
  text-align: center;
}

.haku-family {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 22px 0 18px;
}

.haku-family a {
  padding: 8px 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.haku-family a:hover,
.haku-family a:focus-visible {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.haku-family a[aria-current="page"] {
  border-color: #c9a227;
  background: #c9a227;
  color: #12263f;
}

.haku-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
}

.haku-app {
  color: #12263f;
  text-align: left;
}

.haku-btn {
  min-height: 42px;
  margin: 0;
  padding: 9px 14px;
  border: 1px solid #9abbd0;
  border-radius: 8px;
  background: #e7f1f8;
  color: #064b72;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.haku-btn:hover,
.haku-btn:focus-visible {
  background: #d3e7f4;
  color: #043a59;
}

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

.haku-btn[hidden] {
  display: none;
}

.haku-primary {
  border-color: #c9a227;
  background: #c9a227;
  color: #12263f;
}

.haku-primary:hover,
.haku-primary:focus-visible {
  background: #e0b92f;
  color: #12263f;
}

.haku-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px 14px 0 0;
  background: #0c2340;
  color: #fff;
}

.haku-daybar,
.haku-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.haku-daylabel {
  padding: 0 6px;
  font-weight: 800;
}

.haku-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}

.haku-field select {
  min-height: 42px;
  max-width: 220px;
  padding: 6px 8px;
  border: 1px solid #9abbd0;
  border-radius: 8px;
  background: #fff;
  color: #12263f;
  font: inherit;
  font-size: 15px;
}

.haku-headline {
  padding: 16px 18px 4px;
  background: #fffaf1;
}

.haku-title {
  margin: 0;
  color: #12263f;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: clamp(24px, 4vw, 32px);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.haku-meta {
  margin: 4px 0 0;
  color: #4b5d75;
  font-size: 14px;
}

.haku-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 18px;
  align-items: start;
  padding: 14px 18px 20px;
  border-radius: 0 0 14px 14px;
  background: #fffaf1;
}

.haku-sheet {
  min-width: 0;
}

.haku-grid {
  --cols: 10;
  --cell: 40px;
  width: min(100%, calc(var(--cols) * 46px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  border: 2px solid #12263f;
  background: #12263f;
  gap: 1px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.haku-cell {
  min-width: 0;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #12263f;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(10px, calc(var(--cell) * 0.5), 22px);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.haku-grid-digits .haku-cell {
  font-size: clamp(11px, calc(var(--cell) * 0.52), 22px);
}

.haku-cell:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid #0a84ff;
  outline-offset: -3px;
}

.haku-cell.found {
  background: var(--found-bg, #bfe7c9);
}

.haku-cell[data-color="0"] { --found-bg: #bfe7c9; }
.haku-cell[data-color="1"] { --found-bg: #bcdcf5; }
.haku-cell[data-color="2"] { --found-bg: #f6d7a7; }
.haku-cell[data-color="3"] { --found-bg: #e3c9f2; }
.haku-cell[data-color="4"] { --found-bg: #f5c6c6; }
.haku-cell[data-color="5"] { --found-bg: #c8eee8; }
.haku-cell[data-color="6"] { --found-bg: #eee3a1; }
.haku-cell[data-color="7"] { --found-bg: #d6d9f6; }

.haku-cell.revealed {
  background: #e4e4e4;
  color: #666;
}

.haku-cell.leftover {
  background: #12263f;
  color: #ffd75e;
}

.haku-cell.sel,
.haku-cell.anchor {
  background: #1685c0;
  color: #fff;
}

.haku-cell.hint {
  animation: haku-hint 0.5s ease-in-out 5;
}

@keyframes haku-hint {
  50% { background: #ff8a3d; color: #fff; }
}

.haku-side {
  min-width: 0;
  padding: 14px;
  border: 1px solid #e1d4b8;
  border-radius: 12px;
  background: #fff;
}

.haku-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.haku-stats [data-timer] {
  font-variant-numeric: tabular-nums;
  color: #4b5d75;
}

.haku-message {
  min-height: 2.6em;
  margin: 8px 0;
  color: #0d6b3d;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.haku-list-title {
  margin: 4px 0 8px;
  color: #12263f;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.haku-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 14px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.haku-list li {
  padding: 3px 0;
  break-inside: avoid;
  overflow-wrap: anywhere;
}

.haku-list li.found {
  color: #7a8796;
  text-decoration: line-through;
}

.haku-list li.revealed {
  color: #a3abb6;
}

.haku-list-numbers {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.haku-list-clues {
  columns: 1;
}

.haku-list-clues li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid #efe6d2;
}

.haku-list-clues li.found {
  text-decoration: none;
}

.haku-clue {
  font-weight: 600;
}

.haku-answer {
  flex: none;
  color: #7a8796;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.haku-list-clues li.found .haku-clue {
  color: #7a8796;
}

.haku-list-clues li.found .haku-answer {
  color: #0d6b3d;
  font-size: 15px;
}

.haku-chip {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 4px 8px;
  border: 1px dashed #b9c6d6;
  border-radius: 6px;
  color: #b9c6d6;
}

.samasanahaku-page .haku-list {
  columns: 1;
}

.haku-chip.found {
  border-style: solid;
  border-color: #0d6b3d;
  background: #e2f5e8;
  color: #0d6b3d;
  text-decoration: none;
}

.haku-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.haku-secret {
  margin: 16px auto 0;
  width: min(100%, 560px);
  text-align: center;
}

.haku-secret[hidden],
.haku-secret-form[hidden] {
  display: none;
}

.haku-secret-label {
  margin: 0 0 8px;
  font-weight: 800;
}

.haku-secret-boxes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
}

.haku-secret-word {
  display: flex;
  gap: 3px;
}

.haku-secret-box {
  width: 30px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #12263f;
  border-radius: 4px;
  background: #fff;
  font-size: 20px;
  font-weight: 800;
}

.haku-complete .haku-secret-box {
  border-color: #0d6b3d;
  background: #e2f5e8;
}

.haku-secret-form {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.haku-secret-form input {
  min-width: 0;
  width: min(100%, 260px);
  min-height: 42px;
  padding: 6px 10px;
  border: 2px solid #9abbd0;
  border-radius: 8px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
}

.haku-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.haku-complete .haku-headline::after {
  content: "Ratkaistu ✓";
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #0d6b3d;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 860px) {
  .haku-board {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 8px 16px;
  }

  .haku-toolbar {
    padding: 10px;
  }

  .haku-options {
    width: 100%;
  }

  .haku-field {
    flex: 1 1 140px;
  }

  .haku-field select {
    flex: 1;
    max-width: none;
  }

  .haku-headline {
    padding: 12px 10px 2px;
  }
}

@media (max-width: 480px) {
  .haku-page > .main-wrapper {
    padding-inline: 8px;
  }

  .haku-daylabel {
    order: -1;
    width: 100%;
    padding: 0;
  }

  .haku-btn {
    padding: 8px 10px;
    font-size: 14px;
  }

  .haku-grid {
    border-width: 1px;
  }

  .haku-secret-box {
    width: 24px;
    height: 30px;
    font-size: 16px;
  }
}

.haku-revealed .haku-headline::after {
  content: "Ratkaisu näytetty";
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #6b7787;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
