:root{--ink:#241e4d;--muted:#777493;--violet:#764bdf;--purple:#9f70ef;--coral:#ff8179;--mint:#3dbdaa;--yellow:#ffc96c;--cream:#fffaf7;--glass:rgba(255,255,255,.91);font-family:'Nunito','PingFang SC','Microsoft YaHei',system-ui,-apple-system,sans-serif;color:var(--ink)}
*{box-sizing:border-box}html,body{min-height:100%;margin:0}body{background:radial-gradient(circle at 14% 15%,#fae3f8,transparent 35%),radial-gradient(circle at 85% 25%,#d4e9ff,transparent 35%),linear-gradient(155deg,#eeecff 0%,#f8f7ff 55%,#e7fff8 100%);background-attachment:fixed;overflow-x:hidden}button,input,select{font:inherit}button{cursor:pointer}button:disabled{opacity:.5;cursor:not-allowed}button:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #f9b146;outline-offset:2px}a{color:inherit}
.ambient{position:fixed;width:30rem;height:30rem;z-index:-1;filter:blur(2px);border-radius:50%;opacity:.42;pointer-events:none}.ambient-one{top:-13rem;left:-10rem;background:#e8c2fe}.ambient-two{right:-13rem;bottom:-15rem;background:#9debdc}.stars{position:absolute;left:0;right:0;text-align:center;top:54px;color:#b1a1e2;letter-spacing:clamp(16px,5vw,90px);font-size:1.3rem;pointer-events:none;opacity:.7;white-space:nowrap;overflow:hidden}
.app-shell{width:min(1080px,calc(100% - 32px));margin:20px auto 45px;position:relative}.topbar{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:14px 2px 20px}.brand{display:flex;align-items:center;gap:10px;text-decoration:none;font-weight:1000;color:#4e327f;font-size:1.05rem}.logo{width:42px;height:42px;display:grid;place-items:center;border-radius:16px;background:linear-gradient(145deg,#8953e1,#b891ff);box-shadow:0 5px 0 #6940ba;color:white;font-size:1.5rem}.topright{display:flex;gap:8px;align-items:center}.tiny-pill{font-size:.8rem;font-weight:800;color:#6a5c99;background:#ffffffc9;border:1px solid #ffffff;padding:8px 12px;border-radius:40px}.online{display:inline-block;width:9px;height:9px;border-radius:100%;background:#ddd;margin-right:4px}.online.yes{background:#39c6a2;box-shadow:0 0 0 3px #39c6a226}.icon-btn{border:0;border-radius:12px;background:white;padding:9px 12px;font-weight:900;color:#68519c}
.card{background:var(--glass);border:1px solid #ffffff;border-radius:28px;box-shadow:0 18px 50px #5a448923,0 3px 12px #5a448915;backdrop-filter:blur(18px)}.hero{display:grid;grid-template-columns:1.07fr .93fr;overflow:hidden;min-height:375px}.hero-copy{padding:48px 14px 35px 44px;position:relative;z-index:2}.eyebrow{font-size:.78rem;font-weight:950;letter-spacing:2px;color:#9060cc}.hero h1{font-size:clamp(2rem,4.1vw,3.5rem);line-height:1.19;letter-spacing:-1px;margin:15px 0;color:#3a286e}.hero h1 em{font-style:normal;background:linear-gradient(105deg,#8752e5,#e066a5);color:transparent;background-clip:text}.hero p{font-size:1rem;color:#777295;line-height:1.9;margin:0 0 27px;max-width:400px}.btn{border:0;border-radius:16px;padding:14px 18px;font-size:.98rem;font-weight:1000;transition:transform .15s,box-shadow .15s;text-align:center}.btn:hover:not(:disabled){transform:translateY(-2px)}.btn.primary{color:white;background:linear-gradient(115deg,#8559e8,#aa76f2);box-shadow:0 6px 0 #6845bd,0 12px 25px #8856d136}.btn.secondary{background:white;color:#624b93;border:1px solid #ece5ff;box-shadow:0 5px 0 #e0d7f6}.btn.rose{color:white;background:linear-gradient(120deg,#ff8b83,#fa647d);box-shadow:0 5px 0 #d94c67}.btn.teal{color:white;background:linear-gradient(130deg,#41c6a9,#2aaab8);box-shadow:0 5px 0 #2795a2}.hero-actions{display:flex;gap:13px;flex-wrap:wrap}.hero-actions .btn{min-width:154px}.hero-art{position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;background:radial-gradient(circle at center,#ead9ff 0,#f6eaff 45%,transparent 70%)}.moon{position:absolute;width:280px;height:280px;border-radius:50%;background:linear-gradient(150deg,#ded3ff,#c9f1fd);box-shadow:inset -23px -20px 0 #ffffff60;top:54px;left:50%;transform:translateX(-50%)}.hero-wizard{position:relative;font-size:clamp(8rem,15vw,11rem);filter:drop-shadow(1px 16px 9px #655ba53c);animation:levitate 3s ease-in-out infinite}.spark{position:absolute;font-size:2rem;animation:blink 2.4s infinite}.s1{top:22%;left:16%}.s2{top:20%;right:15%;animation-delay:.7s}.s3{bottom:20%;right:19%;animation-delay:1s}.s4{bottom:17%;left:10%;animation-delay:1.6s}.floating-tag{position:absolute;background:#fff;border-radius:40px;padding:8px 13px;font-weight:900;font-size:.78rem;box-shadow:0 5px 15px #735b9f25}.t1{bottom:56px;left:33px}.t2{top:82px;right:16px}.subtitle{font-weight:1000;font-size:1.1rem;margin:0 0 15px}.lobby-grid{display:grid;grid-template-columns:1.2fr .8fr;gap:16px;margin-top:18px}.section{padding:25px}.setup-grid{display:grid;grid-template-columns:1fr 1fr;gap:13px}.field{display:flex;flex-direction:column;gap:7px;font-size:.83rem;color:#6e6392;font-weight:900}.input{width:100%;border:2px solid #e9e1fb;background:#faf9ff;border-radius:14px;padding:13px 14px;color:#342254;min-width:0;font-size:1rem}.segmented{display:flex;gap:5px;flex-wrap:wrap}.segmented button{border:2px solid #e9e1fa;background:#faf9ff;padding:9px 12px;border-radius:12px;color:#6b5b9c;font-weight:900}.segmented button.selected{border-color:#9168ea;background:#f1eaff;color:#643ac3}.mode-list{display:grid;gap:12px}.mode-choice{display:flex;align-items:center;gap:12px;text-align:left;border:2px solid #ece4ff;border-radius:18px;padding:14px 17px;background:#fcfaff;min-height:85px}.mode-choice:hover{border-color:#ba98fa}.mode-choice .bubble{font-size:2rem}.mode-choice strong{display:block;font-size:.98rem}.mode-choice small{color:#8a82a1;font-weight:700}.profile-row{display:flex;justify-content:space-between;align-items:center;gap:9px;padding:10px 0;border-bottom:1px dashed #eae3f6}.profile-row:last-child{border:0}.profile-row strong{font-size:1.05rem}.footer-note{text-align:center;color:#9991ad;font-size:.77rem;margin-top:25px;line-height:1.8}
/* Waiting room */
.center-panel{max-width:670px;margin:22px auto;text-align:center;padding:42px 30px}.center-panel h2{font-size:2.2rem;margin:6px 0 14px}.center-panel p{color:#756d91;line-height:1.8}.room-code{font-size:clamp(2.8rem,8vw,4.5rem);font-weight:1000;letter-spacing:10px;color:#7650cf;margin:18px 0;background:#f2edff;border-radius:22px;padding:17px 8px;border:2px dashed #c7b2ff}.row-actions{display:flex;gap:12px;justify-content:center;flex-wrap:wrap;margin:16px auto}.loader-stars{font-size:2.9rem;animation:levitate 2s ease-in-out infinite}.join-line{display:flex;gap:10px}.join-line .input{flex:1}.link-quiet{border:0;background:none;color:#8676ac;font-weight:900;text-decoration:underline;padding:8px}
/* Battle */
.battle-card{overflow:hidden}.arena-top{background:#ffffffc4;padding:18px 25px;display:flex;align-items:center;justify-content:space-between;gap:10px;border-bottom:1px solid #eae2fb}.arena-tag{font-size:.8rem;font-weight:1000;color:#754bd1}.timer{background:#342655;color:#fff;border-radius:15px;padding:11px 17px;min-width:99px;text-align:center;font-weight:1000;font-size:1.25rem;font-variant-numeric:tabular-nums;box-shadow:0 5px 0 #27183f}.battle-stage{min-height:325px;position:relative;overflow:hidden;background:linear-gradient(#d4c8ff 0%,#b6e7f5 58%,#9ad4c7 59%,#76c7b6 100%)}.arena-sun{position:absolute;left:48%;top:13px;border-radius:50%;width:140px;height:140px;background:#fef2c7bf;filter:blur(2px)}.stage-hill{position:absolute;bottom:8%;width:56%;height:29%;background:#5cc1b1;border-radius:50% 50% 0 0;opacity:.6}.stage-hill.h1{left:-17%}.stage-hill.h2{right:-13%;background:#5eb9b7;transform:scaleX(1.3)}.castle{position:absolute;left:46%;top:8%;font-size:5rem;opacity:.48}.duelers{position:relative;z-index:2;height:315px;display:grid;grid-template-columns:1fr 1fr;align-items:end;padding:8px clamp(16px,4vw,50px) 18px;gap:60px}.dueler{text-align:center}.fighter{font-size:clamp(5rem,12vw,8rem);line-height:1.2;filter:drop-shadow(0 15px 4px #3e8f9d55);animation:levitate 2.8s ease-in-out infinite}.dueler.enemy .fighter{animation-delay:.4s}.fighter-name{margin:7px auto 4px;background:#ffffffdd;width:fit-content;border-radius:22px;padding:5px 12px;font-size:.8rem;font-weight:1000;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hp-outer{background:#ffffffb4;border-radius:12px;padding:4px;margin:auto;max-width:260px}.hp-track{height:16px;background:#e7deec;border-radius:12px;overflow:hidden}.hp-fill{height:100%;border-radius:12px;background:linear-gradient(90deg,#ff8b9d,#ff6778);transition:width .5s}.hp-count{font-size:.72rem;font-weight:950;color:#543c72;margin-top:3px}.shield-chip{display:inline-block;background:#e4f9ff;color:#3688a5;border:1px solid #98d9ec;border-radius:12px;font-size:.72rem;font-weight:950;padding:3px 7px;margin-top:3px}.divider-vs{position:absolute;left:50%;top:47%;transform:translate(-50%,-50%) rotate(-8deg);font-weight:1000;font-size:2.3rem;color:#fff;text-shadow:0 4px 0 #9778b8,0 6px 15px #4c4077}
.arena-bottom{padding:22px;min-height:295px}.phase-title{font-size:1.15rem;font-weight:1000;text-align:center;margin:0 0 8px}.phase-sub{font-size:.85rem;color:#8c80a4;text-align:center;margin:0 0 17px}.spell-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;max-width:720px;margin:14px auto 0}.spell-option{border:2px solid #e9e2ff;background:linear-gradient(#fff,#fdfaff);padding:20px 9px 16px;border-radius:20px;box-shadow:0 5px 0 #dfd5f8;transition:transform .15s}.spell-option:hover:not(:disabled){transform:translateY(-3px)}.spell-option .glyph{font-size:2.6rem;display:block}.spell-option strong{display:block;font-size:.96rem;margin:4px 0}.spell-option small{color:#9a91ab}.question-box{max-width:700px;margin:auto;text-align:center}.question-type{font-size:.75rem;color:#866fc0;font-weight:900;letter-spacing:1px}.question-title{font-size:clamp(1.2rem,3vw,1.65rem);font-weight:1000;margin:10px 0 14px}.question-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:11px;max-width:600px;margin:14px auto}.answer-button{border:2px solid #eae2ff;background:#fff;color:#60459c;border-radius:17px;box-shadow:0 4px 0 #dcd1fa;padding:17px 9px;font-size:clamp(1.08rem,3vw,1.5rem);font-weight:1000;min-height:69px;transition:all .12s}.answer-button:hover:not(:disabled){border-color:#9c75e9;background:#f7f2ff;transform:translateY(-2px)}.question-tools{display:flex;gap:9px;justify-content:center;flex-wrap:wrap;margin-bottom:7px}.mini-btn{border:1px solid #dccffc;background:#f6f1ff;color:#694bb0;border-radius:13px;font-weight:950;padding:10px 14px}.assemble-rows{display:grid;gap:11px;max-width:550px;margin:12px auto}.syllable-row{display:flex;gap:9px;justify-content:center;flex-wrap:wrap}.chip{border:2px solid #e1d7f8;background:white;padding:13px 19px;border-radius:14px;font-size:1.33rem;font-weight:1000;color:#5e45ac;min-width:78px}.chip.selected{background:#7455dd;color:#fff;border-color:#7455dd;box-shadow:0 5px 0 #5d3eaf}.compose-line{display:flex;gap:12px;align-items:center;justify-content:center;margin:12px 0}.drop-slot{width:120px;max-width:40%;border:2px dashed #bda8ed;border-radius:14px;padding:13px 10px;background:#f9f6ff;font-size:1.3rem;font-weight:1000;min-height:62px}.feedback{margin:20px auto;text-align:center;background:#f4f0ff;max-width:550px;padding:16px;border-radius:16px;font-weight:1000;color:#6f4bc5}.feedback.good{background:#dcf7ee;color:#1e9a78}.feedback.bad{background:#ffeff0;color:#bf5d63}.crystal-panel{border:3px solid #fbc768;border-radius:24px;padding:18px;background:linear-gradient(140deg,#fffcf1,#fff8df);max-width:690px;margin:auto}.crystal-panel h3{font-size:1.3rem;margin:6px}.log-banner{background:#ffffffc5;border-radius:13px;padding:9px 14px;font-size:.84rem;color:#6f5b91;text-align:center;margin:12px 15px 0;min-height:38px}.bottom-controls{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:15px 23px;border-top:1px solid #f3eeff}.metric{display:flex;gap:14px;color:#8574ac;font-size:.86rem;font-weight:950}.metric strong{color:#5d4298}
.result-head{text-align:center;padding:45px 18px 20px}.result-trophy{font-size:5.7rem;animation:levitate 3s infinite}.result-head h1{font-size:2.5rem;margin:5px}.result-metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin:18px auto;max-width:700px}.result-metric{background:#f7f3ff;border-radius:19px;padding:21px 8px;text-align:center}.result-metric strong{display:block;font-size:1.65rem;color:#6544b9}.result-metric small{color:#8d83a3;font-weight:900}.result-actions{text-align:center;padding:12px 0 44px}
#toast{position:fixed;top:78px;left:50%;transform:translateX(-50%) translateY(-30px);opacity:0;pointer-events:none;max-width:min(550px,90vw);text-align:center;background:#3d2b73;color:white;box-shadow:0 10px 30px #30245236;border-radius:15px;padding:12px 18px;transition:opacity .2s,transform .2s;z-index:40;font-weight:900}#toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
@keyframes levitate{0%,100%{transform:translateY(0)}50%{transform:translateY(-10px)}}@keyframes blink{0%,100%{opacity:.4;transform:scale(.9)}50%{opacity:1;transform:scale(1.2)}}
@media(max-width:730px){.app-shell{width:calc(100% - 20px);margin:5px auto 30px}.stars{display:none}.hero{grid-template-columns:1fr}.hero-copy{padding:30px 27px 13px}.hero-copy h1{font-size:2.35rem}.hero-art{min-height:230px}.moon{width:210px;height:210px;top:10px}.hero-wizard{font-size:7.5rem}.t1{bottom:20px}.t2{top:18px}.lobby-grid{grid-template-columns:1fr}.section{padding:18px}.arena-top{padding:13px}.duelers{gap:24px;min-height:260px;height:260px;padding:8px 12px 18px}.battle-stage{min-height:260px}.fighter{font-size:clamp(4.8rem,16vw,7rem)}.arena-bottom{padding:17px 12px}.spell-grid{gap:8px}.spell-option{padding:13px 3px;min-width:0}.spell-option strong{font-size:.82rem}.spell-option small{font-size:.69rem}.spell-option .glyph{font-size:2rem}.result-metrics{gap:7px}.result-metric strong{font-size:1.35rem}.bottom-controls{padding:12px}.metric{gap:7px;font-size:.77rem}.hero-actions .btn{min-width:130px}.topbar{padding:10px 2px 15px}}@media(max-width:430px){.setup-grid{grid-template-columns:1fr}.topright .tiny-pill:last-child{display:none}.hero-actions{gap:8px}.hero-actions .btn{padding:12px;font-size:.91rem}.room-code{letter-spacing:5px;font-size:2.8rem}.answer-button{min-height:64px}.topbar .brand{font-size:.94rem}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation-duration:.01ms!important;transition-duration:.01ms!important}}

/* ===== Mobile-first battle experience: v0.2 ===== */
button, .chip, .mode-choice { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:active:not(:disabled) { transform: scale(.98); }
input, select { font-size: 16px; }
body { padding-bottom: env(safe-area-inset-bottom, 0px); }
.app-shell { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.invite-field { max-width: 490px; margin: 8px auto 12px; text-align: left; }
.invite-url { font-size: .85rem; font-weight: 700; }
.center-panel .row-actions .btn, .join-line .btn { min-height: 52px; }
@media (hover: none) { .btn:hover:not(:disabled), .answer-button:hover:not(:disabled), .spell-option:hover:not(:disabled) { transform: none; } }
@media (max-width: 730px) {
  .is-battle .topbar, .is-battle .footer-note { display: none; }
  .is-battle.app-shell { width: calc(100% - 10px); margin: 5px auto; }
  .battle-card { border-radius: 17px; }
  .arena-top { position: sticky; top: 0; z-index: 10; padding: 9px 12px; min-height: 55px; }
  .arena-top .timer { padding: 8px 12px; min-width: 81px; font-size: 1rem; border-radius: 12px; }
  .arena-top .icon-btn { min-height: 44px; min-width: 52px; }
  .arena-tag { font-size: .77rem; }
  .battle-stage { min-height: 170px; height: clamp(170px, 28dvh, 230px); }
  .duelers { height: 100%; min-height: 0; padding: 4px 10px 9px; gap: 10px; }
  .fighter { font-size: clamp(3.3rem, 13vw, 5.6rem); }
  .fighter-name { margin: 2px auto; padding: 3px 9px; }
  .hp-outer { max-width: 170px; padding: 3px; }
  .hp-track { height: 12px; }
  .hp-count { margin-top: 1px; }
  .castle { font-size: 3.3rem; }
  .arena-sun { width: 88px; height: 88px; }
  .divider-vs { top: 48%; font-size: 1.5rem; }
  .log-banner { margin: 5px 8px 0; padding: 6px 10px; min-height: 30px; font-size: .73rem; }
  .arena-bottom { min-height: 195px; padding: 12px 11px 13px; }
  .phase-title { font-size: 1rem; margin: 0 0 4px; }
  .phase-sub { font-size: .76rem; line-height: 1.45; margin: 4px 0 9px; }
  .spell-grid { gap: 7px; margin-top: 8px; }
  .spell-option { min-height: 92px; padding: 9px 3px; }
  .spell-option .glyph { font-size: 2rem; }
  .spell-option strong { font-size: .83rem; }
  .spell-option small { display: block; font-size: .65rem; }
  .question-title { font-size: clamp(1.08rem, 4.5vw, 1.3rem); margin: 5px 0 8px; }
  .question-options { gap: 8px; margin: 9px auto; }
  .answer-button { min-height: 55px; padding: 9px 6px; font-size: clamp(1.05rem, 5vw, 1.35rem); }
  .chip { min-height: 48px; min-width: 65px; padding: 8px 13px; }
  .compose-line { margin: 6px 0; }
  .drop-slot { min-height: 46px; padding: 7px; }
  .bottom-controls { padding: 7px 11px calc(7px + env(safe-area-inset-bottom,0px)); }
  .bottom-controls .link-quiet { min-height: 44px; }
  .question-tools .mini-btn { min-height: 44px; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .hero-actions .btn { min-width: 0; min-height: 52px; }
  .mode-choice { min-height: 70px; }
  .room-code { overflow-wrap: anywhere; }
  .join-line .input { min-width: 0; }
  .result-actions .btn { min-height: 54px; }
}
@media (max-width: 370px) and (orientation: portrait) {
  .fighter { font-size: 3.4rem; }
  .arena-bottom { padding: 10px 7px; }
  .spell-option .glyph { font-size: 1.7rem; }
  .spell-option small { display: none; }
  .question-options { gap: 6px; }
  .answer-button { min-height: 52px; }
  .metric { font-size: .66rem; gap: 5px; }
  .metric span:last-child { display: none; }
}
/* In landscape, use a side-by-side arena and puzzle so both remain visible.
   Do not force orientation: portrait remains fully playable. */
@media (orientation: landscape) and (max-height: 540px) and (max-width: 1050px) {
  body.battle-screen { padding-bottom: 0; }
  .is-battle .topbar, .is-battle .footer-note { display: none; }
  .is-battle.app-shell { width: calc(100% - 8px); margin: 4px auto; }
  .battle-card { display: grid; grid-template-columns: minmax(0,43%) minmax(0,57%); grid-template-rows: 48px minmax(0,1fr) 39px;
    height: calc(100dvh - 8px); min-height: 280px; border-radius: 14px; }
  .arena-top { grid-column: 1/-1; grid-row: 1; padding: 4px 11px; min-height: 0; position: relative; }
  .arena-top .timer { padding: 5px 10px; min-width: 78px; font-size: 1rem; }
  .arena-top .icon-btn { min-height: 38px; }
  .battle-stage { grid-column: 1; grid-row: 2; height: auto; min-height: 0; }
  .duelers { height: 100%; min-height: 0; gap: 4px; padding: 1px 5px 8px; }
  .fighter { font-size: clamp(3.3rem, 7.4vw, 4.6rem); }
  .fighter-name { font-size: .68rem; margin: 1px auto; padding: 3px 4px; }
  .hp-count { font-size: .64rem; }
  .hp-track { height: 10px; }
  .arena-sun { width: 65px; height: 65px; }
  .castle { font-size: 2.8rem; }
  .divider-vs { font-size: 1.2rem; }
  .log-banner { display: none; }
  .arena-bottom { grid-column: 2; grid-row: 2; min-height: 0; padding: 6px 9px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; align-items: center; justify-content: safe center; }
  .arena-bottom > * { width: 100%; flex-shrink: 0; }
  .phase-title { font-size: .96rem; margin: 0 0 3px; }
  .phase-sub { font-size: .69rem; margin: 3px 0 5px; }
  .spell-grid { gap: 7px; margin: 6px auto 0; }
  .spell-option { min-height: 80px; padding: 5px 3px; border-radius: 14px; }
  .spell-option .glyph { font-size: 1.6rem; }
  .spell-option strong { font-size: .73rem; margin: 1px 0; }
  .spell-option small { display: none; }
  .question-title { font-size: clamp(1rem, 2.5vw, 1.2rem); margin: 3px 0 5px; }
  .question-options { gap: 6px; margin: 5px auto; }
  .answer-button { min-height: 44px; padding: 4px; font-size: 1rem; border-radius: 12px; }
  .question-tools { margin-bottom: 3px; }
  .mini-btn { min-height: 40px; padding: 6px 8px; font-size: .7rem; }
  .assemble-rows { gap: 5px; margin: 5px auto; }
  .syllable-row { gap: 5px; }
  .chip { min-width: 50px; min-height: 43px; padding: 5px 10px; font-size: 1rem; }
  .compose-line { gap: 6px; margin: 4px 0; }
  .drop-slot { min-height: 42px; padding: 6px; font-size: .9rem; }
  .compose-line + div .btn { padding: 8px 11px; font-size: .82rem; }
  .crystal-panel { padding: 7px; }
  .crystal-panel h3 { font-size: .94rem; margin: 2px; }
  .feedback { margin: 5px auto; padding: 8px; font-size: .82rem; }
  .bottom-controls { grid-column: 1/-1; grid-row: 3; padding: 1px 12px; min-height: 0; }
  .bottom-controls .link-quiet { padding: 1px 7px; min-height: 33px; }
  .metric { font-size: .74rem; }
  .shield-chip { font-size: .62rem; padding: 1px 4px; }
}

/* Photo portraits: one consistent costume and a circular face, on every device. */
.avatar-setup{display:flex;gap:18px;align-items:center;margin:18px 0;padding:14px;border-radius:18px;background:#f4eefe}.avatar-setup p{font-size:.8rem;line-height:1.6;color:#76648c;margin:5px 0 10px}.avatar-mini{flex:none;width:90px}.avatar-mini .fighter{font-size:76px;animation:none}.photo-fighter{position:relative;width:1.18em;height:1.32em;margin:auto;line-height:1}.photo-fighter svg{display:block;width:100%;height:100%}.portrait-face{position:absolute;left:28%;top:25%;width:44%;height:39%;border-radius:50%;object-fit:cover;border:2px solid #ffe9bb;box-shadow:0 2px 4px #24143240}.avatar-dialog{width:min(460px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto;border:0;border-radius:22px;padding:20px;color:#45345e;background:#fff;box-shadow:0 20px 90px #25114366}.avatar-dialog::backdrop{background:#25114399}.avatar-title{display:flex;align-items:center;justify-content:space-between;gap:8px}.avatar-title h2{font-size:1.2rem;margin:0}.avatar-dialog p{font-size:.85rem;line-height:1.6}.avatar-file{display:block;text-align:center}.avatar-file input{display:block;max-width:100%;font-size:.8rem;margin-top:8px}.crop-frame{position:relative;width:min(250px,100%);aspect-ratio:1;margin:12px auto;overflow:hidden;border-radius:14px;background:#eee7f6}.crop-frame canvas{width:100%;height:100%;display:block}.crop-guide{position:absolute;inset:0;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 80px #30204566;pointer-events:none}.crop-controls{display:grid;gap:4px}.crop-controls label{display:flex;align-items:center;gap:14px;font-size:.85rem}.crop-controls input{flex:1;min-width:0;min-height:36px;accent-color:#7953c1}.avatar-consent{display:flex;gap:10px;align-items:center;font-size:.82rem;line-height:1.6;margin:15px 0}.avatar-consent input{width:22px;height:22px;flex:none;accent-color:#7953c1}.avatar-privacy{color:#79698a}.avatar-dialog .row-actions{display:flex;gap:8px;flex-wrap:wrap}.avatar-dialog button{min-height:44px}.avatar-dialog #avatar-error:empty{display:none}@media(max-width:370px){.avatar-setup{gap:8px;padding:10px}.avatar-mini{width:62px}.avatar-mini .fighter{font-size:54px}.avatar-setup .btn{padding:10px;font-size:.82rem}.avatar-dialog{padding:14px}.crop-frame{width:190px}}

/* Persistent voice controls remain outside the re-rendered game board. */
#voice-panel[hidden],#voice-panel [hidden]{display:none!important}
#voice-panel{position:fixed;bottom:0;left:50%;transform:translateX(-50%);z-index:30;width:min(600px,100%);padding:8px 12px calc(8px + env(safe-area-inset-bottom));background:#fcfafff5;border:1px solid #dacef2;border-radius:18px 18px 0 0;box-shadow:0 -4px 22px #55407822;box-sizing:border-box;color:#5c448c;text-align:center}
.voice-status{font-size:12px;min-height:18px;line-height:18px}.voice-note{font-size:10px;line-height:15px;color:#84729e;margin-top:3px}.voice-actions{display:flex;justify-content:center;gap:7px;margin-top:4px}
.voice-actions button{min-height:44px;border:1px solid #d9caf0;border-radius:12px;padding:6px 12px;background:#f3edff;color:#61479a;font-size:13px;font-weight:800;cursor:pointer}.voice-actions .voice-enable,.voice-actions .voice-talk{background:#7f57ce;color:white;flex:1;max-width:300px}.voice-talk{touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}.voice-talk[aria-pressed=true]{background:#bf3f62}.voice-talk:disabled{opacity:.5}.has-voice{padding-bottom:110px!important}.voice-speaking .fighter{filter:drop-shadow(0 0 10px #39cbad)}
@media(max-height:520px) and (orientation:landscape){body.has-voice .battle-card{height:calc(100dvh - 115px);min-height:240px}#voice-panel{padding-top:4px}.voice-note{display:none}.has-voice{padding-bottom:83px!important}}
@media(max-width:360px){.voice-actions{gap:4px}.voice-actions button{padding:5px 7px;font-size:12px}}
.team-lobby{max-width:850px}.team-rosters{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:18px 0}.team-roster{border-radius:16px;padding:12px;background:#f0e9ff}.team-roster.team-1{background:#dff5ee}.team-roster h3{margin:0 0 9px;font-size:16px}.team-roster ul{padding:0;list-style:none;min-height:40px;font-size:13px;line-height:1.8}.team-stage{height:auto;min-height:240px;background:linear-gradient(120deg,#e4d7ff,#d3f2ed)}.team-battle-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;padding:14px}.team-battle h3{text-align:center;font-size:15px;margin:0 0 8px}.team-fighters{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;margin-top:12px}.team-fighters .dueler{width:calc(33.333% - 6px);min-width:65px}.team-fighters .fighter{font-size:45px;animation:none;line-height:1.1}.team-fighters .photo-fighter{width:68px!important;height:77px!important;margin:auto}.team-fighters .fighter-name{font-size:10px;padding:3px 5px;max-width:95px}.team-fighters small{font-size:10px}.player-left{opacity:.4}
@media(max-width:430px){.team-battle-grid{gap:8px;padding:10px 6px}.team-fighters .dueler{width:calc(50% - 4px);min-width:45px}.team-fighters .photo-fighter{width:54px!important;height:61px!important}.team-fighters .fighter{font-size:35px}.team-roster{padding:10px 6px}.team-roster .mini-btn{padding:8px}.team-rosters{gap:8px}}
@media(orientation:landscape) and (max-height:540px) and (max-width:1050px){.team-stage{overflow-y:auto}.team-battle-grid{gap:5px;padding:5px}.team-fighters{gap:3px;margin-top:5px}.team-fighters .dueler{min-width:32px;width:calc(50% - 3px)}.team-fighters .fighter{font-size:25px}.team-fighters .photo-fighter{width:33px!important;height:38px!important}.team-fighters .fighter-name{font-size:9px}.team-battle h3{font-size:11px}.team-fighters small{display:none}}

/* Individual hearts and synchronized rounds. */
.round-rules{padding:12px;background:#f2eaff;border-radius:12px;line-height:1.8;font-size:14px}.round-clock{text-align:center;font-size:13px;font-weight:850;color:#5e3a8c}.round-clock strong{display:block;font-size:22px;color:#a03d6c}.round-board{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:10px;background:linear-gradient(110deg,#e4d8ff,#d8f1ee)}.round-team{min-width:0}.round-team h3{margin:2px 0 6px;text-align:center;font-size:16px}.round-team h3 small{display:block;font-size:11px;font-weight:500;margin-top:3px}.angel-zone{border:1px dashed #a692c64d;border-radius:13px;background:#ffffff55;min-height:29px;margin-bottom:8px}.sky-label{text-align:center;color:#9186aa;font-size:10px;padding:3px}.ground-fighters,.sky-fighters{display:flex;flex-wrap:wrap;justify-content:center;gap:6px}.round-fighter{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:calc(33.333% - 5px);max-width:125px;min-width:74px;padding:5px 2px;border:2px solid transparent;border-radius:14px;background:#ffffff50;color:#45315f;font:inherit;opacity:1;cursor:default;box-sizing:border-box}.round-fighter:disabled{opacity:1;color:#45315f}.overhead-name{font-weight:800;font-size:11px;line-height:1.3;max-width:100%;overflow-wrap:anywhere}.heart-row{display:flex;gap:0;white-space:nowrap;line-height:17px}.heart{font-size:15px}.heart.full{color:#eb3655;text-shadow:0 1px 0 #fff}.heart.empty{color:#b2a4bc}.figure-wrap{display:block;position:relative;width:64px;height:65px}.figure-wrap .fighter{font-size:44px;line-height:1.3;animation:none}.figure-wrap .photo-fighter{font-size:40px;width:55px!important;height:62px!important}.fighter-badge{font-size:10px;line-height:15px;margin-top:1px}.angel-wings{position:absolute;inset:8px -4px;color:white;font-size:35px;text-shadow:0 1px 3px #8f81cb;z-index:0}.angel-halo{position:absolute;top:-9px;left:22px;color:#ffd851;font-size:24px;line-height:18px;text-shadow:0 0 5px #fff4a9;z-index:3}.is-angel .fighter{position:relative;z-index:1;filter:drop-shadow(0 0 5px white)}.is-angel{background:#fff7d580}.shield-ring{position:absolute;inset:1px -2px -2px;border:3px solid #73d6ff;border-radius:48%;box-shadow:0 0 8px #17bdfd,inset 0 0 8px #45d4ff;background:#66dcff16}.can-target{cursor:pointer;border-color:#9c64e6;box-shadow:0 0 9px #af7bfc70;background:#fff}.target-selected{border-color:#ec9a2b!important;background:#fff1bc!important;box-shadow:0 0 0 2px #ffc75f70}.target-check{position:absolute;right:-4px;top:-7px;background:#7145b8;color:white;border-radius:50%;padding:1px 5px;font-size:13px}.spell-option.selected,.target-options .selected{border:2px solid #8b51c5;background:#eee1ff}.target-options{display:flex;flex-wrap:wrap;justify-content:center;gap:8px}.target-summary{font-size:13px;color:#74548b;font-weight:700;text-align:center}.revealed-han{display:block;font-size:28px}.empty-field{font-size:12px;color:#857697;padding:30px 5px}.round-battle .arena-bottom{min-height:205px}.round-battle .bottom-controls{gap:5px}.round-battle .bottom-controls button{white-space:nowrap}.round-battle .metric{flex-wrap:wrap}.round-battle .arena-tag small{font-size:10px;color:#9884ab}.magic-fx{position:fixed;pointer-events:none;z-index:80;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.running-wizard .fighter,.flying-angel .fighter{font-size:45px;animation:none}.running-wizard .photo-fighter,.flying-angel .photo-fighter{font-size:40px;width:55px!important;height:62px!important}.running-wizard .shield-ring{display:none}.magic-burst,.magic-impact{font-size:28px;font-weight:900;text-shadow:0 0 10px white}.magic-burst.heal{color:#db4589}.heal-flash .heart-row{animation:heart-pop 1.1s ease-out}.shield-flash .figure-wrap{animation:shield-glow 1s ease-out}.hit-flash .figure-wrap{animation:hit-jolt .5s ease-out}.flying-angel .angel-wings{inset:25px 0}.flying-angel .angel-halo{top:15px;left:40%}@keyframes heart-pop{35%{transform:scale(1.3);filter:drop-shadow(0 0 7px #fc497f)}}@keyframes shield-glow{40%{filter:drop-shadow(0 0 16px #29bfff);transform:scale(1.12)}}@keyframes hit-jolt{30%{transform:translateX(-7px)}60%{transform:translateX(6px)}}
@media(max-width:600px){.round-board{gap:7px;padding:8px 5px}.round-team h3{font-size:13px}.round-fighter{width:calc(50% - 3px);min-width:50px;padding:3px 1px;border-radius:10px}.overhead-name{font-size:10px}.heart{font-size:13px}.figure-wrap{width:49px;height:45px}.figure-wrap .fighter{font-size:34px;line-height:1.2}.figure-wrap .photo-fighter{width:40px!important;height:45px!important}.fighter-badge{font-size:9px}.angel-wings{font-size:28px;inset:4px -5px}.angel-halo{left:16px;top:-9px;font-size:20px}.round-clock{font-size:11px}.round-clock strong{font-size:19px}.round-battle .arena-bottom{min-height:190px}.round-battle .arena-top{padding:5px 8px}.sky-fighters{gap:2px}.is-angel .heart-row{line-height:11px}.is-angel .heart{font-size:10px}}
@media(orientation:landscape) and (max-height:540px) and (max-width:1050px){.round-battle .round-board{grid-column:1;grid-row:2;overflow-y:auto;min-height:0;padding:3px}.round-battle .arena-bottom{min-height:0}.round-battle .round-fighter{width:calc(50% - 2px);min-width:40px;padding:1px}.round-battle .figure-wrap{width:35px;height:34px}.round-battle .figure-wrap .fighter{font-size:27px}.round-battle .figure-wrap .photo-fighter{width:29px!important;height:33px!important}.round-battle .heart{font-size:10px}.round-battle .heart-row{line-height:12px}.round-battle .overhead-name{font-size:9px}.round-battle .fighter-badge{font-size:8px;line-height:10px}.round-battle .round-team h3{font-size:11px;margin:1px}.round-battle .round-team h3 small{font-size:9px;margin:0}.round-battle .angel-zone{min-height:18px;margin-bottom:3px}.round-battle .sky-label{font-size:8px;padding:1px}.round-battle .ground-fighters{gap:2px}.round-battle .round-clock strong{display:inline;margin-left:8px;font-size:16px}.round-battle .angel-halo{left:8px}.round-battle .angel-wings{font-size:20px}}
@media(prefers-reduced-motion:reduce){.heal-flash .heart-row,.shield-flash .figure-wrap,.hit-flash .figure-wrap{animation:none}}

.figure-wrap .angel-halo{width:22px;height:8px;border:3px solid #ffd65f;border-radius:50%;left:calc(50% - 11px);top:-3px;box-shadow:0 0 7px #fff7ad;transform:rotate(-8deg)}.angel-wings::before,.angel-wings::after{content:"";position:absolute;top:3px;width:24px;height:32px;background:#fffdf6;border:1px solid #cfc1e3;box-shadow:0 0 8px white;border-radius:80% 15% 80% 25%;transform:rotate(-32deg);left:-1px}.angel-wings::after{left:auto;right:-1px;transform:scaleX(-1) rotate(-32deg)}
/* Keep the round clock visible while the child scrolls to the answers. */
.round-battle{overflow:visible}.round-battle .arena-top{position:sticky;top:0;z-index:20;background:#fff;border-radius:20px 20px 0 0;box-shadow:0 2px 8px #58426b14}
@media(orientation:landscape) and (max-height:540px) and (max-width:1050px){.round-battle .arena-top{position:relative;top:auto}}

/* v0.6: numerical life, checkpoint reports and equipment rewards. */
.hp-meter{position:relative;display:block;width:100%;height:18px;border:1px solid #78bda7;background:#edf2f6;border-radius:8px;overflow:hidden;margin:3px 0;color:#172b39}
.hp-meter>span{display:block;height:100%;background:linear-gradient(90deg,#70d5a5,#a6ebbb);transition:width .45s}
.hp-meter.low>span{background:linear-gradient(90deg,#ff958e,#ffd29d)}
.hp-meter b{position:absolute;inset:0;font-size:11px;line-height:16px;font-weight:900;text-shadow:0 1px 2px white}
.gear-mini{height:16px;display:flex;justify-content:center;gap:3px;font-size:13px}
.gear-mini:empty{display:none}.power-line{text-align:center;font-size:12px;color:#5c4d79;font-weight:800;margin:8px 0}
.spell-grid.angel-spells{grid-template-columns:1fr;max-width:320px;margin:auto}
.past-report{padding:12px 16px;border-top:1px solid #ece7f7}.past-report summary{cursor:pointer;color:#635280;font-weight:800}
.report-list{display:grid;gap:8px}.report-player{padding:10px;border-radius:12px;background:#f4f0ff;border-left:4px solid #a88be7;font-size:12px;line-height:1.8;text-align:left}
.report-player.team-1{background:#fff4e9;border-color:#f0b078}.report-player strong{display:block;color:#55466c}.report-player small{font-weight:400;color:#706982}.report-player b{font-size:15px;color:#644a9a}
.five-report{padding:8px 4px}.upgrade-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.upgrade-option{display:flex;flex-direction:column;align-items:center;gap:8px;border:2px solid #d9c9f7;border-radius:15px;background:linear-gradient(#fff,#f5efff);padding:14px 6px;color:#4d396b;cursor:pointer;font:inherit;min-width:0}
.upgrade-option:hover{border-color:#9a70e0}.upgrade-option:disabled{opacity:.5;cursor:default}.upgrade-option small{font-size:10px;line-height:1.7}.upgrade-option b{font-size:11px}.upgrade-icon{font-size:32px}.upgrade-option strong{font-size:14px}
.reward-prompt{text-align:center;font-weight:800;color:#725294;font-size:13px}.upgrade-earned{text-align:center;padding:20px;background:#fff3c9;border-radius:16px;font-weight:900;color:#855a0d}.upgrade-earned small{font-weight:400}.upgrade-announcements{font-size:12px;color:#6d5686;text-align:center}
.upgrade-burst{z-index:5000!important;color:#875700;font-weight:900;text-align:center;white-space:nowrap;text-shadow:0 1px white,0 0 8px #ffe59b;pointer-events:none;font-size:18px}
.upgrade-flash{animation:upgrade-glow 1.8s ease-out}@keyframes upgrade-glow{0%,70%{box-shadow:0 0 28px 8px #ffd75b;filter:brightness(1.2)}100%{box-shadow:none}}
@media(min-width:700px){.report-list{grid-template-columns:1fr 1fr}.upgrade-option{padding:18px 12px}.upgrade-option small{font-size:12px}}
@media(prefers-reduced-motion:reduce){.hp-meter>span{transition:none}.upgrade-flash{animation:none}}

.round-battle .arena-bottom{scroll-margin-top:75px}.heal-flash .hp-meter{animation:heart-pop 1.1s ease-out}.upgrade-earned{animation:upgrade-glow 1.8s ease-out}
@media(orientation:landscape) and (max-height:540px) and (max-width:1050px){.past-report{grid-column:1/-1;grid-row:4}.round-battle:has(.past-report){grid-template-rows:48px minmax(0,1fr) 39px auto}}
/* Original textbook pictograms keep answer controls visible on short screens. */
.pinyin-picture{display:block;width:min(240px,60%);margin:8px auto;text-align:center}.pinyin-picture img{display:block;width:100%;max-height:150px;object-fit:contain;border-radius:16px}.question-title{white-space:pre-line}.question-box .options button,.answer-option{overflow-wrap:anywhere}@media(max-height:520px){.pinyin-picture{width:150px;margin:3px auto}.pinyin-picture img{max-height:88px}}

/* Textbook pinyin: sentence choices wrap in two columns; pictures keep space for answers. */
.battle-screen .round-battle.phase-answer .arena-bottom:has(.textbook-question){left:50%;right:auto;width:92vw;max-width:1200px;transform:translateX(-50%)}
.battle-screen .round-battle.phase-answer .textbook-question .question-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;max-width:1000px}
.battle-screen .round-battle.phase-answer .textbook-question .answer-button{white-space:normal;overflow-wrap:anywhere;min-width:0;font-size:clamp(22px,2.7vw,36px);line-height:1.5}
.battle-screen .round-battle.phase-answer .textbook-question:has(.pinyin-picture){display:grid;grid-template-columns:minmax(130px,26%) 1fr;align-items:center;gap:8px 18px}
.battle-screen .round-battle.phase-answer .textbook-question:has(.pinyin-picture)>:is(.question-type,.question-title,.skip-question,.info-button){grid-column:1/-1}
.battle-screen .round-battle.phase-answer .textbook-question .pinyin-picture{width:100%;max-width:240px}
@media(max-height:520px){
 .battle-screen .round-battle.phase-answer .textbook-question .question-title{font-size:22px;line-height:1.35}
 .battle-screen .round-battle.phase-answer .textbook-question .answer-button{font-size:22px;min-height:52px;padding:8px}
 .battle-screen .round-battle.phase-answer .textbook-question:has(.pinyin-picture){gap:3px 12px}
 .battle-screen .round-battle.phase-answer .textbook-question .pinyin-picture img{max-height:126px}
}
