/* Screen layouts */
.page {
  min-height: 100dvh; width: 100%; max-width: 440px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

/* Home: student code entry first, teacher link small */
.home { align-items: center; text-align: center; }
.home .hero { width: 170px; height: 170px; margin: 26px 0 18px; }
/* The picture hero (js/home-practice.js pictureHero): its four pieces come together once. */
.hero-picture { overflow: visible; filter: drop-shadow(0 10px 18px rgba(30, 36, 51, .16)); }
.hero-piece { animation: hero-join .9s cubic-bezier(.2, .8, .2, 1) both; }
.hero-piece-0 { --from: translate(-18px, -14px) rotate(-6deg); }
.hero-piece-1 { --from: translate(18px, -16px) rotate(5deg); animation-delay: .08s; }
.hero-piece-2 { --from: translate(-16px, 18px) rotate(4deg); animation-delay: .16s; }
.hero-piece-3 { --from: translate(16px, 16px) rotate(-5deg); animation-delay: .24s; }
@keyframes hero-join { from { transform: var(--from); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hero-piece { animation: none; } }
.home h1 { font-size: 26px; font-weight: 800; line-height: 1.35; letter-spacing: -0.02em; margin-bottom: 22px; }
.code-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
/* Class code: one real input over six cells (js/code-field.js). Before the script runs the
   input is shown as a plain field, so typing always works. */
.code-field { position: relative; width: 100%; }
.code-input {
  width: 100%; height: 60px; border: 0; border-radius: 16px; background: #fff; margin: 0;
  box-shadow: inset 0 0 0 2px var(--line); color: var(--ink);
  font: inherit; font-size: 28px; font-weight: 800; text-align: center; letter-spacing: .3em;
  padding: 0 0 0 .3em; font-variant-numeric: tabular-nums;
}
.code-input:focus { outline: none; box-shadow: inset 0 0 0 2.5px var(--pri); }
.code-cells { display: none; }
.code-field.is-enhanced .code-input {
  position: absolute; inset: 0; height: 100%; z-index: 1; padding: 0; border-radius: 12px;
  background: transparent; box-shadow: none; color: transparent; caret-color: transparent;
  font-size: 16px; letter-spacing: 0; cursor: text; -webkit-tap-highlight-color: transparent;
}
.code-field.is-enhanced .code-input::selection { background: transparent; color: transparent; }
.code-field.is-enhanced .code-cells { display: flex; align-items: center; justify-content: center; gap: 6px; }
.code-cells span {
  flex: 1 1 0; min-width: 0; max-width: 52px; height: 60px; border-radius: 12px; background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--line); display: grid; place-items: center;
  font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink);
}
.code-cells span.is-filled { box-shadow: inset 0 0 0 1.5px #CBC2B2; }
.code-cells span.is-cur { box-shadow: inset 0 0 0 2.5px var(--pri); }
.code-cells span.is-cur:empty::after {
  content: ''; width: 2.5px; height: 28px; border-radius: 2px; background: var(--pri);
  animation: code-caret 1.05s steps(1) infinite;
}
.code-cells i { flex: none; width: 10px; height: 3px; border-radius: 2px; background: var(--muted); }
.code-field.is-error .code-cells span { box-shadow: inset 0 0 0 2px var(--danger); }
.code-field.is-error .code-cells { animation: code-shake .32s ease-in-out; }
@keyframes code-caret { 50% { opacity: 0; } }
@keyframes code-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) {
  .code-cells span.is-cur:empty::after, .code-field.is-error .code-cells { animation: none; }
}
.home .hint { margin-top: 12px; }
.home-foot { margin-top: 32px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.teacher-link { font-size: 15px; color: var(--sub); }
.teacher-link a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--pri); font-weight: 700; text-decoration: none; }
.policy-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; font-size: 13px; color: var(--muted); }

/* Home landing (index.html): top bar, hero (picture puzzle + code entry), three steps, then
   '혼자 맞춰 보기'. The /join code step reuses .home without .home-landing and keeps its look. */
