:root {
  --ink: #111111;
  --muted: #6f7278;
  --paper: #ffffff;
  --soft: #f6f7f8;
  --line: #d7d9dc;
  --green: #538d4e;
  --yellow: #c9b458;
  --red: #b23b3b;
  --radius: 6px;
  --zoom: 6.4;
  --focus-x: 50%;
  --focus-y: 50%;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app {
  width: min(520px, calc(100vw - 24px));
  margin: 0 auto;
  padding-bottom: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

.brand-lockup {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 1.12rem;
  font-weight: 950;
  line-height: 1;
}

.brand-lockup img {
  display: block;
  width: 28px;
  height: 28px;
}

.brand-lockup span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h1 {
  justify-self: center;
  font-size: 1.72rem;
  font-weight: 950;
  line-height: 1.05;
  text-align: center;
}

.ghost-button {
  justify-self: end;
  min-width: 58px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 850;
}

.game-card {
  padding-top: 16px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-row div,
.result-grid div {
  display: grid;
  gap: 3px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 9px 10px;
}

.stat-row span,
.result-grid span,
.result-kicker {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-row strong,
.result-grid strong {
  overflow: hidden;
  font-size: 1.12rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picture-stage {
  position: relative;
  aspect-ratio: 1 / 1;
  width: min(100%, max(320px, calc(100vh - 250px)));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1b1d20;
}

.puzzle-image {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  filter: none;
  object-fit: cover;
  transform: scale(var(--zoom));
  transform-origin: var(--focus-x) var(--focus-y);
  transition: filter 220ms ease, opacity 220ms ease;
  user-select: none;
}

.picture-stage.is-ready .puzzle-image {
  opacity: 1;
  filter: blur(20px) saturate(0.9);
}

.picture-stage.is-active .puzzle-image,
.picture-stage.is-solved .puzzle-image {
  opacity: 1;
  filter: none;
}

.stage-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(27, 29, 32, 0.38);
  backdrop-filter: blur(2px);
  color: #ffffff;
  text-align: center;
}

.stage-cover[hidden] {
  display: none;
}

.stage-cover span {
  min-height: 22px;
  font-weight: 900;
}

#startButton,
.share-button {
  min-height: 48px;
  border-radius: var(--radius);
  background: var(--green);
  color: #ffffff;
  font-weight: 950;
}

#startButton {
  width: 132px;
}

#startButton:not(:disabled):hover,
.share-button:hover {
  background: #477a43;
}

.guess-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 8px;
  margin-top: 12px;
}

.guess-form input {
  min-width: 0;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0 12px;
  font-weight: 750;
}

.guess-form input:focus {
  border-color: var(--ink);
  outline: 0;
}

#guessButton {
  min-height: 48px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #ffffff;
  font-weight: 950;
}

.feedback {
  min-height: 24px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
}

.feedback.is-good {
  color: var(--green);
}

.feedback.is-bad {
  color: var(--red);
}

.content-section {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.intro-section {
  display: grid;
  gap: 8px;
  text-align: center;
}

.intro-section p,
.how-grid p {
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.45;
}

.how-section {
  display: grid;
  gap: 12px;
}

.how-section h2 {
  font-size: 1.18rem;
  line-height: 1.1;
}

.how-grid {
  display: grid;
  gap: 8px;
}

.how-grid p {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 12px;
}

.how-grid strong {
  color: var(--ink);
}

.footer {
  width: min(520px, calc(100vw - 24px));
  margin: 0 auto;
  border-top: 1px solid var(--line);
  padding: 16px 0 22px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  text-align: center;
}

.result-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.result-backdrop[hidden] {
  display: none;
}

.result-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 24px;
  box-shadow: 0 18px 60px rgba(17, 17, 17, 0.2);
}

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
}

.close-button:hover {
  background: var(--soft);
  color: var(--ink);
}

.result-kicker {
  color: var(--green);
}

.result-card h2 {
  font-size: 1.9rem;
  line-height: 1;
}

.result-answer {
  font-size: 1.08rem;
  font-weight: 850;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.share-button {
  width: 100%;
}

.source-link {
  justify-self: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

.source-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.shake {
  animation: shake 180ms linear 2;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

@media (max-width: 430px) {
  .app {
    width: min(100% - 16px, 520px);
  }

  .topbar {
    grid-template-columns: 58px 1fr 58px;
  }

  .brand-lockup span {
    display: none;
  }

  h1 {
    font-size: 1.48rem;
  }

  .guess-form {
    grid-template-columns: 1fr;
  }

  .picture-stage {
    width: 100%;
  }

  .result-card {
    padding: 22px 18px;
  }
}
