/* =========================================================
   Unscramble Daily Activities – Teen2Teen 2 · Unit 2
   Mobile-first. Two-column layout from 880px up.
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --bg: #f5f3ff;
  --bg-glow-1: rgba(251, 207, 232, 0.7);
  --bg-glow-2: rgba(191, 219, 254, 0.7);
  --card: #ffffff;
  --text: #1e1b4b;
  --muted: #64748b;
  --accent: #6d28d9;
  --accent-2: #8b5cf6;
  --soft: #ede9fe;
  --line: rgba(109, 40, 217, 0.14);
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --shadow: 0 10px 28px rgba(30, 27, 75, 0.08);
  --chip-shadow: 0 3px 0 rgba(109, 40, 217, 0.18);
}

html[data-theme="dark"] {
  --bg: #0f1220;
  --bg-glow-1: rgba(124, 58, 237, 0.22);
  --bg-glow-2: rgba(236, 72, 153, 0.12);
  --card: #1a1f35;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #c4b5fd;
  --accent-2: #a78bfa;
  --soft: rgba(124, 58, 237, 0.18);
  --line: rgba(167, 139, 250, 0.22);
  --ok: #4ade80;
  --ok-soft: rgba(34, 197, 94, 0.16);
  --bad: #f87171;
  --bad-soft: rgba(239, 68, 68, 0.16);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --chip-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

/* ---------- Page shell ---------- */
/* Hide site chrome on this page */
body.game-page > header,
body.game-page .site-footer,
body.game-page .arcade-nav,
body.game-page .arcade-header-bar,
body.game-page .nav-profile,
body.game-page .profile-fab,
body.game-page [data-theme-toggle],
body.game-page .theme-toggle {
  display: none !important;
}

body.game-page {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(900px 520px at 0% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, var(--bg-glow-2), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }

.ua-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top, 0px) + 14px)
    16px
    calc(env(safe-area-inset-bottom, 0px) + 20px);
}