.home-landing { max-width: 1080px; padding-top: max(12px, env(safe-area-inset-top)); }
.home-top { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.home-top .brand { font-size: 21px; }
.home-top-teacher {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; font-size: 14.5px; font-weight: 700;
  color: var(--pri); background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); text-decoration: none; white-space: nowrap;
}
.home-top-teacher:hover { box-shadow: inset 0 0 0 1.5px var(--pri); }
.home-hero {
  position: relative; width: 100%; margin-top: 12px; padding: 28px 20px 26px; border-radius: 28px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background:
    radial-gradient(120% 90% at 0% 0%, #FFE3D3 0%, rgba(255, 227, 211, 0) 60%),
    radial-gradient(110% 90% at 100% 100%, #DCE6FF 0%, rgba(220, 230, 255, 0) 60%),
    #FFF8EE;
  box-shadow: inset 0 0 0 1.5px rgba(232, 226, 215, .8);
}
.home-art { position: relative; width: 190px; height: 190px; display: grid; place-items: center; }
.home-landing .hero { width: 170px; height: 170px; margin: 0; }
.home-art .float { position: absolute; width: 34px; height: 34px; animation: home-float 6s ease-in-out infinite; }
.home-art .f1 { fill: var(--m1); left: -14px; top: 12px; transform: rotate(-18deg); }
.home-art .f2 { fill: var(--m2); right: -18px; top: -4px; width: 28px; height: 28px; animation-delay: -1.5s; }
.home-art .f3 { fill: var(--m3); right: -22px; bottom: 18px; width: 40px; height: 40px; animation-delay: -3s; }
.home-art .f4 { fill: var(--m5); left: -20px; bottom: -6px; width: 30px; height: 30px; animation-delay: -4.5s; }
.home-art .f5 { fill: var(--m4); left: 46%; top: -26px; width: 24px; height: 24px; animation-delay: -2.2s; }
@keyframes home-float { 50% { translate: 0 -8px; rotate: 8deg; } }
@media (prefers-reduced-motion: reduce) { .home-art .float { animation: none; } }
.home-main { width: 100%; max-width: 392px; display: flex; flex-direction: column; align-items: center; }
.home-eyebrow { font-size: 13.5px; font-weight: 700; color: var(--pri); background: rgba(255, 255, 255, .8); padding: 6px 12px; border-radius: 999px; margin: 8px 0 12px; }
.home-landing h1 { margin-bottom: 20px; }
.home-landing .code-cells span { background: #fff; }
.home-steps {
  list-style: none; margin: 18px 0 0; padding: 0; width: 100%;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; counter-reset: step;
}
.home-steps li {
  counter-increment: step; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 14px 8px 12px; border-radius: 18px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line);
}
.home-steps svg { width: 30px; height: 30px; }
.home-steps li:nth-child(1) svg { fill: var(--m1); }
.home-steps li:nth-child(2) svg { fill: var(--m2); }
.home-steps li:nth-child(3) svg { fill: var(--m3); }
.home-steps b { font-size: 15px; }
.home-steps b::before { content: counter(step) '. '; color: var(--muted); font-weight: 700; }
.home-steps span { font-size: 12.5px; color: var(--sub); line-height: 1.4; word-break: keep-all; }
@media (min-width: 860px) {
  .home-hero { flex-direction: row; justify-content: center; gap: 72px; padding: 52px 56px; }
  .home-art { width: 320px; height: 320px; }
  .home-landing .hero { width: 290px; height: 290px; }
  .home-art .float { width: 48px; height: 48px; }
  .home-art .f2 { width: 38px; height: 38px; }
  .home-art .f3 { width: 56px; height: 56px; }
  .home-art .f5 { width: 32px; height: 32px; }
  .home-main { align-items: flex-start; text-align: left; }
  .home-landing h1 { font-size: 34px; text-align: left; }
  .home-landing .hint { text-align: left; }
  .home-landing .code-field.is-enhanced .code-cells { justify-content: flex-start; }
  .home-steps { gap: 14px; margin-top: 22px; }
  .home-steps li { flex-direction: row; justify-content: center; gap: 10px; padding: 16px; text-align: left; }
  .home-steps li > :is(b, span) { display: block; }
  .home-steps li { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; }
  .home-steps svg { grid-row: span 2; width: 36px; height: 36px; }
  .home-steps span { font-size: 13.5px; }
}
.home-landing .practice { margin-top: 22px; }

/* Home: '혼자 맞춰 보기' (js/home-practice.js), alone on /play?demo=1. */
.practice {
  width: 100%; margin-top: 40px; padding: 22px 18px 18px; border-radius: 24px; text-align: left;
  background: #fff; box-shadow: inset 0 0 0 1.5px var(--line);
}
.practice[hidden] { display: none; }
.practice-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 16px; }
.practice h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.practice-sub { margin-top: 4px; font-size: 14.5px; color: var(--sub); }
.practice-pieces { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--board); }
.practice-pieces button {
  border: 0; border-radius: 10px; min-height: 40px; padding: 0 12px; background: none; color: var(--sub);
  font: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
}
.practice-pieces button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(30, 36, 51, 0.12); }
.practice-themes { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: -4px 0 14px; padding: 2px; }
.practice-themes::-webkit-scrollbar { display: none; }
.practice-themes button {
  flex: none; border: 0; border-radius: 999px; min-height: 40px; padding: 0 16px; font: inherit; font-size: 15px; font-weight: 700;
  background: var(--board); color: var(--sub); cursor: pointer;
}
.practice-themes button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.practice-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .practice-list { grid-template-columns: repeat(4, minmax(0, 1fr)); } .practice { padding: 26px 26px 22px; } }
.practice-card {
  display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; text-decoration: none; color: var(--ink);
  background: var(--board); box-shadow: 0 1px 0 var(--line); transition: transform .15s ease, box-shadow .15s ease;
}
.practice-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #EDE6DA; }
.practice-card span { padding: 9px 12px 11px; font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.practice-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(30, 36, 51, 0.12); }
@media (prefers-reduced-motion: reduce) { .practice-card { transition: none; } .practice-card:hover { transform: none; } }
.practice-more { margin-top: 14px; width: 100%; }

