* {
  box-sizing: border-box;
}

:root {
  --bg: #0f1220;
  --panel: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.14);
  --ink: #f4f7fb;
  --muted: #94a0b8;
  --rose: #ff5d8f;
  --sky: #55d6ff;
  --mint: #81f2bc;
  --gold: #ffd469;
  --violet: #b48cff;
}

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

body {
  color: var(--ink);
  font-family: "Trebuchet MS", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 93, 143, 0.24), transparent 28rem),
    radial-gradient(circle at 80% 10%, rgba(85, 214, 255, 0.2), transparent 24rem),
    linear-gradient(160deg, #111524 0%, #1c2236 48%, #090b12 100%);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(9, 11, 18, 0.86) 0%, rgba(9, 11, 18, 0.6) 42%, rgba(9, 11, 18, 0.84) 100%),
    url("./assets/bg-girl.png") right -3rem bottom / min(46vw, 420px) auto no-repeat;
  opacity: 0.78;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 72% 24%, rgba(255, 212, 105, 0.16), transparent 18rem),
    radial-gradient(circle at 76% 58%, rgba(255, 93, 143, 0.14), transparent 22rem);
  pointer-events: none;
  z-index: 0;
}

.app {
  width: min(760px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 14px clamp(12px, 4vw, 28px) 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--gold);
}

h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 48px);
  line-height: 0.95;
}

.subtitle {
  margin: 10px 0 0;
  max-width: 28rem;
  color: #d7deea;
  font-size: 14px;
}

.hub-link,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.hub-link {
  width: 56px;
  display: grid;
  place-items: center;
  text-decoration: none;
}

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

.stats div,
.message,
.legend,
.support-strip a,
.result {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.stats div {
  padding: 9px 8px;
  text-align: center;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.stats strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(20px, 6vw, 30px);
  line-height: 1;
}

.board-shell {
  flex: 1;
  display: grid;
  align-content: center;
  gap: 8px;
}

.message,
.legend {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #dfe6f4;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.board-wrap {
  display: grid;
  place-items: center;
}

.board {
  --cell: min(13vw, 58px, calc((100svh - 420px) / 1.1));
  position: relative;
  touch-action: none;
  width: calc(var(--cell) * 6);
  height: calc(var(--cell) * 6);
  min-width: 270px;
  min-height: 270px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.14)),
    rgba(5, 8, 16, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 22px 48px rgba(0, 0, 0, 0.3);
}

.cell,
.exit {
  border-radius: 14px;
}

.cell {
  background: rgba(255, 255, 255, 0.06);
}

.exit {
  position: absolute;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  color: #081018;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
}

.piece {
  position: absolute;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 16px;
  color: #0e1220;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.12), 0 12px 22px rgba(0, 0, 0, 0.24);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 180ms ease;
}

.piece small {
  display: block;
  font-size: 10px;
  opacity: 0.8;
}

.piece.selected {
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.12), 0 0 0 3px rgba(255, 255, 255, 0.9), 0 14px 28px rgba(0, 0, 0, 0.32);
  transform: translateY(-1px);
}

.piece.hint {
  animation: pulse 640ms ease-in-out 2;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 8px;
}

.middle-controls {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 8px;
}

.ghost,
.actions button,
.support-strip a {
  background: rgba(255, 255, 255, 0.08);
}

.primary {
  background: linear-gradient(135deg, var(--rose), #ff9a4d);
  border-color: rgba(255, 255, 255, 0.34);
  box-shadow: 0 14px 30px rgba(255, 93, 143, 0.24);
}

.actions,
.support-strip {
  display: grid;
  gap: 8px;
}

.actions {
  grid-template-columns: repeat(3, 1fr);
}

.support-strip {
  grid-template-columns: 1.25fr 1fr;
}

.support-strip a {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  text-align: center;
}

.support-strip a:first-child {
  border-color: rgba(255, 212, 105, 0.55);
  background: linear-gradient(135deg, rgba(255, 212, 105, 0.22), rgba(255, 93, 143, 0.18));
}

.result {
  position: fixed;
  inset: auto 14px 14px;
  max-width: 480px;
  margin: 0 auto;
  padding: 18px;
  background: rgba(10, 14, 24, 0.95);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.result-label {
  margin: 0;
  color: var(--mint);
  font-size: 12px;
  font-weight: 900;
}

.result strong {
  display: block;
  margin: 6px 0;
  font-size: 52px;
  line-height: 1;
}

@keyframes pulse {
  50% {
    transform: scale(1.04);
  }
}

@media (max-width: 480px) {
  body::before {
    background:
      linear-gradient(180deg, rgba(9, 11, 18, 0.8) 0%, rgba(9, 11, 18, 0.58) 38%, rgba(9, 11, 18, 0.86) 100%),
      url("./assets/bg-girl.png") center bottom / min(84vw, 360px) auto no-repeat;
    opacity: 0.62;
  }

  .board {
    --cell: min(14vw, calc((100svh - 390px) / 1.08));
    min-width: 248px;
    min-height: 248px;
  }

  .actions,
  .support-strip {
    grid-template-columns: 1fr;
  }

  .message,
  .legend {
    font-size: 12px;
  }
}
