/* === Kill site header offset (empty top band on mobile) === */
.arcade-header-bar,
.arcade-nav,
.nav-profile,
.profile-fab,
[data-theme-toggle],
.theme-toggle,
body > header,
.site-footer {
  display: none !important;
}
html, body {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
}
body.game-page,
body[data-type="game"] {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* Picture Sentences · Unit 5A */
:root {
  --ps-bg: #f4f6fb;
  --ps-card: #ffffff;
  --ps-text: #1e1b4b;
  --ps-muted: #64748b;
  --ps-purple: #6d28d9;
  --ps-purple-soft: rgba(109, 40, 217, 0.12);
  --ps-green: #16a34a;
  --ps-red: #dc2626;
  --ps-radius: 16px;
  --ps-shadow: 0 10px 28px rgba(30, 27, 75, 0.08);
  --ps-chip: #eef2ff;
  --ps-chip-border: rgba(109, 40, 217, 0.18);
}
html[data-theme="dark"] {
  --ps-bg: #0f1220;
  --ps-card: #1a1f35;
  --ps-text: #f1f5f9;
  --ps-muted: #94a3b8;
  --ps-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --ps-chip: #252b45;
  --ps-chip-border: rgba(167, 139, 250, 0.25);
  --ps-purple-soft: rgba(167, 139, 250, 0.18);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--ps-bg) !important;
  color: var(--ps-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.ps-game {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 14px 32px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* Top bar */
.ps-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.ps-back {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--ps-card);
  color: var(--ps-text);
  text-decoration: none;
  border: 1px solid var(--ps-chip-border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  flex-shrink: 0;
  font-size: 1.15rem;
}
.ps-title {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ps-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ps-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--ps-purple-soft);
  color: var(--ps-purple);
  flex-shrink: 0;
}

/* Start / Done */
.ps-start,
.ps-done {
  text-align: center;
  padding: 24px 8px 16px;
}
.ps-hero {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 12px;
}
.ps-start h1,
.ps-done h1 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 5vw, 1.75rem);
  font-weight: 800;
  color: var(--ps-text);
}
.ps-sub {
  margin: 0 auto 18px;
  max-width: 360px;
  color: var(--ps-muted);
  font-size: 0.98rem;
  line-height: 1.45;
}
.ps-tips {
  list-style: none;
  margin: 0 auto 22px;
  padding: 0;
  max-width: 320px;
  text-align: left;
  color: var(--ps-muted);
  font-size: 0.92rem;
}
.ps-tips li {
  padding: 6px 0 6px 22px;
  position: relative;
}
.ps-tips li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--ps-green);
  font-weight: 700;
}
.ps-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 12px 0 20px;
  font-size: 1.8rem;
  color: #cbd5e1;
}
.ps-stars .on { color: #f59e0b; }
.ps-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--ps-purple);
  font-weight: 600;
  text-decoration: none;
}

/* Buttons */
.ps-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 28px;
  border-radius: 14px;
  background: var(--ps-purple);
  color: #fff;
  box-shadow: 0 6px 16px rgba(109, 40, 217, 0.28);
  min-height: 48px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ps-btn:active { transform: scale(0.97); }
