:root {
  --bg: #f5fbff;
  --ink: #071f4d;
  --paper: #fffaf0;
  --panel: #ffffff;
  --muted: #52637a;
  --blue: #2ec4ff;
  --green: #43d9ad;
  --yellow: #ffdd66;
  --coral: #ff624a;
  --pink: #f15bb5;
  --line: rgba(7, 31, 77, 0.13);
  --shadow: rgba(7, 31, 77, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 83% 12%, rgba(67, 217, 173, 0.24), transparent 27%),
    radial-gradient(circle at 10% 91%, rgba(241, 91, 181, 0.16), transparent 24%),
    linear-gradient(170deg, #dff3ff 0 24%, var(--bg) 24% 100%);
  font-family: "Trebuchet MS", "Yu Gothic", Meiryo, sans-serif;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 24px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px var(--shadow);
}

button:focus-visible,
.tile:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 4px;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 380px);
  gap: 28px;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
}

.hero-panel {
  padding: 18px 0;
}

.kicker {
  color: #2563eb;
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  max-width: 620px;
  margin: 14px 0 16px;
  font-size: clamp(3.7rem, 8vw, 7.4rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-wrap: balance;
}

.hero-panel p {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 800;
  line-height: 1.65;
  text-wrap: pretty;
}

.hook-card {
  width: min(520px, 100%);
  margin-top: 28px;
  padding: 18px 24px 22px;
  border-radius: 30px;
  background: var(--coral);
  color: #fff;
  transform: rotate(-3deg);
  box-shadow: 0 18px 0 rgba(255, 98, 74, 0.18);
}

.hook-card span {
  display: block;
  font-size: 0.8rem;
  font-weight: 900;
  opacity: 0.76;
}

.hook-card strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1;
}

.phone-frame {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 12px solid #101828;
  border-radius: 48px;
  background: var(--paper);
  box-shadow: 0 34px 65px rgba(16, 24, 40, 0.28);
}

.phone-frame::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 144px;
  height: 24px;
  border-radius: 0 0 16px 16px;
  background: #101828;
  transform: translateX(-50%);
  z-index: 2;
}

.game-topbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 24px 0 14px;
}

.target-strip {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 12px 8px 8px;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
}

.target-preview {
  aspect-ratio: 1;
  border-radius: 16px;
  background-image: var(--art);
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 2px rgba(7, 31, 77, 0.1);
}

.target-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.target-strip strong {
  display: block;
  margin-top: 2px;
  font-size: 1.55rem;
  line-height: 1;
}

.game-topbar div {
  min-height: 54px;
  padding: 9px 11px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
}

.game-topbar span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.game-topbar strong {
  display: block;
  margin-top: 5px;
  font-size: 1.25rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.board-wrap {
  position: relative;
  aspect-ratio: 1;
}

.board,
.complete-art {
  position: absolute;
  inset: 0;
  border-radius: 34px;
}

.complete-art {
  opacity: 0;
  transform: scale(0.92);
  background-image: var(--art);
  background-size: cover;
  background-position: center;
  transition: opacity 180ms ease, transform 180ms ease;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 9px;
  background: #fff;
  box-shadow: inset 0 0 0 3px rgba(7, 31, 77, 0.08);
  transition: opacity 180ms ease, transform 180ms ease;
}

.board.solved {
  opacity: 0;
  transform: scale(1.04);
}

.board.solved + .finish-banner,
.board-wrap.solved .finish-banner {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.88);
}

.board-wrap.solved .complete-art {
  opacity: 1;
  transform: scale(1);
}

.tile {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 0;
  border-radius: 22px;
  background-color: #e7edf5;
  background-image: var(--art);
  background-size: 300% 300%;
  background-position: var(--pos);
  box-shadow: inset 0 -7px 0 rgba(7, 31, 77, 0.1);
  transform: translateZ(0);
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.tile-number,
.empty-number {
  position: absolute;
  left: 8px;
  top: 7px;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: rgba(16, 24, 40, 0.82);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
}

.tile.correct .tile-number {
  background: var(--green);
  color: var(--ink);
}

.tile.can-move {
  box-shadow: inset 0 -7px 0 rgba(7, 31, 77, 0.1), 0 0 0 5px rgba(255, 221, 102, 0.9);
}

.tile.correct {
  filter: saturate(1.08) brightness(1.05);
  box-shadow: inset 0 -7px 0 rgba(7, 31, 77, 0.06), 0 0 0 5px rgba(67, 217, 173, 0.72);
}

.tile:active {
  transform: scale(0.96);
}

.empty {
  position: relative;
  border-radius: 22px;
  background-color: #e8eef6;
  background-image: linear-gradient(rgba(232, 238, 246, 0.24), rgba(232, 238, 246, 0.24)), var(--art);
  background-size: 100% 100%, 300% 300%;
  background-position: center, var(--pos);
  border: 3px solid rgba(154, 169, 189, 0.62);
}

.empty-number {
  background: rgba(154, 169, 189, 0.38);
  color: #627086;
}

.finish-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  min-width: 220px;
  padding: 18px 24px;
  border-radius: 30px;
  background: #101828;
  color: #fff;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.88);
  transition: opacity 180ms ease, transform 180ms ease;
}

.finish-banner span {
  display: block;
  color: var(--yellow);
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.finish-banner strong {
  display: block;
  margin-top: 4px;
  font-size: 3rem;
  line-height: 1;
}

.status {
  min-height: 46px;
  margin: 14px 4px;
  color: var(--muted);
  font-weight: 900;
  line-height: 1.55;
  text-align: center;
  text-wrap: pretty;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 0.72fr 0.92fr;
  gap: 8px;
}

#shuffleButton {
  background: var(--coral);
}

#hintButton {
  background: var(--yellow);
  color: var(--ink);
}

#nextButton {
  background: var(--green);
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .hero-panel {
    padding-top: 8px;
  }

  h1 {
    margin-bottom: 14px;
  }

  .hook-card {
    margin-top: 24px;
  }

  .phone-frame {
    width: min(480px, 100%);
    margin: 0 auto;
  }
}

@media (max-width: 440px) {
  .app-shell {
    padding-inline: 14px;
  }

  .phone-frame {
    padding: 16px;
    border-width: 9px;
    border-radius: 40px;
  }

  .game-topbar {
    gap: 7px;
  }

  .game-topbar div {
    min-height: 58px;
    padding: 9px;
  }

  .game-topbar strong {
    font-size: 1.24rem;
  }

  .board {
    gap: 6px;
    padding: 8px;
  }

  .target-strip {
    grid-template-columns: 62px 1fr;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}
