/* Vinschool Game — home page (night-sky hero, clay 3D cards) */
.home {
  --p-ink: #1B1F3B; --p-muted: #4A4F75; --p-muted2: #5D6285; --p-card: #FFFFFF; --p-soft: #EFEDFF;
  --p-field: #FAF9FF; --p-border: #DCD8F5; --p-edge: #C9C3F5; --p-gold: #FFC531;
  color: var(--p-ink);
  background: linear-gradient(180deg, #EDEBFF, #F6F5FF);
}
@media (prefers-color-scheme: dark) {
  .home {
    --p-ink: #EEF1FF; --p-muted: #B9BFE0; --p-muted2: #A8B0CF; --p-card: #1D2240; --p-soft: #151A34;
    --p-field: #141831; --p-border: #3A4175; --p-edge: #0C0F26;
    background: linear-gradient(180deg, #120C2B, #0D0A22);
  }
}
.home a:focus-visible, .home button:focus-visible, .home input:focus-visible { outline: 3px solid var(--p-gold); outline-offset: 2px; }

/* ---- top bar over the sky ---- */
.home .topbar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 20; background: transparent; border: 0;
  backdrop-filter: none; padding: 14px 16px 0; max-width: 1120px; margin: 0 auto;
}
.home .brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 800; font-size: 20px; }
@media (max-width: 420px) { .home .brand { font-size: 20px; } .home .brand::first-letter { font-size: inherit; } }
.tb-btns { display: flex; gap: 8px; }
.tb-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.12);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
  backdrop-filter: blur(6px);
}
.tb-btn.txt { width: auto; padding: 0 14px; }
.tb-btn:hover { background: rgba(255,255,255,.22); }
.tb-btn[aria-pressed="true"], .tb-btn.on { background: rgba(255,197,49,.28); border-color: var(--p-gold); }