.ps-btn.secondary {
  background: var(--ps-card);
  color: var(--ps-text);
  border: 1px solid var(--ps-chip-border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}
.ps-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.ps-actions .ps-btn {
  flex: 1 1 140px;
  max-width: 220px;
}

/* Play layout */
.ps-play {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Picture */
.ps-pic-wrap {
  background: var(--ps-card);
  border-radius: var(--ps-radius);
  box-shadow: var(--ps-shadow);
  overflow: hidden;
  border: 1px solid var(--ps-chip-border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  max-height: min(42vh, 320px);
}
.ps-pic {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(42vh, 320px);
  object-fit: contain;
  object-position: center;
  background: #fff;
}
html[data-theme="dark"] .ps-pic {
  background: #111827;
}

/* Sentence slots */
.ps-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: stretch;
  min-height: 52px;
  padding: 10px 4px;
  background: var(--ps-card);
  border-radius: var(--ps-radius);
  border: 1px solid var(--ps-chip-border);
  box-shadow: var(--ps-shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.ps-slots.is-correct {
  border-color: var(--ps-green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}
.ps-slots.is-wrong {
  animation: ps-shake 0.45s ease;
  border-color: var(--ps-red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}
@keyframes ps-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.ps-slot {
  appearance: none;
  border: 2px dashed var(--ps-chip-border);
  background: transparent;
  min-width: 56px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ps-text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}
.ps-slot.is-empty {
  background: var(--ps-purple-soft);
  border-style: dashed;
  color: transparent;
}
.ps-slot.is-filled {
  background: var(--ps-chip);
  border-style: solid;
  border-color: var(--ps-purple);
  color: var(--ps-text);
}
.ps-slot.is-filled:active {
  transform: scale(0.96);
}

/* Word chips pool */
.ps-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 4px 0 2px;
}
.ps-chip {
  appearance: none;
  border: 1px solid var(--ps-chip-border);
  background: var(--ps-card);
  color: var(--ps-text);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 11px 14px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  transition: transform 0.1s ease, opacity 0.15s ease, background 0.12s ease;
  touch-action: manipulation;
}
.ps-chip:active:not(:disabled) {
  transform: scale(0.95);
}
.ps-chip.is-used,
.ps-chip:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* Feedback */
.ps-fb {
  text-align: center;
  min-height: 1.4em;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--ps-muted);
}
.ps-fb.is-ok { color: var(--ps-green); }
.ps-fb.is-bad { color: var(--ps-red); }
.ps-fb.is-hint { color: var(--ps-muted); }

/* ---------- Desktop / wider screens ---------- */
@media (min-width: 640px) {
  .ps-game {
    padding: 18px 20px 40px;
  }
  .ps-pic-wrap {
    min-height: 220px;
    max-height: min(46vh, 380px);
  }
  .ps-pic {
    max-height: min(46vh, 380px);
  }
  .ps-slot {
    min-width: 64px;
    min-height: 48px;
    font-size: 1.02rem;
    padding: 10px 14px;
  }
  .ps-chip {
    font-size: 1.02rem;
    padding: 12px 18px;
    min-height: 48px;
  }
  .ps-slots {
    gap: 10px;
    padding: 14px 10px;
  }
  .ps-pool {
    gap: 10px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  .ps-game {
    padding: 10px 10px 28px;
  }
  .ps-slot {
    min-width: 48px;
    padding: 7px 9px;
    font-size: 0.88rem;
  }
  .ps-chip {
    padding: 10px 12px;
    font-size: 0.88rem;
  }
  .ps-pic-wrap {
    min-height: 140px;
    max-height: 36vh;
  }
  .ps-pic {
    max-height: 36vh;
  }
}

/* Landscape phones: keep picture smaller so chips stay reachable */
@media (max-height: 500px) and (orientation: landscape) {
  .ps-pic-wrap {
    min-height: 100px;
    max-height: 28vh;
  }
  .ps-pic {
    max-height: 28vh;
  }
  .ps-game {
    padding-bottom: 16px;
  }
  .ps-slot,
  .ps-chip {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

/* ── T2T 4-part additions ── */
.ps-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ps-stats { width: 100%; }
.ps-stat {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(109, 40, 217, 0.1);
  color: #6d28d9;
}
.ps-progress {
  height: 5px;
  background: rgba(0,0,0,0.06);
  border-radius: 3px;
  margin-bottom: 12px;
  overflow: hidden;
}
.ps-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6d28d9, #a78bfa);
  width: 0%;
  transition: width 0.35s ease;
  border-radius: 3px;
}
.ps-partlabel {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ps-muted, #6b7280);
  margin: 0 0 10px;
}
.ps-picwrap {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 14px;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  border: 1px solid var(--ps-chip-border, rgba(109, 40, 217, 0.18));
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  max-height: min(42vh, 300px);
}
html[data-theme="dark"] .ps-picwrap {
  background: #111827;
}
.ps-picwrap .ps-pic,
.ps-picwrap img.ps-pic {
  width: 100%;
  height: auto;
  max-height: min(42vh, 300px);
  display: block;
  object-fit: contain;
  object-position: center;
}
.ps-qhint {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: #6d28d9;
}
.ps-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  text-align: left;
  background: var(--ps-card, #fff);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}
.ps-steps li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 0.92rem;
}
.ps-steps li:last-child { border-bottom: none; }
.ps-steps strong {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: #6d28d9;
  color: #fff;
  font-size: 0.75rem;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}
@media (min-width: 640px) {
  .ps-picwrap {
    max-width: 400px;
    min-height: 220px;
    max-height: min(46vh, 360px);
  }
  .ps-picwrap .ps-pic,
  .ps-picwrap img.ps-pic {
    max-height: min(46vh, 360px);
  }
}
@media (min-width: 768px) {
  .ps-game { max-width: 560px; }
  .ps-picwrap { max-width: 420px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .ps-picwrap {
    min-height: 100px;
    max-height: 28vh;
  }
  .ps-picwrap .ps-pic,
  .ps-picwrap img.ps-pic {
    max-height: 28vh;
  }
}
