:root {
  --green: #8ac783;
  --yellow: #dbc96d;
  --red: #dd6666;
  --border: #b8b8b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f7f7;
  color: #111;
}

main {
  flex: 1 0 auto;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.logo {
  display: block;
  width: min(660px, 100%);
  height: auto;
  margin: 0 auto 8px;
}

p {
  margin: 0 0 12px;
}

.controls {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 16px 0 18px;
  flex-wrap: wrap;
  width: 1085px;
}

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 16px;
}

.mode-tab.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

input, button, select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

input {
  width: 100%;
  min-width: 240px;
}

.guess-search {
  position: relative;
  flex: 1 1 320px;
  min-width: 260px;
}

.suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
}

.suggestions.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #e7e7e7;
  border-radius: 0;
  background: #fff;
  color: #111;
  text-align: left;
}

.suggestion-item:last-child {
  border-bottom: 0;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: #f3f3f3;
}

.suggestion-image {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 6px;
  object-fit: cover;
}

button {
  cursor: pointer;
  background: #fff;
}

button:hover {
  background: #f0f0f0;
}

.dev-button {
  border-color: #d79a9a;
  color: #8f2525;
}

.dev-button:hover {
  background: #fff1f1;
}

.dev-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -6px 0 18px;
  color: #555;
  font-size: 0.95rem;
}

.dev-controls select {
  flex: 1 1 320px;
  min-width: 260px;
  max-width: 420px;
  background: #fff;
}

.puzzle-meta {
  min-height: 24px;
  margin-bottom: 4px;
  color: #333;
  font-weight: 600;
}

.status {
  min-height: 24px;
  margin-bottom: 10px;
}

.result-button {
  display: block;
  margin: 0 auto 16px;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  font-size: 0.95rem;
}

.legend-item {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.swatch {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  perspective: 900px;
}

.splash-panel {
  max-width: 540px;
  margin: 0 auto 20px;
}

.splash-art-wrap {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.splash-art {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scale(1.04);
  transition: filter 900ms ease;
}

.splash-hint {
  margin: 10px 0;
  text-align: center;
  color: #444;
}

.splash-guesses {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.splash-guess {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  text-align: center;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(7, 148px);
  gap: 8px;
  width: max-content;
}

.cell {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 8px;
  min-height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
  font-size: 0.95rem;
  word-break: break-word;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.cell.flip-in {
  animation: flip-in 900ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--flip-delay, 0ms);
}

@keyframes flip-in {
  0% {
    opacity: 0;
    transform: rotateY(-100deg);
  }

  45% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: rotateY(0deg);
  }
}

.guess-name {
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  text-align: center;
  font-size: 1.08rem;
  font-weight: 600;
}

.character-image {
  width: 88px;
  height: 88px;
  flex: 0 0 88px;
  border-radius: 6px;
  object-fit: cover;
}

.header .cell {
  font-weight: 700;
  background: #ececec;
  min-height: 52px;
}

.exact {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.partial {
  background: var(--yellow);
  color: #fff;
  border-color: var(--yellow);
}

.none {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.arrow {
  display: inline-block;
  margin-left: 6px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.38);
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  position: relative;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  margin: 0 34px 8px 0;
  font-size: 1.5rem;
}

.modal textarea {
  width: 100%;
  min-height: 96px;
  margin: 10px 0;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  padding: 0;
}

.note {
  margin-top: 20px;
  color: #444;
  font-size: 0.92rem;
}

@media (max-width: 920px) {
  .board {
    padding-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cell.flip-in {
    animation: none;
  }
}

.app-footer {
  flex-shrink: 0;
  margin-top: 56px;
  padding: 22px 0 26px;
  border-top: 1px solid #d8d8d8;
  background: #eeeeee;
  color: #444;
  font-size: 0.92rem;
}

.app-footer .page-frame {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.app-footer p {
  margin: 0 0 8px;
  line-height: 1.45;
}

.app-footer p:last-child {
  margin-bottom: 0;
}

.app-footer a {
  color: #111;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: #bdbdbd;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.app-footer a:visited {
  color: #111;
}

.app-footer a:hover {
  color: #8f2525;
  text-decoration-color: #8f2525;
}

.app-footer a:focus-visible {
  outline: 2px solid #111;
  outline-offset: 3px;
  border-radius: 4px;
}
