:root {
  color-scheme: light;
  --ink: #2f2830;
  --muted: #7d7078;
  --line: #eadde2;
  --paper: #fffafd;
  --soft: #fff2f6;
  --rose: #e96087;
  --rose-dark: #ba315d;
  --mint: #79c7b1;
  --butter: #f7cb6a;
  --sky: #8fbde7;
  --lilac: #bca0e8;
  --shadow: 0 18px 50px rgba(112, 72, 91, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 220, 231, 0.9), transparent 24rem),
    radial-gradient(circle at 90% 8%, rgba(210, 239, 230, 0.9), transparent 22rem),
    linear-gradient(135deg, #fff8fb 0%, #fef5df 52%, #eff8ff 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  align-items: center;
}

.app-shell-wide {
  width: calc(100% - 16px);
  align-items: start;
}

.loading-card,
.login-panel,
.setup-grid,
.game-panel {
  background: rgba(255, 250, 253, 0.86);
  border: 1px solid rgba(234, 221, 226, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.loading-card,
.login-panel {
  width: min(460px, 100%);
  margin: auto;
  border-radius: 8px;
  padding: 28px;
  text-align: center;
}

.sparkle-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  letter-spacing: 0;
  background: conic-gradient(from 180deg, var(--rose), var(--butter), var(--mint), var(--sky), var(--rose));
  box-shadow: 0 10px 30px rgba(233, 96, 135, 0.28);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--rose-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.6rem, 3.5vw, 2.5rem);
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.muted {
  color: var(--muted);
}

.login-form,
.name-row,
.word-row,
.upload-row {
  display: flex;
  gap: 10px;
}

input[type="password"],
input[type="text"],
input[type="date"] {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: white;
  outline: 0;
}

input:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 4px rgba(233, 96, 135, 0.14);
}

.primary,
.secondary,
.ghost,
.choice-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary {
  color: white;
  background: var(--rose);
  box-shadow: 0 12px 24px rgba(233, 96, 135, 0.22);
}

.secondary {
  color: #2b5349;
  background: #dff6ef;
}

.ghost {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.primary:disabled,
.secondary:disabled,
.ghost:disabled,
.choice-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.primary:not(:disabled):hover,
.secondary:not(:disabled):hover,
.ghost:not(:disabled):hover,
.choice-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.error {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--rose-dark);
  font-weight: 700;
}

.setup-grid {
  width: 100%;
  border-radius: 8px;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(280px, 440px) 1fr;
  gap: 24px;
  align-items: start;
}

.canvas-wrap {
  display: grid;
  gap: 12px;
}

.avatar-canvas {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

.tool-strip,
.saved-avatars,
.topbar,
.player-list,
.time-grid,
.submission-grid,
.reveal-grid,
.game-menu {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 0 0 1px var(--line);
}

.swatch.active {
  box-shadow: 0 0 0 3px var(--ink);
}

.saved-avatar,
.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid white;
  box-shadow: 0 0 0 1px var(--line), 0 8px 18px rgba(112, 72, 91, 0.12);
  background: var(--soft);
}

.saved-avatar {
  padding: 0;
  overflow: hidden;
}

.game-panel {
  width: 100%;
  border-radius: 8px;
  padding: 22px;
}

.gposes-panel {
  min-height: calc(100vh - 64px);
  padding: 18px;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.storage-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  color: #2b5349;
  background: #dff6ef;
  font-size: 0.82rem;
  font-weight: 800;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mini-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  background: var(--rose);
}

.game-menu {
  margin: 18px 0 24px;
}

.welcome-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.welcome-tile {
  min-height: 190px;
  border-radius: 8px;
  padding: 22px;
  text-align: left;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(112, 72, 91, 0.1);
}

.welcome-tile strong {
  display: block;
  margin-bottom: 8px;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.welcome-tile:hover {
  transform: translateY(-2px);
  border-color: var(--rose);
}

.menu-tile {
  flex: 1 1 260px;
  min-height: 132px;
  border-radius: 8px;
  padding: 18px;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
}

.menu-tile.active {
  border-color: var(--rose);
  box-shadow: 0 12px 26px rgba(233, 96, 135, 0.16);
}

.menu-tile strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.player-card,
.phase-card,
.submission-card,
.reveal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.player-card {
  min-width: 210px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  margin-left: auto;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 900;
  color: #694a16;
  background: #ffe9ab;
}

.status-pill.ready {
  color: #24544a;
  background: #dff6ef;
}

.player-info {
  min-width: 0;
}

.kick-button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--rose-dark);
  background: var(--soft);
  border: 1px solid #ffd4df;
  font-size: 0.78rem;
  font-weight: 900;
}

.kick-button:hover {
  color: white;
  background: var(--rose);
}

.phase-card {
  margin-top: 18px;
  padding: 18px;
}

.word-badge {
  display: inline-flex;
  margin: 8px 0 14px;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--rose-dark);
  background: var(--soft);
  font-weight: 900;
}

.time-grid {
  margin-top: 12px;
}