/* ---- sky ---- */
.home-main { max-width: none; padding: 0; }
.top {
  position: relative; overflow: hidden; padding-bottom: 8px;
  background: linear-gradient(180deg, #0F1434 0%, #23206A 52%, #5B3FB8 76%, #EDEBFF 100%);
}
@media (prefers-color-scheme: dark) { .top { background: linear-gradient(180deg, #0A0D26 0%, #1A1853 52%, #3E2B87 78%, #120C2B 100%); } }
.top::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; animation: twinkle 3.2s ease-in-out infinite;
  background:
    radial-gradient(2px 2px at 8% 12%, #fff 50%, transparent 52%), radial-gradient(3px 3px at 22% 30%, #fff 50%, transparent 52%),
    radial-gradient(2px 2px at 37% 8%, #fff 50%, transparent 52%), radial-gradient(2px 2px at 52% 22%, #fff 50%, transparent 52%),
    radial-gradient(3px 3px at 66% 10%, #fff 50%, transparent 52%), radial-gradient(2px 2px at 78% 34%, #fff 50%, transparent 52%),
    radial-gradient(2px 2px at 90% 16%, #fff 50%, transparent 52%), radial-gradient(2px 2px at 14% 46%, #fff 50%, transparent 52%),
    radial-gradient(2px 2px at 58% 44%, #fff 50%, transparent 52%), radial-gradient(3px 3px at 94% 50%, #fff 50%, transparent 52%);
}
@keyframes twinkle { 0%,100% { opacity: .4 } 50% { opacity: 1 } }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }
.top-in { position: relative; max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; }

#hero { position: relative; height: 780px; color: #fff; text-align: center; }   /* phone: room for six islands */
/* The islands live BELOW the title so they never cover the text. */
#scene { position: absolute; inset: 228px 0 0 0; z-index: 0;
  /* soft top edge so the sun's glow never shows a hard cut */
  -webkit-mask-image: linear-gradient(transparent, #000 56px); mask-image: linear-gradient(transparent, #000 56px); }
#scene canvas { display: block; width: 100%; height: 100%; }
#scene2d { position: absolute; left: 0; right: 0; top: 242px; z-index: 0; }
#scene2d svg { display: block; width: 100%; max-width: 420px; margin: 0 auto; height: auto; overflow: visible; }
#scene2d .bob1 { animation: bob 4.2s ease-in-out infinite; }
#scene2d .bob2 { animation: bob 5s ease-in-out .6s infinite; }
#scene2d .bob3 { animation: bob 4.6s ease-in-out 1.2s infinite; }
#scene2d .bob4 { animation: bob 5.4s ease-in-out .3s infinite; }
#islandLabels { position: absolute; inset: 228px 0 0 0; z-index: 2; pointer-events: none; overflow: hidden; }
.island-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap;
  background: var(--c, #6741D9); color: #fff; font-weight: 800; font-size: 15px; line-height: 1; padding: 8px 14px 6px;
  border: 2px solid #fff; border-radius: 999px; margin-top: 8px;
  box-shadow: 0 4px 0 var(--dark, #3F2789), 0 8px 16px rgba(15,20,52,.45); will-change: transform;
}
/* small pointer up to its island, so the name clearly belongs to it */
.island-label::before {
  content: ""; position: absolute; left: 50%; top: -9px; width: 12px; height: 12px; margin-left: -6px;
  background: var(--c, #6741D9); border-left: 2px solid #fff; border-top: 2px solid #fff; transform: rotate(45deg); border-radius: 2px 0 0 0;
}
.island-label:hover { filter: brightness(1.1); }
.hero-text { position: relative; z-index: 1; padding: 74px 8px 0; pointer-events: none; }
#tagline { margin: 0; font-size: 34px; line-height: 1.05; font-weight: 800; letter-spacing: -.5px; }
#sub { margin: 8px 0 0; font-size: 16px; font-weight: 600; color: #D9D4FF; }
.hero-cta {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; min-height: 48px; padding: 0 24px;
  border-radius: 999px; background: var(--p-gold); color: #1B1F3B; font-weight: 800; font-size: 18px; text-decoration: none;
  box-shadow: 0 5px 0 #C99A06, 0 12px 22px rgba(15,20,52,.4); transition: transform .08s, box-shadow .08s;
}
.hero-cta:hover { filter: brightness(1.05); }
.hero-cta:active { transform: translateY(3px); box-shadow: 0 2px 0 #C99A06; }

/* ---- how to play ---- */
#howto { max-width: 1120px; margin: 0 auto; padding: 28px 16px 0; }
#howTitle, #subjectsTitle { margin: 0 0 14px 4px; font-size: 24px; font-weight: 800; color: var(--p-ink); }
#steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 10px; counter-reset: st; }
#steps li {
  counter-increment: st; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px;
  background: var(--p-card); box-shadow: 0 4px 0 var(--p-edge);
}
.st-ico { position: relative; flex: none; width: 48px; height: 48px; border-radius: 16px; background: var(--p-soft); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.st-ico::after {
  content: counter(st); position: absolute; top: -6px; left: -6px; width: 22px; height: 22px; border-radius: 50%;
  background: #E8590C; color: #fff; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
#steps b { display: block; font-size: 17px; font-weight: 800; line-height: 1.2; }
#steps small { display: block; font-size: 14px; font-weight: 600; color: var(--p-muted2); line-height: 1.35; }

/* ---- auth heading ---- */
.auth-head { margin: 0 0 14px; }
#authTitle { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.2; color: var(--p-ink); }
#authSub { margin: 2px 0 0; font-size: 14px; font-weight: 600; color: var(--p-muted2); }
#auth.offline .auth-head { display: none; }

/* ---- auth card ---- */
.auth-card {
  position: relative; z-index: 3; margin: -24px 0 0; background: var(--p-card); border-radius: 28px; padding: 20px;
  box-shadow: 0 10px 0 var(--p-edge), 0 28px 48px rgba(15,20,52,.35);
}
#authTabs { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; padding: 6px; background: var(--p-soft); border-radius: 18px; }
#authTabs button {
  height: 44px; border-radius: 13px; background: transparent; color: var(--p-muted2); font-weight: 700; font-size: 16px;
  transition: transform .08s, box-shadow .08s;
}
#authTabs button.on { background: var(--p-card); color: var(--p-ink); font-weight: 800; box-shadow: 0 4px 0 var(--p-edge); }
#authForm { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
#authForm label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 700; color: var(--p-muted); min-width: 0; }
.row2 { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr); gap: 10px; }
.row2[hidden], .signup-only[hidden] { display: none !important; }
#authForm input {
  width: 100%; min-width: 0; height: 48px; border-radius: 14px; border: 2px solid var(--p-border); background: var(--p-field);
  padding: 0 14px; font: inherit; font-size: 16px; font-weight: 600; color: var(--p-ink);
}
#authForm input::placeholder { color: var(--p-muted2); opacity: .6; }
#authForm input:focus { outline: 3px solid var(--p-gold); outline-offset: 1px; border-color: var(--p-gold); }
.pw { position: relative; display: block; }
.pw input { padding-right: 52px !important; }
#pwToggle { position: absolute; right: 2px; top: 2px; width: 44px; height: 44px; border-radius: 12px; color: var(--p-muted); display: flex; align-items: center; justify-content: center; }
#pwToggle .eye-off, #pwToggle[aria-pressed="true"] .eye-on { display: none; }
#pwToggle[aria-pressed="true"] .eye-off { display: block; }
#authError { margin: 0; min-height: 0; font-size: 14px; font-weight: 700; color: #C92A2A; }
#authError:empty { display: none; }
@media (prefers-color-scheme: dark) { #authError { color: #FF8787; } }
.cta {
  margin-top: 6px; min-height: 56px; border-radius: 18px; background: #E8590C; color: #fff; font-weight: 800; font-size: 19px;
  box-shadow: 0 6px 0 #9A3412, 0 12px 20px rgba(194,65,12,.35); transition: transform .08s, box-shadow .08s;
}
.cta:active { transform: translateY(4px); box-shadow: 0 2px 0 #9A3412; }
.cta:disabled { opacity: .6; cursor: default; }
.guest {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 16px; border-radius: 16px;
  border: 2px solid var(--p-border); color: var(--p-muted); background: transparent; text-decoration: none; font-weight: 800; font-size: 16px;
  text-align: center;
}
.guest:hover { border-color: var(--p-gold); }
.guest:active { transform: translateY(2px); }
#authForms > .guest { margin-top: 12px; }
#authForms > #authNote { margin-top: 12px; }
#authNote { margin: 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--p-muted2); }

/* signed-in */
#authSigned { display: flex; flex-direction: column; gap: 14px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 56px; height: 56px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: #6741D9; color: #fff; box-shadow: 0 4px 0 #3F2789, inset 0 -4px 0 rgba(0,0,0,.15);
}
.who-text { display: flex; flex-direction: column; min-width: 0; }
#helloName { font-size: 22px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
#helloMeta { font-size: 14px; font-weight: 600; color: var(--p-muted2); }
.total {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 18px;
  background: var(--p-soft); font-size: 24px; font-weight: 800;
}
.total::after { content: none; }

/* ---- subjects ---- */
#subjects { max-width: 1120px; margin: 0 auto; padding: 28px 16px 0; scroll-margin-top: 12px; }
#subjectList { display: flex; flex-direction: column; gap: 22px; padding-bottom: 8px; }
.s-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.g-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 12px 4px; }
.g-head span { display: inline-block; padding: 3px 12px; border-radius: 999px; background: #6741D9; color: #fff; font-size: 15px; font-weight: 800; }
.g-head small { font-size: 14px; font-weight: 600; color: var(--p-muted2); }
.s-card {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 24px; background: var(--p-card); color: var(--p-ink);
  text-decoration: none; min-height: 92px; position: relative;
  box-shadow: 0 7px 0 var(--edge, #C9C3F5), 0 16px 26px rgba(27,31,59,.14);
  transform: perspective(800px) rotateX(var(--rx, 4deg)) rotateY(var(--ry, 0deg)); transition: transform .15s ease-out, box-shadow .08s;
}
.s-card:active { transform: perspective(800px) rotateX(var(--rx, 4deg)) rotateY(var(--ry, 0deg)) translateY(5px); box-shadow: 0 2px 0 var(--edge, #C9C3F5), 0 6px 12px rgba(27,31,59,.14); }
.s-card.tilting { transition: transform .05s linear; }
@media (prefers-color-scheme: dark) { .s-card { box-shadow: 0 7px 0 var(--dark, #000), 0 16px 26px rgba(0,0,0,.4); } .s-card:active { box-shadow: 0 2px 0 var(--dark, #000); } }
.s-tile {
  flex: 0 0 64px; width: 64px; height: 64px; border-radius: 20px; background: var(--c, #6741D9); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -5px 0 rgba(0,0,0,.18);
}
.s-tile svg { width: 32px; height: 32px; fill: none; stroke: #fff; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.s-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.s-name { font-size: 19px; font-weight: 800; line-height: 1.15; }
.s-blurb { font-size: 13px; font-weight: 600; color: var(--p-muted2); line-height: 1.3; }
.s-bar { display: block; height: 8px; border-radius: 4px; background: var(--p-soft); margin-top: 6px; overflow: hidden; }
.s-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--c, #6741D9); transition: width .6s; }
.s-stars { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; font-weight: 800; min-width: 44px; }
.s-stars svg { width: 22px; height: 22px; fill: #FFC531; stroke: #E8A400; stroke-width: 1.5; stroke-linejoin: round; }
.s-stars b { font-size: 16px; line-height: 1.2; }
.s-stars small { font-size: 12px; color: var(--p-muted2); font-weight: 600; }

.portal-links { display: flex; justify-content: center; padding: 26px 16px 0; }
.teacher-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 240px; min-height: 48px; padding: 0 20px;
  border-radius: 16px; background: var(--p-card); border: 2px solid var(--p-border); color: var(--p-muted); text-decoration: none; font-weight: 800;
}
.teacher-link:hover { border-color: var(--p-gold); }
.home footer { text-align: center; padding: 22px 24px 28px; font-size: 12px; font-weight: 600; color: var(--p-muted2); line-height: 1.5; display: flex; flex-direction: column; gap: 2px; }
.home footer .credit { font-weight: 700; }

/* ---- desktop ---- */
@media (min-width: 960px) {
  .top { padding-bottom: 56px; }
  .top-in { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 40px; align-items: center; }
  #hero { height: 780px; text-align: left; }
  .hero-text { padding-top: 120px; max-width: 460px; }
  #tagline { font-size: 52px; }
  #sub { font-size: 18px; }
  #scene2d { top: 400px; left: 0; right: 0; }
  #scene, #islandLabels { inset: 350px 0 0 0; }
  #scene2d svg { max-width: 430px; margin: 0; }
  .auth-card { margin: 70px 0 0; align-self: start; }
  #howto { padding-top: 40px; }
  #steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  #subjects { padding-top: 40px; }
  .s-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px; }
  .s-card:hover { box-shadow: 0 9px 0 var(--edge, #C9C3F5), 0 20px 30px rgba(27,31,59,.18); }
}
@media (hover: none) { .s-card { --rx: 4deg !important; --ry: 0deg !important; } }
.s-card.picked { animation: picked .7s ease-out; box-shadow: 0 7px 0 var(--edge, #C9C3F5), 0 0 0 4px var(--p-gold), 0 0 28px 6px rgba(255,197,49,.65); }
@keyframes picked { 0% { scale: 1 } 30% { scale: 1.04 } 100% { scale: 1 } }

@media (prefers-reduced-motion: reduce) {
  .top::before, #scene2d [class^="bob"] { animation: none !important; }
  .s-card, .cta, .s-bar > span { transition: none; }
  .s-card { transform: none !important; }
  .s-card.picked { animation: none; }
  .s-card:active { transform: translateY(4px) !important; }
}
@media (max-width: 380px) {
  #tagline { font-size: 30px; }
  .s-name { font-size: 17px; }
  .s-tile { flex-basis: 56px; width: 56px; height: 56px; }
}

/* offline: only guest button + note visible */
#auth.offline #authForms { display: flex; flex-direction: column; }
#auth.offline #authForms > .guest { margin-top: 0; }
#auth.offline #authNote { margin-top: 12px; }
#auth.offline { padding: 18px 20px; }
#authNote:empty { display: none; }
/* toast */
.toast { position: fixed; top: auto; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; max-width: min(92vw, 420px);
  background: #1B1F3B; color: #fff; padding: 12px 18px; border-radius: 16px; font-weight: 700; text-align: center;
  box-shadow: 0 4px 0 #0F1434, 0 14px 28px rgba(15,20,52,.4); }
@media (max-width: 380px) {
  .home .brand { font-size: 17px; min-width: 0; gap: 6px; }
  .home .brand svg { width: 26px; height: 26px; }
  .tb-btns { gap: 6px; }
  .tb-btn.txt { padding: 0 10px; }
}
