:root { --cream: #fff8ec; --cream2: #fbe9cf; --plum: #5a2370; --plum2: #3a1550; --orange: #f08a24; --orange2: #c25e0c; --gold: #ffc94a;
  --green: #5bb33a; --green2: #367a1e; --ink: #43203f; --soft: #85607c; --ok: #2f9a55; --bad: #d2453f;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: #5a2370 url(img/bg.jpg) center bottom / cover no-repeat; font-family: var(--font); color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#top { position: fixed; top: max(8px, env(safe-area-inset-top)); right: 8px; z-index: 30; display: flex; gap: 6px; }
#topL { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 8px; z-index: 30; }
.ib { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--cream); background: var(--plum); color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0; box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.ib svg { width: 22px; height: 22px; }
.ib.off { opacity: .55; background: #5a4a58; }
.ib:active { transform: translateY(2px); }
.scr { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 58px 10px 12px; overflow: auto; }
.card { position: relative; width: min(760px, 100%); margin: auto; background: var(--cream); border-radius: 22px; padding: 16px; text-align: center;
  box-shadow: 0 0 0 5px var(--orange), 0 0 0 9px var(--gold), 0 18px 50px rgba(30,0,40,.55); animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.card::before { content: ""; position: absolute; inset: 7px; border: 2px dashed rgba(91,179,58,.45); border-radius: 16px; pointer-events: none; }
@keyframes pop { from { transform: scale(.85) translateY(10px); opacity: 0 } }
.hero { display: flex; align-items: center; justify-content: center; gap: 12px; text-align: left; }
.mascot { width: 118px; height: auto; animation: bob 2s ease-in-out infinite; flex: none; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg) } }
h1 { font: 900 42px/1 var(--font); color: var(--plum); margin: 0; text-shadow: 0 2px 0 #ffd9a0; }
h1 small { display: block; font: 800 19px/1.2 var(--font); color: var(--orange2); margin-top: 6px; }
h2 { font: 900 30px/1.1 var(--font); color: var(--plum); margin: 2px 0 8px; }
h3 { margin: 12px 0 6px; font-size: 15px; color: var(--soft); text-transform: uppercase; letter-spacing: 1px; }
.intro { font-size: 14px; font-weight: 700; color: var(--soft); margin: 6px 0 4px; line-height: 1.4; }
.note { font-size: 12px; color: var(--soft); margin: 12px 0 0; }
.keys { font-size: 13px; color: var(--soft); margin: 8px 0 0; font-weight: 700; }
.k { display: inline-block; min-width: 22px; padding: 1px 6px; margin: 0 1px; border-radius: 6px; background: #fff; border: 2px solid #d9bfa6; border-bottom-width: 4px; font-weight: 900; color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 16px; padding: 10px 18px; min-height: 48px; cursor: pointer; color: #fff;
  font: 900 18px/1.1 var(--font); background: linear-gradient(#7cc94f, #449b25); box-shadow: 0 5px 0 var(--green2); text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--green2); }
.btn.big { font-size: 22px; padding: 14px 28px; margin-top: 10px; min-width: 260px; }
.btn.alt { background: linear-gradient(#a06bb8, #6d3488); box-shadow: 0 5px 0 var(--plum2); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode, .lvl { border: 3px solid #f0d3ad; background: #fff; border-radius: 16px; padding: 10px 8px; cursor: pointer; font-family: var(--font); color: var(--ink); display: flex; flex-direction: column; gap: 3px; align-items: center; box-shadow: 0 4px 0 #e6c59d; }
.mode b, .lvl b { font-size: 16px; }
.mode span, .lvl span { font-size: 12px; color: var(--soft); font-weight: 700; }
.mode:active, .lvl:active { transform: translateY(3px); box-shadow: 0 1px 0 #e6c59d; }
.lvl .st { color: #e0a21a; font-size: 18px; letter-spacing: 2px; }
.lvl.m { border-color: #9fd77f; } .lvl.s { border-color: #ffc06a; } .lvl.h { border-color: #e48d8d; }
/* team setup */
.row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.lbl { font-weight: 900; min-width: 110px; text-align: right; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.seg button { border: 3px solid #e6c59d; background: #fff; border-radius: 12px; padding: 8px 12px; font: 800 15px var(--font); color: var(--ink); cursor: pointer; min-height: 42px; }
.seg button.on { background: var(--plum); border-color: var(--plum); color: #fff; }
.teamNames { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0; }
.teamNames span { padding: 6px 12px; border-radius: 99px; color: #fff; font-weight: 900; }
/* quiz */
.quiz { width: min(820px, 100%); margin: auto; display: flex; flex-direction: column; gap: 8px; }
.hud { display: flex; gap: 6px; justify-content: center; }
.pill { background: rgba(58,21,80,.85); color: #fff; padding: 6px 14px; border-radius: 99px; font-weight: 900; font-size: 16px; border: 2px solid rgba(255,255,255,.35); }
.pill.gold { background: linear-gradient(#ffd666, #f0a323); color: #5a2a00; }
.teams { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.teams span { padding: 4px 10px; border-radius: 99px; color: #fff; font-weight: 900; font-size: 14px; opacity: .6; border: 3px solid transparent; }
.teams span.cur { opacity: 1; border-color: #fff; transform: scale(1.08); box-shadow: 0 0 12px rgba(255,220,120,.9); }
.timer { height: 10px; background: rgba(255,255,255,.25); border-radius: 9px; overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffd34d, #ff8a2a); border-radius: 9px; transition: width .2s linear; }
.timer i.low { background: #ff5a4a; }
.qwrap { display: flex; align-items: flex-end; gap: 6px; }
.qm { width: 92px; flex: none; transition: transform .2s; }
.qm.jump { animation: jump .5s; } .qm.shake { animation: shake .45s; }
@keyframes jump { 40% { transform: translateY(-18px) scale(1.06) } }
@keyframes shake { 20%,60% { transform: translateX(-6px) } 40%,80% { transform: translateX(6px) } }
.qcard { flex: 1; background: var(--cream); border-radius: 18px; padding: 14px 16px; box-shadow: 0 0 0 4px var(--orange), 0 10px 24px rgba(0,0,0,.35); position: relative; min-height: 92px; display: flex; flex-direction: column; justify-content: center; }
.qcard::before { content: ""; position: absolute; left: -12px; bottom: 22px; border: 10px solid transparent; border-right-color: var(--orange); }
.qcard p { margin: 0; font-size: 21px; font-weight: 800; line-height: 1.3; }
.turn { font-weight: 900; color: #fff; display: inline-block; align-self: flex-start; padding: 2px 10px; border-radius: 99px; margin-bottom: 6px; font-size: 14px; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ans { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; border-radius: 16px; padding: 10px 12px; min-height: 58px; cursor: pointer; background: #fff; color: var(--ink);
  font: 800 17px/1.25 var(--font); box-shadow: 0 5px 0 #d8b893; transition: transform .1s; }
.ans .n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900; }
.ans:nth-child(1) .n { background: #e8722c; } .ans:nth-child(2) .n { background: #4f9e2e; } .ans:nth-child(3) .n { background: #8a46ad; } .ans:nth-child(4) .n { background: #d9a51c; }
.ans:hover { transform: translateY(-2px); }
.ans.ok { background: #d9f7d0; box-shadow: 0 5px 0 var(--ok), 0 0 0 3px var(--ok); animation: jump .4s; }
.ans.no { background: #fde0dc; box-shadow: 0 5px 0 var(--bad), 0 0 0 3px var(--bad); animation: shake .4s; }
.ans.dim { background: #efe6ea; color: #9a8494; box-shadow: 0 5px 0 #cdbcc4; }
.ans:disabled { cursor: default; }
.fb { background: var(--cream); border-radius: 16px; padding: 10px 14px; box-shadow: 0 0 0 4px var(--gold); text-align: center; animation: pop .3s; }
.fb b { font-size: 20px; } .fb b.good { color: var(--ok); } .fb b.bad { color: var(--bad); }
.fb p { margin: 4px 0 8px; font-weight: 700; color: var(--soft); }
.hint { text-align: center; color: #fff; font-weight: 800; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); margin: 2px 0 0; }
/* result */
.stars { font-size: 46px; color: #e5d3bb; letter-spacing: 4px; }
.stars .on { color: #ffbf1f; text-shadow: 0 2px 0 #c77f00; display: inline-block; animation: jump .5s backwards; }
.big2 { font-size: 30px; font-weight: 900; margin: 4px 0; color: var(--plum); }
.btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.btns .btn.big { min-width: 200px; }
.rank { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; margin: 4px auto; max-width: 380px; border-radius: 12px; color: #fff; font-weight: 900; font-size: 18px; }
/* mini game */
.scr.game { padding: 0; display: block; }
#cv { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 1; pointer-events: none; display: block; }
.scr.game { touch-action: none; }
.ghud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 60px; right: 110px; display: flex; gap: 6px; justify-content: center; }
.ghint { position: absolute; left: 0; right: 0; top: calc(max(10px, env(safe-area-inset-top)) + 50px); padding: 0 12px; }
.ghud .pill { white-space: nowrap; }
@media (max-width: 600px) {
  .hero { flex-direction: column; text-align: center; gap: 2px; }
  .mascot { width: 92px; }
  h1 { font-size: 34px; } h1 small { font-size: 16px; }
  .intro { font-size: 13px; }
  .grid3 { grid-template-columns: 1fr; }
  .mode, .lvl { flex-direction: row; justify-content: space-between; padding: 8px 12px; }
  .mode span { text-align: right; }
  .btn.big { min-width: 0; width: 100%; font-size: 20px; }
  .answers { grid-template-columns: 1fr; gap: 7px; }
  .ans { min-height: 50px; font-size: 16px; }
  .qcard p { font-size: 18px; }
  .qm { width: 64px; }
  .ghud { left: 54px; right: 100px; gap: 4px; } .ghud .pill { font-size: 13px; padding: 5px 8px; }
  .lbl { min-width: 0; text-align: center; width: 100%; }
}
/* ---- embed-fit: small game window (794x447, 640x360) + phone ---- */
.mcol { display: contents; }

@media (min-aspect-ratio: 5/4) and (max-height: 700px) {
  .card.menu { width: min(1000px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); column-gap: 18px; align-items: center; padding: 14px 16px 10px; }
  .mcol { display: block; min-width: 0; }
  .card.menu .note { grid-column: 1 / -1; margin-top: 6px; }
  .card.menu .hero { flex-direction: column; text-align: center; gap: 2px; }
  .card.menu .btn.big { min-width: 0; width: 100%; }
  .card.menu h3:first-child { margin-top: 0; }
}
@media (max-height: 560px) {
  .ib { width: 38px; height: 38px; } .ib svg { width: 20px; height: 20px; }
  .scr { padding: 52px 10px 8px; }
  .card { padding: 12px 14px; border-radius: 18px; box-shadow: 0 0 0 4px var(--orange), 0 0 0 7px var(--gold), 0 12px 30px rgba(30,0,40,.5); }
  .mascot { width: 72px; }
  h1 { font-size: 32px; } h1 small { font-size: 16px; margin-top: 4px; }
  h2 { font-size: 24px; margin: 0 0 4px; }
  h3 { margin: 8px 0 4px; font-size: 13px; }
  .intro { font-size: 12.5px; margin: 4px 0 2px; line-height: 1.35; }
  .btn { min-height: 42px; font-size: 16px; padding: 8px 14px; }
  .btn.big { font-size: 19px; padding: 10px 20px; margin-top: 6px; }
  .keys { font-size: 12px; margin-top: 6px; }
  .note { font-size: 11px; }
  .mode, .lvl { padding: 6px 6px; border-radius: 14px; gap: 1px; }
  .mode b, .lvl b { font-size: 14px; } .mode span, .lvl span { font-size: 11px; } .lvl .st { font-size: 15px; }
  /* team setup */
  .row { margin: 4px 0; gap: 8px; } .seg button { min-height: 36px; padding: 5px 10px; font-size: 14px; }
  .teamNames { margin: 4px 0; } .teamNames span { padding: 3px 10px; font-size: 14px; }
  /* quiz */
  #sQuiz { padding-top: 8px; }
  .quiz { gap: 6px; }
  .hud { margin: 0 92px 0 48px; } .pill { padding: 4px 12px; font-size: 14px; }
  .timer { height: 8px; }
  .qm { width: 58px; }
  .qcard { min-height: 64px; padding: 10px 14px; } .qcard p { font-size: 18px; }
  .ans { min-height: 46px; padding: 6px 10px; font-size: 15.5px; box-shadow: 0 4px 0 #d8b893; }
  .ans .n { width: 26px; height: 26px; }
  .fb { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; text-align: left; padding: 8px 12px; }
  .fb b { font-size: 17px; } .fb p { margin: 2px 0 0; font-size: 13px; line-height: 1.3; grid-column: 1; }
  .fb .btn { grid-column: 2; grid-row: 1 / span 2; }
  .hint { font-size: 12px; }
  /* result */
  #sResult .mascot { width: 64px; }
  .stars { font-size: 34px; } .big2 { font-size: 24px; margin: 2px 0; }
  #rSub { margin: 4px 0; }
  .rank { padding: 4px 12px; margin: 3px auto; font-size: 15px; }
  .btns .btn.big { min-width: 160px; }
}
@media (max-height: 420px) {
  .card.menu .mascot, #qMascot, #sResult .mascot { display: none; }
  .card.menu .intro { display: none; }
  .card .intro { font-size: 12px; }
  .ghint { display: none; }
  #sQuiz { padding-top: 6px; padding-bottom: 4px; }
  .quiz { gap: 5px; }
  .teams span { padding: 2px 8px; font-size: 12.5px; border-width: 2px; }
  .qcard { min-height: 0; padding: 7px 12px; } .qcard p { font-size: 16px; line-height: 1.25; } .turn { margin-bottom: 3px; font-size: 12px; }
  .ans { min-height: 40px; font-size: 14.5px; padding: 4px 10px; }
  .fb { padding: 6px 10px; } .fb b { font-size: 15px; } .fb p { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .fb .btn { min-height: 38px; }
  #rTeams { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; max-width: 520px; margin: 0 auto; }
  .rank { max-width: none; margin: 2px 0; }
}
@media (max-width: 600px) and (orientation: portrait) {
  .scr { padding: 52px 10px 8px; }
  .card { padding: 12px 14px; }
  .mascot { width: 64px; }
  h1 { font-size: 32px; } h1 small { font-size: 15px; margin-top: 3px; }
  .intro { font-size: 12.5px; line-height: 1.35; }
  h3 { margin: 7px 0 3px; font-size: 13px; }
  .grid3 { gap: 6px; }
  .mode, .lvl { padding: 4px 10px; min-height: 40px; }
  .btn.big { margin-top: 6px; padding: 10px 18px; }
  .keys { margin-top: 6px; font-size: 12px; }
  .note { margin-top: 6px; font-size: 11px; }
}
