* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Verdana, Geneva, Tahoma, sans-serif; color: #111; background: #3a7bd5 url(wall.jpg) center / cover no-repeat fixed; padding: 26px 10px; min-height: 100vh; overflow-x: hidden; }
#desk { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.flag { position: absolute; width: 96px; height: 96px; image-rendering: pixelated; opacity: .45; will-change: transform; }
.px { position: fixed; z-index: 1; pointer-events: none; image-rendering: pixelated; animation: floatup 1.3s ease-out forwards; }
@keyframes floatup { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-70px) scale(.4); opacity: 0; } }
center { position: relative; z-index: 2; }

#box { border: 4px ridge #ff66cc; background: #fffbe6; box-shadow: 8px 8px 0 #000; }
#hdr { background: #ff3399; border-bottom: 4px ridge #ff66cc; text-align: center; letter-spacing: 1px; }
#hdr font[size="6"] { text-shadow: 3px 3px 0 #000; }
#main { text-align: center; background: #fffbe6; }

#face { position: relative; width: 240px; height: 240px; margin: 4px auto 10px; cursor: pointer; perspective: 600px; }
#head { position: relative; width: 240px; height: 240px; transition: transform .6s ease; will-change: transform; }
#face .fr { position: absolute; left: 0; top: 0; width: 240px; height: 240px; opacity: 0; background: transparent; user-select: none; -webkit-user-drag: none; transition: opacity .09s linear; }
#face .fr.base { opacity: 1; }
#face .fr.mouth { clip-path: inset(52% 33% 24% 35%); }
#face .fr.eyes { clip-path: inset(29% 24% 53% 28%); }
#face .fr.blinkf { transition: opacity .05s linear; }
#face .fr.thinkf { transition: opacity .28s ease; }
#face .fr.smile { transition: opacity .25s ease; }
#face .fr.show { opacity: 1; }
#face.idle #head { animation: sway 5s ease-in-out infinite; }
#face.thinking #head { animation: bob 1.4s ease-in-out infinite; }
#face.speaking #head { animation: talk 2.2s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: rotate(-1deg) translateY(0); } 50% { transform: rotate(1deg) translateY(2px); } }
@keyframes bob { 0%,100% { transform: rotate(-2deg) translateX(-3px); } 50% { transform: rotate(-3deg) translateX(-5px) translateY(-2px); } }
#face.cool #head { animation: spin .9s cubic-bezier(.2,.8,.2,1) 1; }
@keyframes spin { 0% { transform: rotateY(0) scale(1); } 50% { transform: rotateY(180deg) scale(1.08); } 100% { transform: rotateY(360deg) scale(1); } }
#shades { position: absolute; left: 62px; top: -80px; width: 118px; height: 32px; z-index: 5; opacity: 0; transition: top .45s cubic-bezier(.3,1.4,.5,1), opacity .2s; pointer-events: none; }
#face.shades #shades { top: 76px; opacity: 1; }
.confetti { position: fixed; z-index: 9; width: 8px; height: 8px; pointer-events: none; animation: burst 1s ease-out forwards; }
@keyframes burst { 0% { transform: translate(0,0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
@keyframes talk { 0%,100% { transform: translateY(0) rotate(0deg); } 30% { transform: translateY(-2px) rotate(.8deg); } 70% { transform: translateY(1px) rotate(-.8deg); } }

#bubble { width: 100%; background: #ffff99; border: 3px outset #ffcc00; margin-bottom: 14px; }
#reply { font-family: "Comic Sans MS", "Comic Sans", "Trebuchet MS", sans-serif; font-size: 15px; line-height: 1.5; min-height: 22px; text-align: center; }
#reply.dim { color: #996600; font-style: italic; }

#f { display: flex; gap: 8px; align-items: center; }
#q { flex: 1; font: inherit; font-size: 16px; padding: 10px 12px; border: 3px inset #99ccff; background: #ffffff; outline: none; }
#q:focus { background: #e6f7ff; }
#mic { position: relative; width: 60px; height: 60px; flex: 0 0 60px; border: 3px outset #66ff66; background: #33cc33; color: #003300; cursor: pointer; padding: 0; }
#mic:active { border-style: inset; }
#mic svg { width: 32px; height: 32px; position: relative; z-index: 1; }
#mic .ring { position: absolute; inset: -3px; border: 3px solid #ff0000; opacity: 0; }
#mic.rec { background: #ff3333; color: #fff; border-color: #ff9999; }
#mic.rec .ring { animation: pulse 1.1s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
#mic.busy { opacity: .5; pointer-events: none; }

#status { color: #cc0066; font-size: 12px; font-weight: bold; margin: 10px 0 4px; min-height: 16px; }
#rule { border: 0; border-top: 3px dashed #ff66cc; margin: 16px 0 8px; }
#rule + #history:empty { display: none; }
#main { border-bottom: 4px ridge #ff66cc; }
#history { text-align: left; }
#history .item { padding: 8px 6px; border-bottom: 1px dotted #cc99ff; font-size: 13px; line-height: 1.45; }
#history .item:nth-child(odd) { background: #f3e6ff; }
#history .you { color: #3333cc; }
#history .you:before { content: "> "; color: #999; }
#history .me { margin-top: 2px; color: #222; }
#history .item a { color: #ff0066; font-size: 12px; margin-left: 6px; cursor: pointer; text-decoration: underline; }

#rule:has(+ #history:empty) { display: none; }
