/* css/app.css — the student page shell (index.html + js/main.mjs): header, join screen, and the page layout around
   the game (css/game.css). Prefix cp-. Phones: the game fills the screen under the header, Behind the scenes below.
   Desktop (≥ 900 px): a centred app column with the Behind-the-scenes panel beside it. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.cp {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--display);
  overflow-x: hidden;
}
.cp [hidden] { display: none !important; }
.cp a { color: var(--cobalt-ink); }
.cp :is(a, button, input):focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.cp-skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: 12px; background: var(--ink); color: #FFFDF8 !important; font-weight: 800; text-decoration: none; }
.cp-skip:focus { top: 10px; }

/* ───────────────────────────────────────────── header */
.cp-top {
  --top-h: 56px;
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--top-h);
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: rgba(244, 241, 234, .92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.cp-top__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cp-top__logo { flex: none; width: 28px; height: 28px; display: block; }
.cp-top__titles { display: grid; min-width: 0; line-height: 1.1; }
.cp-top__name { font: 900 16px/1.1 var(--display); letter-spacing: -.02em; }
.cp-top__class { font: 500 12.5px/1.2 var(--display); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-top__who { display: flex; align-items: center; gap: 10px; flex: none; min-width: 0; }
.cp-top__me { font: 500 13px/1.2 var(--display); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.cp-top__me strong { color: var(--ink); font-weight: 850; }

/* ───────────────────────────────────────────── buttons + inputs */
.cp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 14px;
  background: #FFFDF8; color: var(--ink);
  box-shadow: inset 0 0 0 1.5px rgba(18, 19, 24, .16), 0 2px 0 rgba(18, 19, 24, .06);
  font: 800 14.5px/1 var(--display); letter-spacing: -.01em; cursor: pointer;
  transition: transform .18s var(--ease-back), box-shadow .18s;
}
.cp-btn--small { min-height: 38px; padding: 0 13px; border-radius: 12px; font-size: 13px; }
.cp-btn--primary { min-height: 54px; width: 100%; margin-top: 6px; border-radius: 16px; background: var(--cobalt); color: #FFFDF8; box-shadow: 0 10px 22px -12px rgba(35, 64, 255, .9); font-size: 17px; }
.cp-btn:disabled { opacity: .6; cursor: progress; }
.cp-btn:not(:disabled):active { transform: scale(.98); }
@media (hover: hover) {
  .cp-btn:not(.cp-btn--primary):hover { box-shadow: inset 0 0 0 1.5px rgba(18, 19, 24, .3), 0 2px 0 rgba(18, 19, 24, .08); }
  .cp-btn--primary:not(:disabled):hover { background: var(--cobalt-ink); }
}
.cp-form { display: grid; gap: 6px; margin-top: 18px; text-align: left; }
.cp-label { margin-top: 8px; font: 800 14px/1.2 var(--display); }
.cp-input {
  width: 100%; min-height: 52px; padding: 0 16px;
  border: 1.5px solid rgba(18, 19, 24, .2); border-radius: 14px;
  background: #FFFFFF; color: var(--ink);
  font: 600 17px/1.2 var(--display);
}
.cp-input::placeholder { color: #8F8D86; font-weight: 500; }
.cp-input:focus { border-color: var(--cobalt); outline: none; box-shadow: 0 0 0 3px rgba(35, 64, 255, .18); }
.cp-input:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 1px; }
.cp-input--code { text-transform: uppercase; letter-spacing: .12em; font-family: var(--mono); font-size: 16px; }
.cp-input--code::placeholder { text-transform: none; letter-spacing: 0; font-family: var(--display); }
.cp-help { margin: 0; font: 500 12.5px/1.4 var(--display); color: var(--ink-3); }
.cp-error { margin: 4px 0 0; min-height: 1.2em; color: #A4493A; font: 700 14px/1.35 var(--display); }
.cp-error:empty { min-height: 0; margin: 0; }
.cp-demo { margin: 2px 0 0; padding: 9px 12px; border-radius: 12px; background: var(--usagi-tint); color: #6B5211; font: 600 13.5px/1.3 var(--display); }
.cp-demo strong { font-family: var(--mono); letter-spacing: .08em; }

/* ───────────────────────────────────────────── cards: join, loading, errors */
.cp-main { min-width: 0; }
.cp-card {
  width: 100%; max-width: 440px; margin: 0 auto;
  padding: 26px 22px 22px;
  border-radius: 26px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.cp-join, .cp-loading { padding: 28px 16px 40px; }
.cp-kicker { margin: 10px 0 0; font: 600 11px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.cp-h1 { margin: 6px 0 0; font: 900 30px/1.08 var(--display); letter-spacing: -.03em; }
.cp-lede { margin: 8px 0 0; font: italic 400 17px/1.4 var(--human); color: var(--ink-2); }
.cp-note { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: #E4F7EF; color: var(--mint-ink); font: 700 14px/1.35 var(--display); }
.cp-muted { color: var(--ink-2); overflow-wrap: anywhere; }
.cp-teacher { margin: 18px 0 0; font: 700 14px/1.3 var(--display); }
.cp-teacher a { display: inline-block; padding: 8px 4px; }
.cp-eggs { display: flex; justify-content: center; align-items: flex-end; gap: 10px; height: 64px; }
.cp-egg { display: block; width: 40px; height: 52px; border-radius: 50% 50% 48% 48% / 60% 60% 40% 40%; box-shadow: inset -5px -6px 0 rgba(0, 0, 0, .06), inset 0 0 0 1.5px rgba(59, 46, 46, .5); }
.cp-egg--chii { background: radial-gradient(circle at 30% 35%, #F6A9BE 0 3px, transparent 4px), radial-gradient(circle at 65% 60%, #F6A9BE 0 3px, transparent 4px), #FFF5EA; }
.cp-egg--hachi { height: 58px; background: linear-gradient(170deg, #8C9FCF 0 34%, #FDFDFF 35%); }
.cp-egg--usagi { background: linear-gradient(#FFF3C9, #FFF3C9); }
.cp-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 50svh; color: var(--ink-2); font-weight: 700; }
.cp-loading__egg { width: 44px; height: 56px; border-radius: 50% 50% 48% 48% / 60% 60% 40% 40%; background: #FFF5EA; box-shadow: inset 0 0 0 1.5px rgba(59, 46, 46, .5); animation: cp-wobble 1.4s var(--ease-swift) infinite; transform-origin: 50% 100%; }
.cp-fatal { text-align: left; }
.cp-noscript { max-width: 440px; margin: 40px auto; padding: 16px; text-align: center; }
@keyframes cp-wobble { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-8deg); } 80% { transform: rotate(7deg); } 90% { transform: rotate(-4deg); } }

/* ───────────────────────────────────────────── the game page */
.cp-play { min-width: 0; }
.cp-game, .cp-xray { min-width: 0; }
.cp .g-pv { max-width: none; }

/* phones + tablets: the game is the screen */
@media (max-width: 899px) {
  .cp .g-app { --g-screen-h: calc(100svh - 56px); --g-screen-r: 0px; gap: 0; }
  .cp .g-screen { border: 0; box-shadow: none; }
  .cp .g-pv { margin: 12px 16px 0; width: auto; justify-self: stretch; }
  .cp-xray { padding: 16px 16px max(24px, env(safe-area-inset-bottom)); }
  .cp .g-app { justify-items: stretch; }
}
/* a tablet: keep the app a readable column */
@media (min-width: 600px) and (max-width: 899px) {
  .cp-play { max-width: 560px; margin: 0 auto; padding-top: 16px; }
  .cp .g-app { --g-screen-h: calc(100svh - 92px); --g-screen-r: 26px; }
  .cp .g-screen { border: 1px solid var(--line); box-shadow: var(--shadow-1); }
  .cp .g-pv { margin: 12px 0 0; }
  .cp-xray { padding: 16px 0 32px; }
}
/* desktop: app column + Behind the scenes beside it */
@media (min-width: 900px) {
  .cp-play {
    display: grid;
    grid-template-columns: minmax(360px, 430px) minmax(380px, 560px);
    justify-content: center; align-items: start;
    gap: 28px;
    padding: 20px var(--gutter) 40px;
  }
  .cp .g-app { --g-screen-h: clamp(600px, calc(100svh - 190px), 820px); --g-screen-r: 30px; }
  .cp .g-screen { box-shadow: var(--shadow-2); }
  .cp-xray { position: sticky; top: 76px; height: calc(100svh - 96px); min-height: 560px; }
  .cp-join, .cp-loading { padding-top: 56px; }
}
@media (max-width: 480px) {
  .cp-top__me { display: none; }
}
@media (max-width: 380px) {
  .cp-h1 { font-size: 27px; }
  .cp-card { padding: 22px 16px 18px; border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .cp-loading__egg { animation: none; }
  .cp-btn { transition: none; }
}
