:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #edf1f5;
  color: #111;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 280px;
  background: #edf1f5;
}

button {
  font: inherit;
}

.verification-app {
  width: min(100%, 460px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 34px rgb(22 36 50 / 14%);
}

.brand {
  padding: 22px 18px 9px;
  font-family: "Comic Sans MS", "Arial Narrow", sans-serif;
  font-size: clamp(2.15rem, 10vw, 3rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.08em;
  transform: scaleX(0.84);
  transform-origin: left center;
}

.challenge-intro {
  padding: 28px 18px 30px;
  text-align: center;
}

.headline-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.robot-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  color: #4a90e2;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.5;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8.2vw, 2.75rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.level-label {
  margin: 10px 0 0;
  color: #777;
  font-size: clamp(1.45rem, 6.5vw, 2rem);
  line-height: 1.1;
}

.section-rule {
  height: 1px;
  background: #dadada;
}

.challenge-panel {
  padding: 8px 8px 0;
}

.challenge-prompt {
  display: flex;
  min-height: 104px;
  padding: 18px 17px 15px;
  flex-direction: column;
  justify-content: center;
  background: #4a90e2;
  color: #fff;
  line-height: 1.08;
}

.challenge-prompt span {
  font-size: clamp(1.36rem, 5.6vw, 1.8rem);
  font-weight: 400;
}

.challenge-prompt strong {
  margin-top: 4px;
  font-size: clamp(2rem, 8vw, 2.65rem);
  font-weight: 700;
}

.tile-grid {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  margin-top: 5px;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 4px;
  overflow: hidden;
  background: #fff;
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  background-color: #dbe7ef;
  background-image: url("assets/stop-sign-road.png");
  background-repeat: no-repeat;
  background-position: calc(var(--column) * 33.333333%) calc(var(--row) * 33.333333%);
  background-size: 400% 400%;
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 130ms ease, filter 130ms ease;
}

.tile:hover {
  filter: brightness(1.04);
}

.tile:focus-visible {
  z-index: 2;
  outline: 4px solid #101820;
  outline-offset: -4px;
}

.tile[aria-pressed="true"] {
  z-index: 1;
  transform: scale(0.88);
  box-shadow: 0 0 0 4px #2b7de9;
}

.tile[aria-pressed="true"]::after {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #2b7de9;
  color: #fff;
  content: "✓";
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
  place-items: center;
}

.control-bar {
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding: 12px 8px 14px;
  border-top: 1px solid #d7d7d7;
}

.refresh-button,
.verify-button {
  border: 0;
  cursor: pointer;
}

.refresh-button {
  display: grid;
  width: 58px;
  height: 58px;
  padding: 7px;
  background: transparent;
  color: #050505;
  place-items: center;
}

.refresh-button svg {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-width: 5;
}

.refresh-button:active svg {
  transform: rotate(-30deg);
}

.verify-button {
  min-width: 132px;
  min-height: 58px;
  padding: 12px 25px;
  background: #4a90e2;
  color: #fff;
  font-size: 1.55rem;
  font-weight: 400;
}

.refresh-button:focus-visible,
.verify-button:focus-visible {
  outline: 3px solid #111;
  outline-offset: 3px;
}

.verify-button:hover {
  background: #347fcc;
}

.tile-grid.is-retrying {
  animation: retry-shake 260ms ease-in-out;
}

.dialog-open {
  overflow: hidden;
}

.failure-dialog {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  padding: 24px;
  background: rgb(15 23 42 / 58%);
  place-items: center;
}

.failure-dialog[hidden] {
  display: none;
}

.failure-card {
  width: min(100%, 340px);
  padding: 30px 24px 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgb(0 0 0 / 28%);
  text-align: center;
}

.failure-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #4a90e2;
  color: #fff;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  place-items: center;
}

.failure-card h2 {
  margin: 0;
  color: #111;
  font-size: 1.85rem;
  line-height: 1.2;
}

.failure-card p {
  margin: 12px 0 24px;
  color: #606060;
  font-size: 1rem;
  line-height: 1.6;
}

.retry-button {
  width: 100%;
  min-height: 54px;
  border: 0;
  background: #4a90e2;
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 600;
}

.retry-button:hover {
  background: #347fcc;
}

.retry-button:focus-visible {
  outline: 3px solid #111;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes retry-shake {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-4px); }
  70% { transform: translateX(4px); }
}

@media (max-width: 360px) {
  .challenge-intro {
    padding-block: 22px 24px;
  }

  .headline-row {
    gap: 7px;
  }

  .robot-icon {
    width: 38px;
    height: 38px;
  }

  .challenge-prompt {
    min-height: 92px;
  }

  .tile-grid {
    gap: 3px;
  }
}

@media (min-width: 600px) {
  body {
    padding-block: 28px;
  }

  .verification-app {
    min-height: auto;
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