/* Home: back to the class this device joined (js/app.js showResume). */
.resume {
  margin-top: 18px; width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: 2px 12px; min-height: 56px; padding: 10px 16px; border-radius: 16px; text-align: left; text-decoration: none;
  background: var(--pri-weak); color: var(--pri);
}
.resume-label { font-size: 16px; font-weight: 800; white-space: nowrap; }
.resume-detail { font-size: 14px; font-weight: 600; color: #33449C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-arrow { font-size: 18px; font-weight: 800; }

/* ---------- Student: code, name, waiting (mockup student-phone #1~#3) ---------- */
.st { word-break: keep-all; overflow-wrap: break-word; }
.st h1:focus { outline: none; }
.st-error {
  color: #B8322D; background: #FDECEC; font-size: 15px; font-weight: 700; line-height: 1.45;
  padding: 10px 14px; border-radius: 12px; text-align: center;
}
.st-error:empty { display: none; }
.st-center { align-items: center; justify-content: center; text-align: center; gap: 14px; }
.st-loading { display: flex; align-items: center; gap: 12px; color: var(--sub); font-size: 17px; font-weight: 600; }
.st-spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--pri-weak); border-top-color: var(--pri); animation: st-spin .8s linear infinite; }
@keyframes st-spin { to { transform: rotate(360deg); } }

