:root{font-family:ui-rounded,"SF Pro Rounded",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#6d5145;background:#fff3e5;font-synthesis:none;text-rendering:optimizeLegibility}
*{box-sizing:border-box}
html,body{width:100%;height:100%;margin:0;overflow:hidden}
body{background:radial-gradient(ellipse at 10% 10%,rgba(255,190,156,.55),transparent 34%),radial-gradient(ellipse at 90% 86%,rgba(250,216,144,.6),transparent 34%),radial-gradient(ellipse at 80% 10%,rgba(255,226,195,.7),transparent 30%),#fff3e5;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
button{font:inherit;cursor:pointer;touch-action:manipulation}
button:focus-visible,a:focus-visible{outline:3px solid #79bda7;outline-offset:4px}
.app{position:relative;isolation:isolate;width:100%;height:100dvh;min-height:0;padding:calc(env(safe-area-inset-top) + 9px) calc(env(safe-area-inset-right) + 20px) calc(env(safe-area-inset-bottom) + 10px) calc(env(safe-area-inset-left) + 20px);display:flex;flex-direction:column;gap:8px;overflow:hidden}
.app:before,.app:after{position:absolute;z-index:-1;content:"";border-radius:50%;pointer-events:none;filter:blur(2px)}
.app:before{width:180px;height:180px;left:-105px;top:36%;background:#f8c7b5;opacity:.42}
.app:after{width:220px;height:220px;right:-125px;top:8%;background:#f5d89a;opacity:.52}
.topbar{height:42px;flex:0 0 auto;display:flex;align-items:center;justify-content:flex-end}.topbar-spacer{flex:1}
.bottom-brand{height:30px;flex:0 0 30px;display:inline-flex;align-items:center;align-self:center;justify-content:center;color:rgba(137,105,84,.82);font-size:20px;line-height:1;font-weight:750;letter-spacing:.015em;text-decoration:none;text-shadow:0 1px 0 rgba(255,255,255,.75);white-space:nowrap;opacity:.82;transition:opacity .16s ease}.bottom-brand:active{opacity:.58}
.bottom-brand .brand-i{display:inline-block;margin:0 .055em;font-size:1.22em;font-weight:900;line-height:.9}
.bottom-brand .brand-i-1{color:#ff827a}.bottom-brand .brand-i-2{color:#ffd166}.bottom-brand .brand-i-3{color:#65d9ef}.bottom-brand .brand-i-4{color:#c7a6ff}

.icon-button{display:grid;place-items:center;width:42px;height:42px;border:1px solid rgba(220,181,151,.58);border-radius:16px;background:rgba(255,255,255,.72);color:#9a7661;box-shadow:0 4px 12px rgba(147,100,70,.08);transition:transform .16s ease,background .16s ease}
.icon-button:active,.choice-button:active,.level-button:active{transform:scale(.92)}
.icon-button svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.sound-button{justify-self:end}
.sound-button .speaker-off{display:none}
.sound-button[aria-pressed="false"] .speaker-on{display:none}
.sound-button[aria-pressed="false"] .speaker-off{display:block}
.game-area{flex:1;min-height:0;width:min(100%,780px);margin:0 auto;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:clamp(8px,2vh,18px)}
.status-row{height:clamp(48px,8vh,68px);width:min(100%,540px);display:flex;align-items:center;justify-content:center;gap:12px}.player-avatar{width:42px;height:42px;display:grid;place-items:center;border:1px solid rgba(229,198,170,.75);border-radius:15px;background:rgba(255,255,255,.72);opacity:.72;transition:transform .16s ease,opacity .16s ease,border-color .16s ease}.player-avatar.active{opacity:1;border-color:#e8bb69;box-shadow:0 3px 10px rgba(225,184,100,.18);transform:translateY(-2px)}.animal-sprite{display:block;width:100%;height:100%;background-image:url("./avatars.webp");background-repeat:no-repeat;background-size:200% 200%;border-radius:inherit}
.animal-rabbit{background-position:0% 0%}.animal-cat{background-position:100% 0%}.animal-bear{background-position:0% 100%}.animal-fox{background-position:100% 100%}
.animal-robot{position:relative;isolation:isolate;display:block;overflow:hidden;border:2px solid #7ca9a8;border-radius:inherit;background:radial-gradient(circle at 50% 8%,#f2c66f 0 4%,transparent 4.8%),linear-gradient(180deg,transparent 0 11%,#79a6a6 11% 15%,transparent 15%),linear-gradient(145deg,#e5f7f3,#b8dfdc)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.9)}
.animal-robot::before{content:"";position:absolute;inset:14% 9% 9%;border:3px solid #759da0;border-radius:25%;background:radial-gradient(ellipse at 31% 42%,#355b61 0 7%,transparent 8%),radial-gradient(ellipse at 69% 42%,#355b61 0 7%,transparent 8%),linear-gradient(145deg,#fff,#d5eeea);box-shadow:inset 0 -5px 0 rgba(89,151,151,.14),0 3px 0 rgba(64,105,108,.14)}
.animal-robot::after{content:"";position:absolute;left:38%;top:66%;width:24%;height:10%;border-bottom:3px solid #456e72;border-radius:0 0 50% 50%}
.animal-robot[data-expression="easy"]::after{top:66%;height:10%;border-bottom:3px solid #456e72;border-radius:0 0 50% 50%}
.animal-robot[data-expression="hard"]::before{background:linear-gradient(165deg,transparent 0 35%,#456e72 36% 40%,transparent 41%) 17% 30%/34% 22% no-repeat,linear-gradient(195deg,transparent 0 35%,#456e72 36% 40%,transparent 41%) 83% 30%/34% 22% no-repeat,radial-gradient(ellipse at 31% 45%,#355b61 0 6%,transparent 7%),radial-gradient(ellipse at 69% 45%,#355b61 0 6%,transparent 7%),linear-gradient(145deg,#fff,#d5eeea)}
.animal-robot[data-expression="hard"]::after{top:69%;height:0;border-bottom:3px solid #456e72;border-radius:0}
.animal-robot[data-expression="win"]::before{background:radial-gradient(ellipse at 31% 43%,#355b61 0 6%,transparent 7%),radial-gradient(ellipse at 69% 43%,#355b61 0 6%,transparent 7%),radial-gradient(circle at 34% 39%,#fff 0 1.8%,transparent 2.4%),radial-gradient(circle at 72% 39%,#fff 0 1.8%,transparent 2.4%),linear-gradient(145deg,#fff,#d5eeea)}
.animal-robot[data-expression="win"]::after{top:61%;height:19%;border:3px solid #456e72;border-top:0;background:#ef998e;border-radius:0 0 50% 50%}
.animal-robot[data-expression="lose"]::before{background:radial-gradient(ellipse at 31% 42%,#355b61 0 6%,transparent 7%),radial-gradient(ellipse at 69% 42%,#355b61 0 6%,transparent 7%),radial-gradient(ellipse at 25% 61%,#62b9d0 0 3.5%,transparent 4.5%),radial-gradient(ellipse at 75% 61%,#62b9d0 0 3.5%,transparent 4.5%),linear-gradient(145deg,#fff,#d5eeea)}
.animal-robot[data-expression="lose"]::after{top:69%;height:8%;border-bottom:0;border-top:3px solid #456e72;border-radius:50% 50% 0 0}
.animal-robot[data-expression="draw"]::after{top:69%;height:0;border-bottom:3px solid #456e72;border-radius:0}
.player-avatar .animal-sprite{width:34px;height:34px}
.turn-avatar{appearance:none;-webkit-appearance:none;width:62px;height:62px;display:grid;place-items:center;border-radius:21px;background:linear-gradient(145deg,#fffefa,#fff4e8);border:2px solid rgba(232,190,126,.8);box-shadow:0 7px 18px rgba(150,105,76,.14),inset 0 1px 0 #fff;padding:2px;cursor:pointer;transition:transform .18s ease,box-shadow .18s ease,border-color .18s ease}.turn-avatar:active{transform:scale(.93)}.turn-avatar:disabled{cursor:default;opacity:1}.turn-avatar:focus-visible{outline:3px solid #79bda7;outline-offset:4px}.turn-avatar .animal-sprite{width:100%;height:100%}
.turn-avatar.pop{animation:avatar-pop .42s cubic-bezier(.2,.8,.2,1.3)}
.avatar-flower{color:#eb9a87}.avatar-heart{color:#81bca5}
.turn-stars{display:flex;gap:7px;color:#e7bb65;font-size:13px;opacity:.8}
.status-face{width:36px;height:36px;display:grid;place-items:center;border-radius:50%;background:#ffdfb0;color:#a87654;font-size:21px;font-weight:900;transition:transform .2s ease}
.board-wrap{position:relative;width:min(100%,min(66vh,520px));aspect-ratio:1;display:grid;place-items:center}
.board-glow{position:absolute;inset:7%;border-radius:36px;background:rgba(247,196,160,.25);filter:blur(22px)}
.board{position:relative;width:100%;height:100%;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(3,minmax(0,1fr));gap:10px;padding:13px;border:1px solid rgba(231,198,169,.85);border-radius:30px;background:rgba(255,253,248,.82);box-shadow:0 20px 52px rgba(153,105,73,.14),inset 0 1px 0 rgba(255,255,255,.9)}
.cell{position:relative;display:grid;place-items:center;min-width:0;min-height:0;border:1px solid #f2dfcf;border-radius:22px;background:linear-gradient(145deg,#fffefa,#fff8f0);color:#e99483;box-shadow:0 4px 0 #f0dfd0,inset 0 1px 0 #fff;transition:transform .16s ease,background .18s ease,border-color .18s ease,box-shadow .18s ease}
.cell:not(:disabled):active{transform:scale(.94);background:#fff0e4}
.cell:disabled{cursor:default}
.cell.mark-x{color:#e99382;background:linear-gradient(145deg,#fff8f3,#fff0e9)}
.cell.mark-o{color:#7db9a5;background:linear-gradient(145deg,#f7fff8,#eaf6ed)}
.cell.is-win{border-color:#edc56e;background:#fff2ce;box-shadow:0 4px 0 #e8d4a5,0 0 0 4px rgba(237,197,110,.18);animation:win-pop .46s ease both}
.piece{display:block;width:76%;height:76%;border-radius:24%;filter:drop-shadow(0 4px 1px rgba(120,82,54,.1));animation:piece-in .24s cubic-bezier(.2,.8,.2,1.3) both}.score-mark{width:22px;height:22px;border-radius:7px;flex:0 0 22px}
.hand-hint{position:absolute;z-index:2;left:50%;top:50%;font-size:clamp(25px,5vh,38px);filter:drop-shadow(0 3px 3px rgba(120,82,54,.2));pointer-events:none;animation:point-tap 1.5s ease-in-out infinite;opacity:.9}
.hand-hint.hidden{display:none}
.score-row{width:min(100%,380px);display:flex;align-items:center;justify-content:center;gap:clamp(14px,5vw,34px)}
.score-pill,.score-draw{height:39px;min-width:76px;padding:0 13px;display:flex;align-items:center;justify-content:center;gap:9px;border:1px solid rgba(229,198,170,.72);border-radius:14px;background:rgba(255,255,255,.68);box-shadow:0 4px 12px rgba(147,100,70,.06)}

.score-pill strong,.score-draw strong{font-size:16px;font-weight:900;color:#876b59;font-variant-numeric:tabular-nums}
.score-draw{min-width:56px;background:rgba(255,248,236,.72);color:#d9ae65}.score-draw span{font-size:18px}
.controls{height:76px;flex:0 0 auto;width:min(100%,480px);margin:0 auto;display:flex;align-items:center;justify-content:center;gap:clamp(14px,4vw,26px);padding:7px 12px;border:1px solid rgba(229,198,170,.68);border-radius:23px;background:rgba(255,255,255,.64);box-shadow:0 8px 24px rgba(147,100,70,.08)}
.control-group{display:flex;align-items:center;gap:9px}
.choice-button{position:relative;width:48px;height:48px;display:grid;place-items:center;border:1px solid #eddfd1;border-radius:16px;background:#fffaf4;color:#b49a86;transition:transform .16s ease,background .16s ease,border-color .16s ease}
.choice-button svg{width:29px;height:29px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.choice-button.active{border-color:#e9a18f;background:#fff0e8;color:#df8e7c;box-shadow:0 3px 10px rgba(223,142,124,.16)}
.choice-button .choice-dot{position:absolute;bottom:4px;width:5px;height:5px;border-radius:50%;background:transparent}
.choice-button.active .choice-dot{background:#e79a86}
.control-divider{width:1px;height:36px;background:#ead9c9}
.level-group{gap:7px}
.level-button{width:42px;height:42px;border:1px solid #eddfd1;border-radius:14px;background:#fffaf4;font-size:22px;filter:saturate(.82);transition:transform .16s ease,background .16s ease,border-color .16s ease}
.level-button.active{border-color:#e8c06f;background:#fff4d8;box-shadow:0 3px 9px rgba(225,184,100,.15)}
.restart-button{width:48px;height:48px;border-radius:16px;background:#f2a18e;border-color:#e99382;color:white;box-shadow:0 4px 0 #dc8978,0 7px 14px rgba(220,137,120,.18)}
.restart-button:active{transform:translateY(2px) scale(.96);box-shadow:0 2px 0 #dc8978}
.confetti{position:absolute;inset:0;z-index:3;pointer-events:none;overflow:hidden}
.confetti i{position:absolute;top:-18px;width:9px;height:13px;border-radius:4px;animation:confetti-fall 1.45s ease-in forwards}
.toast{position:absolute;left:50%;top:50%;z-index:4;display:flex;gap:13px;color:#e6b75f;font-size:32px;opacity:0;pointer-events:none;transform:translate(-50%,-50%) scale(.5)}
.toast.show{animation:toast-pop .85s ease both}
@keyframes piece-in{from{opacity:0;transform:scale(.45) rotate(-20deg)}to{opacity:1;transform:scale(1) rotate(0)}}
@keyframes avatar-pop{0%{transform:scale(1)}40%{transform:scale(1.2) rotate(-7deg)}100%{transform:scale(1)}}
@keyframes win-pop{0%{transform:scale(1)}45%{transform:scale(1.055)}100%{transform:scale(1)}}
@keyframes point-tap{0%,100%{transform:translate(-50%,-20%) scale(1)}45%{transform:translate(-50%,5%) scale(.9)}}
@keyframes confetti-fall{to{transform:translateY(110vh) rotate(520deg);opacity:0}}
@keyframes toast-pop{0%{opacity:0;transform:translate(-50%,-50%) scale(.4)}25%{opacity:1;transform:translate(-50%,-50%) scale(1.2)}75%{opacity:1;transform:translate(-50%,-50%) scale(1)}100%{opacity:0;transform:translate(-50%,-50%) scale(.8)}}
.animal-picker{position:absolute;z-index:6;top:calc(env(safe-area-inset-top) + 104px);left:50%;transform:translateX(-50%);display:flex;gap:8px;padding:8px;border:1px solid rgba(229,198,170,.8);border-radius:20px;background:rgba(255,253,248,.96);box-shadow:0 10px 28px rgba(120,82,54,.16)}.animal-picker button{width:48px;height:48px;padding:5px;border:1px solid #eddfd1;border-radius:15px;background:#fffaf4}.animal-picker button:active{transform:scale(.92)}.animal-picker .animal-sprite{width:100%;height:100%}
@media(max-width:760px) and (orientation:portrait){
 .app{padding-left:12px;padding-right:12px;gap:5px}.topbar{height:36px}.bottom-brand{height:26px;flex-basis:26px;font-size:18px}.icon-button{width:36px;height:36px;border-radius:13px}
 .game-area{gap:clamp(6px,1.3vh,12px)}
 .status-row{height:44px;gap:8px}.player-avatar{width:37px;height:37px;border-radius:13px}.player-avatar .animal-sprite{width:30px;height:30px}.turn-avatar{width:54px;height:54px;border-radius:18px;padding:1px}.status-face{width:31px;height:31px;font-size:18px}
 .board-wrap{width:min(100%,min(60vh,90vw,470px))}
 .board{padding:9px;gap:7px;border-radius:23px}.cell{border-radius:16px}.piece{width:79%;height:79%}
 .score-row{gap:13px}.score-pill,.score-draw{height:32px;min-width:65px;padding:0 10px;border-radius:12px}.score-mark,.score-draw span{font-size:15px}.score-pill strong,.score-draw strong{font-size:14px}
 .controls{height:66px;padding:6px 10px;border-radius:19px;gap:clamp(10px,3.5vw,20px)}.choice-button{width:43px;height:43px;border-radius:14px}.choice-button svg{width:26px;height:26px}.level-button{width:38px;height:38px;font-size:20px}.restart-button{width:43px;height:43px}
}
@media(max-width:390px) and (orientation:portrait){
 .app{padding-left:8px;padding-right:8px}.board-wrap{width:min(100%,min(58vh,91vw,410px))}.board{gap:6px;padding:7px}.cell{border-radius:13px}.controls{gap:9px;padding:5px 7px}.control-group{gap:6px}.choice-button{width:40px;height:40px}.level-button{width:35px;height:35px}.restart-button{width:40px;height:40px}.score-row{gap:8px}
}
@media(orientation:landscape) and (max-height:560px){
 .app{padding-top:5px;padding-bottom:5px;gap:4px}.topbar{height:30px}.bottom-brand{height:22px;flex-basis:22px;font-size:16px}.icon-button{width:30px;height:30px}
 .game-area{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto 1fr auto;gap:5px 16px;max-width:900px}
 .status-row{grid-column:1;grid-row:1;height:32px;justify-content:flex-start}
 .turn-avatar{width:46px;height:46px;padding:1px;border-radius:15px}.player-avatar{width:30px;height:30px;padding:3px;border-radius:10px}.player-avatar .animal-sprite{width:24px;height:24px}.status-face{width:26px;height:26px;font-size:15px}
 .board-wrap{grid-column:2;grid-row:1 / span 3;width:min(82vh,440px);height:min(82vh,440px)}
 .board{padding:7px;gap:6px;border-radius:19px}.cell{border-radius:12px}.piece{width:78%;height:78%}
 .score-row{grid-column:1;grid-row:2;justify-content:flex-start;align-self:center}
 .controls{grid-column:1;grid-row:3;height:55px;width:auto;justify-content:flex-start;padding:5px 8px;gap:10px}
 .choice-button{width:35px;height:35px;border-radius:11px}.choice-button svg{width:22px;height:22px}.level-button{width:32px;height:32px;font-size:17px}.restart-button{width:35px;height:35px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}

[hidden]{display:none!important}

.score-mark.animal-robot{border-width:1px;border-radius:7px}

/* Scoreboard portraits are direct avatar-picker controls. */
.score-avatar-button{appearance:none;-webkit-appearance:none;flex:0 0 28px;width:28px;height:28px;padding:0;border:0;border-radius:8px;background-color:transparent;cursor:pointer;touch-action:manipulation;transition:transform .16s ease,filter .16s ease}
.score-avatar-button:active{transform:scale(.88)}
.score-avatar-button:focus-visible{outline:3px solid #79bda7;outline-offset:3px}
@media(max-width:760px) and (orientation:portrait){.score-avatar-button{width:27px;height:27px;flex-basis:27px}}