.ua-shell {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Top bar ---------- */
.ua-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ua-back {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-decoration: none;
  font-size: 18px;
  transition: transform 0.15s ease;
}
.ua-back:hover { transform: translateX(-2px); }

.ua-top-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ua-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.ua-title {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ua-count {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ua-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}
.ua-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #a78bfa, #7c3aed, #ec4899);
  background-size: 200% 100%;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.45);
  transition: width 0.55s cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* ---------- Round layout ---------- */
.ua-round {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ua-media { position: relative; }

.ua-work {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

@media (min-width: 880px) {
  .ua-shell { max-width: 980px; gap: 22px; }
  .ua-app { padding-top: 28px; }
  .ua-round {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 28px;
    align-items: start;
  }
  .ua-media { position: sticky; top: 24px; }
  .ua-work { padding-top: 6px; }
}

/* ---------- Picture + audio ---------- */
.ua-pic {
  position: relative;
  height: clamp(200px, 38vh, 380px);
  border-radius: 22px;
  overflow: hidden;
  background: var(--soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}

.ua-pic img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 14px;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.ua-emoji {
  display: none;
  font-size: 92px;
  line-height: 1;
}
.ua-pic.no-img img { display: none; }
.ua-pic.no-img .ua-emoji { display: block; }

.ua-play {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #8b5cf6, #6d28d9);
  box-shadow: 0 8px 22px rgba(109, 40, 217, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.ua-play svg { pointer-events: none; }
.ua-play:hover { transform: scale(1.06); }
.ua-play:active { transform: scale(0.94); }

.ua-play.is-playing::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid #8b5cf6;
  animation: ua-ring 1.2s ease-out infinite;
  pointer-events: none;
}

/* ---------- Hint ---------- */
.ua-hint {
  margin: 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- Answer row ---------- */
.ua-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.ua-answer {
  min-height: 92px;
  padding: 18px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ua-slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.ua-chip,
.ua-gap,
.ua-tile {
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.ua-chip {
  border: 2px solid var(--accent-2);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--chip-shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.2s, border-color 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.ua-chip:hover { transform: translateY(-1px); }
.ua-chip:active { transform: translateY(2px); box-shadow: none; }

.ua-chip.is-pop { animation: ua-pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1); }

.ua-chip.is-ok {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
  box-shadow: none;
  cursor: default;
}

.ua-chip.is-bad {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
  animation: ua-shake 0.45s ease;
}

.ua-gap {
  min-width: 78px;
  border: 2px dashed rgba(124, 58, 237, 0.42);
  background: var(--soft);
}

/* ---------- Word bank ---------- */
.ua-bank {
  padding: 16px;
  display: flex;
  justify-content: center;
}

.ua-pool {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.ua-tile {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.ua-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(109, 40, 217, 0.16);
}
.ua-tile:active { transform: scale(0.94); }

.ua-tile.is-used {
  opacity: 0.25;
  box-shadow: none;
  border-style: dashed;
  cursor: default;
  pointer-events: none;
}

/* ---------- Feedback + buttons ---------- */
.ua-feedback {
  min-height: 26px;
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
}
.ua-feedback.ok { color: var(--ok); }
.ua-feedback.bad { color: var(--bad); }

.ua-btn {
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  min-height: 50px;
  padding: 0 28px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(145deg, #8b5cf6, #6d28d9);
  box-shadow: 0 8px 20px rgba(109, 40, 217, 0.32);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.ua-btn:hover { filter: brightness(1.06); }
.ua-btn:active { transform: scale(0.97); }

.ua-btn.ghost {
  background: var(--card);
  color: var(--accent);
  border: 2px solid var(--line);
  box-shadow: none;
}

.ua-next { width: 100%; }

.ua-fade-in { animation: ua-in 0.3s ease both; }

/* ---------- Start + done ---------- */
.ua-start,
.ua-done {
  padding: 40px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.ua-hero { font-size: 56px; line-height: 1; }

.ua-start h1,
.ua-done h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.ua-start p,
.ua-done p {
  margin: 0;
  max-width: 340px;
  color: var(--muted);
  line-height: 1.5;
}

.ua-stars {
  display: flex;
  gap: 8px;
  font-size: 34px;
  line-height: 1;
}
.ua-stars span { opacity: 0.22; }
.ua-stars span.on {
  opacity: 1;
  color: #f59e0b;
  animation: ua-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.ua-stars span.on:nth-child(2) { animation-delay: 0.12s; }
.ua-stars span.on:nth-child(3) { animation-delay: 0.24s; }

.ua-done-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- Screen transitions ---------- */
.ua-screen { animation: ua-in 0.42s cubic-bezier(0.22, 0.9, 0.3, 1) both; }

/* ---------- Focus ---------- */
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.55);
  outline-offset: 3px;
}

/* ---------- Small phones ---------- */
@media (max-width: 420px) {
  .ua-app { padding-left: 12px; padding-right: 12px; }
  .ua-shell { gap: 12px; }
  .ua-round { gap: 12px; }
  .ua-pic { height: clamp(170px, 32vh, 260px); }
  .ua-emoji { font-size: 72px; }
  .ua-title { font-size: 15px; }
  .ua-answer { padding: 14px 10px; min-height: 84px; }
  .ua-chip, .ua-gap, .ua-tile { font-size: 15px; height: 42px; padding: 0 13px; }
  .ua-gap { min-width: 64px; }
  .ua-slots, .ua-pool { gap: 8px; }
}

@media (max-width: 340px) {
  .ua-chip, .ua-gap, .ua-tile { font-size: 14px; height: 40px; padding: 0 10px; }
  .ua-count { padding: 6px 9px; font-size: 12px; }
}

/* ---------- Motion ---------- */
@keyframes ua-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes ua-pop {
  0%   { transform: scale(0.7); opacity: 0; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes ua-shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
@keyframes ua-ring {
  from { transform: scale(0.9); opacity: 0.8; }
  to   { transform: scale(1.5); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