/* name step */
.st-topnav { display: flex; align-items: center; gap: 8px; margin-left: -12px; }
.st-back {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 12px; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--sub); font: inherit; font-size: 34px; line-height: 1; padding: 0 0 4px;
}
.st-back:hover { background: #F2EEE7; }
.st-name h1 { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin: 26px 0 8px; }
.st-name-form { flex: 1; display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.st-name-input {
  width: 100%; height: 62px; border: 0; border-radius: 16px; background: #fff; color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line); padding: 0 18px; font: inherit; font-size: 24px; font-weight: 700;
}
.st-name-input:focus { outline: none; box-shadow: inset 0 0 0 2.5px var(--pri); }
.st-note {
  display: flex; gap: 8px; align-items: flex-start; padding: 12px 14px; border-radius: 14px;
  background: var(--ok-weak); color: #17693C; font-size: 14px; line-height: 1.5; font-weight: 500;
}
.st-note svg { flex: none; margin-top: 1px; }
.st-name .spacer { min-height: 20px; }

/* waiting */
.st-wait { align-items: center; text-align: center; }
/* Waiting screen: a piece clicks into place, over and over (student/views.js howToPicture). */
.st-how { display: flex; justify-content: center; margin: 4px 0 10px; }
.st-how svg { width: 100%; max-width: 260px; height: auto; overflow: visible; }
.st-how-board { fill: var(--board); }
.st-how-a { fill: var(--m3); stroke: #fff; stroke-width: 2; }
.st-how-b { fill: var(--m5); stroke: #fff; stroke-width: 2; }
.st-how-hand { fill: rgba(30, 36, 51, .18); stroke: rgba(30, 36, 51, .45); stroke-width: 2; }
.st-how-spark path { fill: none; stroke: var(--ok); stroke-width: 3; stroke-linecap: round; }
.st-how-move { animation: st-how-move 3.6s ease-in-out infinite; }
.st-how-hand { animation: st-how-hand 3.6s ease-in-out infinite; }
.st-how-spark { opacity: 0; animation: st-how-spark 3.6s ease-out infinite; }
@keyframes st-how-move {
  0%, 12% { transform: translate(72px, 22px); }
  50% { transform: translate(6px, 3px); }
  56%, 88% { transform: translate(0, 0); }
  100% { transform: translate(72px, 22px); }
}
@keyframes st-how-hand { 0%, 54% { opacity: 1; } 60%, 92% { opacity: 0; } 100% { opacity: 1; } }
@keyframes st-how-spark { 0%, 55% { opacity: 0; } 60% { opacity: 1; } 78%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .st-how-move, .st-how-hand, .st-how-spark { animation: none; }
  .st-how-hand { opacity: 0; }
}
.st-banner {
  width: 100%; margin-bottom: 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--warn-weak); color: #8A4E06; font-size: 14px; font-weight: 600;
}
.st-banner:empty { display: none; }
/* 다시 연결하는 중 at the top of the puzzle board, under the toast (same look as the teacher band) */
.st-band {
  position: absolute; z-index: 5; left: 50%; transform: translateX(-50%);
  top: 54px; width: max-content; max-width: calc(100% - 24px); pointer-events: none;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  background: var(--warn-weak); color: #7A4300; font-size: 15px; font-weight: 700; line-height: 1.4;
  box-shadow: 0 6px 18px rgba(20, 30, 60, .16);
}
.st-band[hidden] { display: none; }
.st-band .dot { background: var(--warn); }
.st-pill { margin-top: 10px; }
.st-pill.pri .dot { background: var(--pri); }
.st-pill.ok { color: #187A43; }
.st-pill .dot { animation: st-pulse 1.8s ease-in-out infinite; }
.st-bigicon { width: 120px; height: 120px; margin: 40px 0 22px; flex: none; }
.st-bigicon .ic { display: block; width: 100%; height: 100%; }
.st-bigicon.is-waiting .ic { animation: st-bob 2.6s ease-in-out infinite; }
.st-headline h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.3; margin-bottom: 8px; }
.st-dots { display: flex; gap: 8px; margin: 26px 0 24px; }
.st-dots[hidden] { display: none; }
.st-dots i { width: 10px; height: 10px; border-radius: 50%; background: #D8D0C2; animation: st-pulse 1.4s ease-in-out infinite; }
.st-dots i:nth-child(2) { animation-delay: .2s; }
.st-dots i:nth-child(3) { animation-delay: .4s; }
.st-mates { list-style: none; width: 100%; margin: 28px 0 22px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.st-mates[hidden] { display: none; }
.st-mate {
  display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 56px; padding: 12px 14px; border-radius: 16px;
  background: #fff; box-shadow: inset 0 0 0 1px var(--line); font-size: 17px; font-weight: 700; text-align: left;
}
.st-mate .ic { width: 30px; height: 30px; flex: none; }
.st-mate-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-mate em { flex: none; margin-left: auto; padding: 2px 7px; border-radius: 99px; font-style: normal; font-size: 12px; font-weight: 700; color: var(--pri); background: var(--pri-weak); }
.st-mate em.off { color: var(--muted); background: #F2EEE7; }
.st-mate.is-me { box-shadow: inset 0 0 0 2px var(--me, var(--pri)); }
.st-mate.is-off { color: var(--muted); }
.st-mate.is-off .ic { filter: grayscale(1) opacity(.5); }
.st-tips { width: 100%; padding: 16px 18px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); text-align: left; }
.st-tips h2 { font-size: 15px; font-weight: 800; }
.st-tips ol { margin: 8px 0 0; padding-left: 20px; color: var(--sub); font-size: 15px; line-height: 1.7; }
.st-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 8px; margin-top: 16px; font-size: 14px; color: var(--muted); }
.st-link {
  min-height: 44px; padding: 0 8px; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--pri); text-decoration: underline; text-underline-offset: 3px;
}
.st-link[hidden] { display: none; }
.st-message .st-bigicon { margin: 0 0 6px; width: 104px; height: 104px; }
.st-message h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.st-message .btn { margin-top: 10px; max-width: 340px; }
@keyframes st-pulse { 50% { opacity: .35; } }
@keyframes st-bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) {
  .st-spinner, .st-pill .dot, .st-dots i, .st-bigicon.is-waiting .ic { animation: none; }
}

/* Completed puzzle (mockup student-phone #5). Wider screens get a bigger picture. */
.st-done { position: relative; align-items: center; text-align: center; max-width: 560px; overflow: hidden; }
.st-done-more { margin-top: 16px; width: 100%; max-width: 360px; }
.st-confetti { position: absolute; inset: 0; pointer-events: none; }
.st-confetti i {
  position: absolute; width: 9px; height: 15px; border-radius: 2px; transform: rotate(var(--turn, 0deg));
  animation: st-fall .9s cubic-bezier(.2, .7, .3, 1) var(--delay, 0ms) both;
}
.st-done .st-pill { margin-top: 38px; position: relative; }
.st-done .st-pill .dot { background: var(--ok); animation: none; }
.st-done h1 { position: relative; font-size: 34px; font-weight: 900; letter-spacing: -0.03em; margin: 14px 0 8px; animation: st-pop .5s cubic-bezier(.3, 1.4, .5, 1) both; }
.st-done .sub { position: relative; }
.st-done-img {
  position: relative; width: 100%; margin: 26px 0 20px; padding: 8px; border-radius: 18px; background: #fff;
  box-shadow: 0 12px 30px rgba(60, 40, 20, .14);
}
.st-done-img img { display: block; width: 100%; height: auto; border-radius: 12px; }
.st-done-img:has(+ .st-credit) { margin-bottom: 8px; }
.st-credit { position: relative; margin: 0 0 16px; font-size: 12.5px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.st-stats { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin: 0 0 18px; }
.st-stats div { background: #fff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); padding: 12px; }
.st-stats dt { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.st-stats dd { margin: 0; font-size: 21px; font-weight: 800; }
@keyframes st-fall { from { opacity: 0; translate: 0 -40px; } }
@keyframes st-pop { from { opacity: 0; scale: .8; } }
@media (prefers-reduced-motion: reduce) {
  .st-confetti i, .st-done h1 { animation: none; }
}

/* Screens not built yet */
.placeholder { align-items: center; justify-content: center; text-align: center; gap: 16px; }
.placeholder h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }

/* Text pages (privacy) */
.doc { max-width: 720px; gap: 16px; }
.doc h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 12px; }
.doc a.brand { text-decoration: none; min-height: 44px; }
.doc h2 { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; margin: 18px 0 10px; }
.doc p, .doc li { font-size: 15px; line-height: 1.7; color: var(--ink); }
.doc-lead { font-size: 16px; }
.doc-note { color: var(--sub); }
.doc-list { padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.doc h3 { font-size: 16px; font-weight: 700; margin: 14px 0 6px; }
.doc-credits li { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.doc-table { overflow-x: auto; margin: 4px 0 10px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); background: #fff; }
.doc-table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.6; }
.doc-table caption { text-align: left; padding: 10px 12px 0; font-size: 13px; color: var(--sub); }
.doc-table th, .doc-table td { padding: 10px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.doc-table thead th { border-top: 0; background: var(--bg); font-weight: 700; white-space: nowrap; }
.doc-table tbody th { font-weight: 700; white-space: nowrap; }
@media (max-width: 599px) {
  /* Phones: one row per block instead of a wide table. */
  .doc-table table, .doc-table tbody, .doc-table tr, .doc-table th, .doc-table td { display: block; }
  .doc-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .doc-table tr { border-top: 1px solid var(--line); padding: 8px 0; }
  .doc-table tr:first-child { border-top: 0; }
  .doc-table th, .doc-table td { border-top: 0; padding: 4px 12px; }
  .doc-table tbody th { white-space: normal; color: var(--pri); }
  .doc-table caption { display: block; padding-bottom: 6px; }
  .doc-table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 700; color: var(--sub); }
}

/* Student puzzle screen (mockups student-phone #4 and student-tablet).
   Portrait: board on top, my tray below. Landscape (600px+ wide, phones on their side too): tray on the right. */
html.is-play, html.is-play body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.play {
  --ok-ink: #187A43; /* --ok darkened to 4.5:1 on --bg for small text */
  position: relative; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.pz-top { flex: none; display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 8px; padding: 8px 16px 10px; }
.pz-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.pz-progress { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pz-bar { width: 90px; flex: none; }
.pz-bar i { width: 0; transition: width .3s ease-out; }
.pz-count { font-size: 15px; font-weight: 700; color: var(--ok-ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pz-chips {
  order: 5; flex: 1 0 100%; display: flex; gap: 6px; margin: 0; padding: 0; list-style: none;
  overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
}
.pz-chips::-webkit-scrollbar { display: none; }
.pz-chips[hidden] { display: none; }
.pz-chips .chip { height: 28px; font-size: 13px; flex: none; }
.pz-chips .chip .ic { width: 18px; height: 18px; }
.pz-picture-btn { margin-left: auto; color: var(--ink); flex: none; }
.pz-picture-btn .pz-btn-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.pz-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pz-board {
  position: relative; flex: 1; min-height: 0; overflow: hidden; background: #E9E2D5;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.pz-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.pz-canvas:active { cursor: grabbing; }
.pz-hint, .pz-toast, .pz-loading {
  position: absolute; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px);
  border-radius: 99px; font-size: 13px; font-weight: 600; padding: 7px 13px; text-align: center; pointer-events: none;
}
.pz-hint { bottom: 12px; background: rgba(30, 36, 51, .82); color: #fff; white-space: nowrap; transition: opacity .3s; }
.pz-hint.is-hidden { opacity: 0; }
.pz-toast { top: 12px; background: var(--ink); color: #fff; opacity: 0; transition: opacity .2s; }
.pz-toast.is-shown { opacity: 1; }
.pz-toast.ok { background: var(--ok-weak); color: #17693C; font-size: 16px; font-weight: 800; padding: 10px 18px; box-shadow: 0 6px 18px rgba(31, 157, 85, .2); }
.pz-loading { top: 45%; color: var(--sub); font-size: 15px; }

.pz-tray { flex: none; background: #fff; padding: 12px 14px max(14px, env(safe-area-inset-bottom)); min-width: 0; }
.pz-tray-h { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; margin-bottom: 6px; }
.pz-tray-title { font-size: 16px; font-weight: 800; }
.pz-tray-note { font-size: 13px; color: var(--muted); }
.pz-tiles {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  padding: 8px 2px 4px; scrollbar-width: thin; min-height: 74px; /* same height when empty: no board jump */
}
.pz-tile { flex: none; width: 62px; height: 62px; padding: 3px; border: 0; cursor: grab; touch-action: pan-x; transition: transform .15s, opacity .15s; }
.pz-tile canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
.pz-tile.is-lifted { opacity: .35; transform: scale(.92); }

.pz-ghost { position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; will-change: transform; }
.pz-ghost canvas { display: block; transition: transform .14s ease-out; filter: drop-shadow(0 10px 12px rgba(60, 40, 20, .28)); }
@media (prefers-reduced-motion: reduce) {
  .pz-bar i, .pz-tile, .pz-ghost canvas { transition: none; }
}

.pz-dialog {
  width: min(92vw, 720px); max-height: 92dvh; border: 0; border-radius: 20px; padding: 18px;
  background: #fff; color: var(--ink); box-shadow: 0 24px 60px rgba(20, 30, 60, .25);
}
.pz-dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.pz-dialog::backdrop { background: rgba(30, 36, 51, .55); }
.pz-dialog h2 { font-size: 18px; font-weight: 800; }
.pz-credit { margin: -6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.pz-credit:empty { display: none; }
.pz-dialog img { width: 100%; height: auto; max-height: 70dvh; object-fit: contain; border-radius: 12px; background: var(--board); }
.pz-dialog .btn { align-self: center; min-width: 120px; }

@media (orientation: landscape) and (min-width: 600px) {
  .pz-top { flex-wrap: nowrap; column-gap: 14px; padding: 8px 20px 10px; border-bottom: 1px solid var(--line); }
  .pz-title { font-size: 22px; }
  .pz-bar { width: 140px; }
  .pz-chips { order: 0; flex: 0 1 auto; margin-left: 8px; }
  .pz-chips .chip { height: 30px; font-size: 14px; }
  .pz-chips .chip .ic { width: 20px; height: 20px; }
  .pz-picture-btn { width: auto; padding: 0 14px; gap: 8px; display: inline-flex; align-items: center; font: inherit; font-size: 15px; font-weight: 600; }
  .pz-picture-btn .pz-btn-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .pz-body { flex-direction: row; }
  .pz-board { border: 0; }
  .pz-tray {
    width: 236px; display: flex; flex-direction: column; border-left: 1px solid var(--line);
    padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  }
  .pz-tray-h { display: block; margin-bottom: 8px; }
  .pz-tray-title { font-size: 17px; }
  .pz-tray-note { margin-top: 4px; line-height: 1.5; }
  .pz-tray-note span { display: block; }
  .pz-tray-note .pz-sep { display: none; }
  .pz-tiles {
    flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 10px;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; padding: 6px 2px;
  }
  .pz-tile { width: auto; height: auto; aspect-ratio: 1; padding: 4px; touch-action: pan-y; }
}
/* Phones on their side: slimmer header and tray so the board keeps its height. */
@media (orientation: landscape) and (min-width: 600px) and (max-height: 500px) {
  .pz-top { padding: 4px 16px 6px; column-gap: 10px; }
  .pz-title { font-size: 18px; }
  .pz-bar { width: 90px; }
  .pz-picture-btn { padding: 0 12px; }
  .pz-tray { width: 196px; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .pz-tray-title { font-size: 16px; }
  .pz-tray-note { font-size: 12px; margin-top: 2px; line-height: 1.4; }
  .pz-tiles { gap: 8px; }
}
@media (orientation: landscape) and (min-width: 1280px) {
  .pz-tray { width: 268px; }
}

/* Solo practice (/play?demo=1, js/play/demo.js): back to the home page, and a card when done. */
.pz-back { flex: none; width: 40px; height: 40px; color: var(--ink); text-decoration: none; }
.pz-done {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 5;
  width: min(340px, calc(100% - 32px)); padding: 22px 20px 18px; border-radius: 22px; text-align: center;
  background: #fff; box-shadow: 0 18px 48px rgba(30, 36, 51, 0.22); animation: pz-done-in .35s ease-out both;
}
.pz-done-title { font-size: 22px; font-weight: 800; color: #17693C; letter-spacing: -0.02em; }
.pz-done-time { margin-top: 6px; color: var(--sub); font-size: 15px; }
.pz-done-actions { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pz-done-actions .btn { font-size: 15px; padding: 10px 8px; }
@keyframes pz-done-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.pz-board:has(.pz-done) .pz-hint { display: none; }
@media (prefers-reduced-motion: reduce) { .pz-done { animation: none; } }