.choice-button {
  width: 48px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.choice-button.active {
  color: white;
  background: var(--rose);
  border-color: var(--rose);
}

.timer {
  margin: 16px 0;
  font-size: clamp(2rem, 9vw, 5rem);
  line-height: 1;
  font-weight: 900;
}

.submission-card,
.reveal-card {
  flex: 1 1 280px;
  overflow: hidden;
}

.submission-card {
  padding: 14px;
}

.submission-card img,
.reveal-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 8px;
  background: #fff8fb;
  border: 1px solid var(--line);
}

.hidden-submission {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.hidden-submission::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 250, 253, 0.34);
}

.blurred-submission {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(22px) saturate(0.9);
  transform: scale(1.1);
}

.ready-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: white;
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  font-weight: 900;
  text-shadow: 0 3px 18px rgba(47, 40, 48, 0.44);
}

.reveal-card {
  padding: 14px;
}

.reveal-focus {
  max-width: 680px;
  margin-bottom: 14px;
}

.guess-details {
  margin: 10px 0 12px;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--soft);
}

.guess-details p {
  margin: 4px 0;
}

.history-list {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.history-head h3,
.history-head p {
  margin-bottom: 4px;
}

.album-upload {
  margin-bottom: 18px;
}

.album-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 0.7fr) minmax(220px, 1.4fr) auto;
  gap: 10px;
  align-items: center;
}

.album-grid {
  column-width: 330px;
  column-gap: 18px;
}

.album-card,
.album-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.album-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  break-inside: avoid;
  box-shadow: 0 14px 34px rgba(112, 72, 91, 0.11);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.album-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 44px rgba(112, 72, 91, 0.18);
}

.album-frame {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  background: var(--soft);
}

.album-card img {
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 220ms ease;
}

.album-card:hover img {
  transform: scale(1.08);
}

.album-caption {
  padding: 14px;
}

.album-caption time {
  display: block;
  margin-bottom: 8px;
  color: var(--rose-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.album-caption blockquote {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

.album-edit {
  margin-top: 12px;
}

.album-edit summary {
  width: fit-content;
  color: var(--rose-dark);
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.album-edit-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.album-empty {
  display: inline-block;
  width: 100%;
  min-height: 180px;
  padding: 18px;
}

.memory-lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.memory-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(47, 40, 48, 0.72);
  backdrop-filter: blur(12px);
}

.memory-dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 1500px);
  max-height: 94vh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 26px 80px rgba(47, 40, 48, 0.35);
}

.memory-dialog img {
  width: 100%;
  max-height: 82vh;
  object-fit: contain;
  background: #171316;
}

.memory-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  font-weight: 900;
}

.memory-dialog-caption {
  padding: 14px 18px;
}

.memory-dialog-caption time {
  display: block;
  margin-bottom: 6px;
  color: var(--rose-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.memory-dialog-caption blockquote {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 900;
}

.empty-art {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff8fb;
}

.chapter-panel {
  min-height: calc(100vh - 64px);
}

.chapter-tile {
  background: linear-gradient(135deg, #ffffff, #fff2f6 54%, #eff8ff);
}

.chapter-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 20px;
}

.chapter-word {
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  text-align: center;
  color: var(--muted);
  background: white;
  font-weight: 900;
}

.chapter-word.recovered {
  color: #24544a;
  background: #dff6ef;
  border-color: #bce6da;
}

.chapter-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.chapter-card {
  margin-top: 0;
}

.letter-lines {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.letter-lines p {
  margin: 0;
  border-left: 4px solid var(--line);
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff8fb;
  line-height: 1.55;
}

.checkpoint-card {
  max-width: 780px;
}

.memory-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: 12px 0 18px;
  border-radius: 8px;
  padding: 0 16px;
  color: #2b5349;
  background: #dff6ef;
  font-weight: 900;
  text-decoration: none;
}

.memory-link:hover {
  transform: translateY(-1px);
}

.checkpoint-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.password-card {
  max-width: 760px;
}

.final-progress {
  margin-bottom: 18px;
}

.chapter-night {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 64px);
  border-color: #08070a;
  background: #050507;
  animation: chapterFade 1400ms ease both;
}

.chapter-final {
  width: min(760px, 100%);
  padding: 32px 20px;
  color: #fffafd;
  text-align: center;
}

.chapter-final p {
  margin: 0 0 18px;
  font-size: clamp(1.25rem, 4vw, 2rem);
  line-height: 1.35;
  opacity: 0;
  transform: translateY(10px);
  animation: chapterLineIn 900ms ease forwards;
}

.chapter-final p:nth-child(1) {
  animation-delay: 900ms;
}

.chapter-final p:nth-child(2) {
  animation-delay: 2100ms;
}

.chapter-final p:nth-child(3) {
  animation-delay: 3300ms;
}

.chapter-final p:nth-child(4) {
  animation-delay: 4500ms;
}

.chapter-final p:nth-child(5) {
  animation-delay: 5900ms;
}

@keyframes chapterFade {
  from {
    background: rgba(255, 250, 253, 0.86);
  }
  to {
    background: #050507;
  }
}

@keyframes chapterLineIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 10px 0;
  }

  .setup-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .game-panel {
    padding: 14px;
  }

  .login-form,
  .name-row,
  .word-row,
  .upload-row,
  .album-form,
  .welcome-menu {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
  }

  .history-head {
    flex-direction: column;
  }

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