.spiral-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  container-type: inline-size;
  container-name: spiral-layout;
}

.spiral-board-card {
  padding: 1rem;
  border: 1px solid #d9dfd7;
  border-radius: 1rem;
  background: #fff;
}

#spiral-board {
  width: 100%;
  height: auto;
  max-height: 78vh;
  display: block;
}

.spiral-cell {
  fill: #f8f8f5;
  stroke: #1e1e1e;
  stroke-width: 1.1;
  cursor: pointer;
}

.spiral-cell.is-selected {
  fill: #ffe08a;
}

.spiral-cell.is-active {
  fill: #b8d8e8;
}

.spiral-cell.is-active.is-selected {
  fill: #ffd700;
}

.spiral-cell.is-correct {
  fill: #c8f5c8;
}

.spiral-cell.is-wrong {
  fill: #ffc8c8;
}

.spiral-order {
  font: 600 8px Arial, sans-serif;
  fill: #777;
  pointer-events: none;
}

.spiral-letter {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 24px;
  font-weight: 700;
  fill: #151515;
  pointer-events: none;
}

.spiral-panel {
  display: flex;
  flex-direction: column;
  height: min(calc(78vh + 2rem), calc(100cqw - 316px));
  min-height: 0;
  overflow: hidden;
  border: 1px solid #d9dfd7;
  border-radius: 1rem;
  background: #fff;
  padding: 1rem;
}

.spiral-panel-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.spiral-direction-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 15rem);
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.spiral-direction-switch button {
  padding: 0.38rem 0.45rem;
  border: 1px solid #b8c8be;
  border-radius: 0.45rem;
  color: #526159;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.spiral-direction-switch button.is-active {
  border-color: #176b4d;
  color: #fff;
  background: #176b4d;
}

.spiral-definitions {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.spiral-clue-column {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.spiral-clue-column h2 {
  flex: 0 0 auto;
  margin: 0.25rem 0 0;
  color: #526159;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.spiral-clues-list {
  min-height: 0;
  flex: 1 1 0;
  overflow: auto;
  border-radius: 0.3em;
  background: #eef4f7;
  font-size: 0.86rem;
}

.spiral-clue-item {
  display: block;
  width: 100%;
  padding: 0.27rem 0.4rem;
  border: 0;
  border-radius: 0.35rem;
  color: inherit;
  background: transparent;
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.35;
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

.spiral-clue-item:hover {
  background: #cfe4d8;
  color: inherit;
}

.spiral-clue-item.is-selected,
.spiral-clue-item.is-selected:hover {
  color: #fff;
  background: #176b4d;
}

.spiral-status {
  margin-top: 1rem;
  flex: 0 0 auto;
}

.spiral-actions {
  display: grid;
  gap: 0.5rem;
  flex: 0 0 auto;
  margin-top: auto;
}

@media (max-width: 900px) {
  .spiral-layout {
    grid-template-columns: 1fr;
  }

  .spiral-panel {
    height: auto;
  }

  .spiral-definitions {
    flex: 0 0 auto;
    grid-template-rows: none;
    overflow: visible;
  }

  .spiral-clue-column {
    overflow: visible;
  }

  .spiral-clues-list {
    flex: 0 1 auto;
    max-height: 16rem;
  }
}
