:root {
  color-scheme: light;
  --ink: #23323a;
  --muted: #60727c;
  --paper: #ffffff;
  --page: #f4fbff;
  --mint: #d8f3dc;
  --aqua: #bde0fe;
  --sun: #ffd166;
  --coral: #ef6f6c;
  --leaf: #2a9d8f;
  --plum: #6d597a;
  --line: #d6e3e8;
  --shadow: 0 18px 48px rgba(35, 50, 58, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    linear-gradient(90deg, rgba(189, 224, 254, 0.34) 0 12px, transparent 12px 32px),
    var(--page);
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
  touch-action: manipulation;
}

.page-shell {
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 132px;
  padding: 16px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.photo-frame {
  width: 112px;
  height: 112px;
  border: 4px solid var(--sun);
  border-radius: 8px;
  overflow: hidden;
  background: var(--mint);
}

.photo-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.title-block {
  min-width: 0;
}

.title-block p {
  margin: 0 0 8px;
  color: var(--leaf);
  font-size: 1rem;
  font-weight: 800;
}

.title-block h1 {
  margin: 0;
  color: var(--ink);
  font-size: 2.35rem;
  line-height: 1.04;
}

.next-button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 178px;
  min-height: 58px;
  padding: 0 20px;
  border-radius: 8px;
  background: var(--coral);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 0 8px 0 #bf4f4d;
}

.next-button span:first-child {
  font-size: 1.5rem;
  line-height: 1;
}

.next-button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #bf4f4d;
}

.next-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.next-button:focus-visible {
  outline: 3px solid rgba(17, 138, 178, 0.25);
  outline-offset: 4px;
}

.face-game {
  display: grid;
  place-items: start center;
  margin-top: 18px;
}

.face-stage {
  width: min(100%, 560px);
  padding: 18px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-counts {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

.face-image {
  display: block;
  width: min(100%, 480px);
  aspect-ratio: 3 / 4;
  margin: 18px auto 16px;
  border: 3px solid #263238;
  border-radius: 8px;
  background: var(--aqua);
  object-fit: cover;
  box-shadow: 0 10px 0 #c8d8de;
  user-select: none;
  -webkit-user-drag: none;
}

.face-stage.is-loading .face-image {
  opacity: 0.28;
  transform: scale(0.99);
}

.caption {
  min-height: 64px;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: #f0f7f2;
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1.18;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .photo-frame {
    width: 94px;
    height: 94px;
  }

  .title-block h1 {
    font-size: 1.75rem;
  }

  .next-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 18px, 1040px);
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .topbar {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    min-height: 0;
  }

  .photo-frame {
    width: 82px;
    height: 82px;
  }

  .title-block p {
    margin-bottom: 5px;
    font-size: 0.86rem;
  }

  .title-block h1 {
    font-size: 1.45rem;
  }

  .face-game {
    margin-top: 12px;
  }

  .face-stage {
    padding: 12px;
  }

  .face-image {
    width: min(100%, 420px);
    margin: 12px auto;
  }

  .caption {
    min-height: 56px;
    padding: 12px;
    font-size: 1.2rem;
  }
}

@media (max-width: 380px) {
  .title-block h1 {
    font-size: 1.28rem;
  }

  .caption {
    font-size: 1.05rem;
  }
}
