* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #111; color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
:root { --meme: Impact, "Arial Black", "Anton", "Haettenschweiler", sans-serif; --y: #ffd400; }

/* ---------- panels ---------- */
.panel { position: fixed; inset: 0; z-index: 30; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#menu { background: radial-gradient(ellipse at center, rgba(0,0,0,.05), rgba(0,0,0,.55)); gap: 14px; }
.title { font-family: var(--meme); font-size: clamp(54px, 12vw, 140px); line-height: .9; text-align: center; color: #fff;
  -webkit-text-stroke: 3px #000; text-shadow: 0 6px 0 #000, 0 0 40px rgba(0,0,0,.5); letter-spacing: 2px; transform: rotate(-3deg); }
.title span { display: block; }
.title span:last-child { color: var(--y); animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 0%,100% { transform: rotate(0) scale(1); } 50% { transform: rotate(2deg) scale(1.04); } }
.tagline { font-family: var(--meme); font-size: clamp(18px, 3vw, 28px); -webkit-text-stroke: 1px #000; text-shadow: 0 3px 0 #000; margin-bottom: 18px; }
.btns { display: flex; flex-direction: column; gap: 10px; align-items: center; }
button { font-family: var(--meme); font-size: 22px; letter-spacing: 1px; padding: 10px 26px; min-width: 200px; border: 3px solid #000;
  background: #fff; color: #111; border-radius: 12px; cursor: pointer; box-shadow: 0 5px 0 #000; transition: transform .08s; }
button:hover { transform: translateY(-2px) rotate(-1deg); }
button:active { transform: translateY(3px); box-shadow: 0 2px 0 #000; }
button.big { background: var(--y); font-size: 30px; padding: 12px 40px; }
.card { background: #fff; color: #111; border: 4px solid #000; border-radius: 20px; padding: 26px 30px; box-shadow: 0 10px 0 #000;
  max-width: min(560px, 92vw); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.card h2 { font-family: var(--meme); font-size: 42px; letter-spacing: 1px; }
.card h3 { font-family: var(--meme); font-size: 24px; color: #c0392b; }
.card p { font-size: 17px; line-height: 1.4; }
.card p.small { font-size: 14px; color: #555; }
.panel:not(#menu) { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; text-align: left; margin: 4px 0 8px; }
.keys div { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.keys span { margin-left: 4px; }
kbd { display: inline-block; min-width: 26px; padding: 2px 7px; border: 2px solid #111; border-bottom-width: 4px; border-radius: 7px;
  background: #f3f3f3; font: bold 13px system-ui, sans-serif; text-align: center; color: #111; }
.touch-only { display: none; }
body.touch .touch-only { display: grid; }
body.touch .desktop-only { display: none; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 18px; font-weight: 700; }
.flags { display: flex; gap: 10px; }
.flag { min-width: 0; padding: 4px; width: 74px; height: 52px; background: #eee; box-shadow: 0 3px 0 #000; opacity: .5; }
.flag.active { opacity: 1; background: var(--y); }
.flag svg { width: 100%; height: 100%; display: block; border-radius: 4px; }
.seg { display: flex; gap: 6px; }
.seg button, #musicBtn { min-width: 0; font-size: 16px; padding: 6px 12px; box-shadow: 0 3px 0 #000; }
.seg button.active { background: var(--y); }
input[type=range] { width: 180px; accent-color: #111; }
.credits .names { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 14px; }
.credits .names div { font-family: var(--meme); font-size: 40px; }
.credits .names div:nth-child(3) { color: #fff; background: #111; border-radius: 10px; padding: 2px 0; letter-spacing: 3px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#topbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.45); padding: 6px 10px; border-radius: 16px; }
#slots { display: flex; gap: 5px; }
.slot { width: 34px; height: 34px; border-radius: 50%; border: 2px dashed rgba(255,255,255,.55); display: grid; place-items: center;
  font: bold 16px system-ui; color: rgba(255,255,255,.6); }
.slot.found { border: 2px solid var(--y); background: rgba(255,212,0,.25); font-size: 19px; color: #fff; }
.slot.pop { animation: pop .6s cubic-bezier(.2,2,.4,1); }
@keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(1.7); } 100% { transform: scale(1); } }
#count { font-family: var(--meme); font-size: 26px; color: var(--y); -webkit-text-stroke: 1px #000; min-width: 56px; text-align: center; }
.bump { animation: bump .5s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.6); color: #fff; } 100% { transform: scale(1); } }
#topright { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  font-family: var(--meme); font-size: 22px; text-shadow: 0 2px 0 #000; }
#memeCount { display: inline-block; }
#viewfinder { position: absolute; left: 50%; top: 50%; width: 46vmin; height: 36vmin; transform: translate(-50%, -50%); }
#viewfinder i { position: absolute; width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.8); }
#viewfinder i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
#viewfinder i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
#viewfinder i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
#viewfinder i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
#viewfinder b { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
#keysHint { position: absolute; left: 14px; bottom: 14px; font-size: 14px; opacity: .8; display: flex; gap: 8px; align-items: center; }
body.touch #keysHint { display: none; }

/* tinfoil vision */
#folyoFx { position: absolute; inset: 0; opacity: 0; transition: opacity .3s; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(120,0,180,.45) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 2px, transparent 2px 4px); }
body.folyo #folyoFx { opacity: 1; }
#folyoFx .brim { position: absolute; top: -6vh; left: -5%; right: -5%; height: 14vh; border-radius: 0 0 50% 50%;
  background: conic-gradient(from 0deg, #bbb, #fff, #999, #eee, #aaa, #fff, #bbb); filter: contrast(1.3) drop-shadow(0 6px 6px rgba(0,0,0,.5));
  animation: shimmer 3s linear infinite; }
@keyframes shimmer { to { filter: contrast(1.3) hue-rotate(360deg) drop-shadow(0 6px 6px rgba(0,0,0,.5)); } }
#folyoFx .label { position: absolute; top: 10vh; left: 50%; transform: translateX(-50%); font-family: var(--meme); font-size: 20px;
  color: #e9b8ff; letter-spacing: 4px; text-shadow: 0 0 10px #a0f; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .4; } }

/* bubbles */
#bubbles { position: absolute; inset: 0; overflow: hidden; }
.bubble { position: absolute; left: 0; top: 0; max-width: 260px; padding: 8px 12px; background: #fff; color: #111; border: 3px solid #111;
  border-radius: 16px; font: 700 15px/1.25 system-ui, sans-serif; text-align: center; transform-origin: 50% 100%; display: none; white-space: normal; width: max-content; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -12px; margin-left: -8px; border: 8px solid transparent; border-top-color: #111; }

/* toasts */
#toasts { position: absolute; left: 50%; bottom: 13vh; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.toast { background: rgba(0,0,0,.8); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 700; font-size: 17px; max-width: 86vw; text-align: center;
  animation: tin .25s cubic-bezier(.2,1.6,.4,1); border: 2px solid rgba(255,255,255,.2); }
.toast.out { opacity: 0; transform: translateY(10px); transition: all .3s; }
.toast.hint { background: rgba(30,60,140,.9); }
.toast.meme { background: #ffd400; color: #111; border-color: #111; font-family: var(--meme); font-size: 22px; letter-spacing: 1px; }
.toast.gold { background: linear-gradient(90deg, #ffd400, #ff8c1a); color: #111; font-family: var(--meme); font-size: 22px; }
.toast.red { background: #c0392b; }
.toast.bw { background: repeating-linear-gradient(90deg, #111 0 16px, #fff 16px 32px); color: #fff; -webkit-text-stroke: 1px #000;
  font-family: var(--meme); font-size: 26px; text-shadow: 0 2px 0 #000; padding: 12px 26px; }
@keyframes tin { from { transform: scale(.5); opacity: 0; } }

/* polaroid */
#polaroid { position: absolute; right: 24px; top: 50%; width: 280px; background: #fff; color: #111; padding: 12px 12px 14px; box-shadow: 0 14px 40px rgba(0,0,0,.5);
  transform: translate(140%, -50%) rotate(12deg); transition: transform .5s cubic-bezier(.2,1.4,.4,1); }
#polaroid.show { transform: translate(0, -50%) rotate(-4deg); }
#polaroid img { width: 100%; aspect-ratio: 4/3; display: block; background: #222; }
#polaroid .ptitle { font-family: var(--meme); font-size: 22px; margin-top: 8px; line-height: 1.1; }
#polaroid .pcap { font-size: 14px; color: #444; margin-top: 4px; font-style: italic; }
#polaroid .stamp { position: absolute; top: 34px; left: 50%; transform: translateX(-50%) rotate(-14deg) scale(1); font-family: var(--meme); font-size: 46px;
  color: #e3002b; border: 5px solid #e3002b; border-radius: 10px; padding: 0 12px; background: rgba(255,255,255,.75); z-index: 2; letter-spacing: 2px; }
#polaroid.show .stamp { animation: stamp .45s .35s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes stamp { from { transform: translateX(-50%) rotate(-14deg) scale(3); opacity: 0; } }
@media (max-width: 700px) { #polaroid { width: 190px; right: 10px; } #polaroid .ptitle { font-size: 17px; } #polaroid .stamp { font-size: 30px; } }

#useBtn { position: absolute; left: 50%; bottom: 13vh; transform: translateX(-50%); pointer-events: auto; animation: wobble 1.2s infinite; z-index: 5; }
#useBtn kbd { vertical-align: middle; }
body.touch #useBtn kbd { display: none; }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 20; }
#flash.go { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 21; }
body.shake #game { animation: shake .4s; }
@keyframes shake { 20% { transform: translate(-8px, 4px); } 40% { transform: translate(7px, -5px); } 60% { transform: translate(-5px, 3px); } 80% { transform: translate(3px, -2px); } }
#clickToPlay { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; background: rgba(0,0,0,.35); cursor: pointer; }
#clickToPlay span { font-family: var(--meme); font-size: 40px; background: var(--y); color: #111; padding: 10px 30px; border: 4px solid #000; border-radius: 14px; box-shadow: 0 6px 0 #000; }

/* touch controls */
#touchArea, #joy, #touchBtns, #tHint, #tPause { display: none; }
body.touch #touchArea { display: block; position: absolute; inset: 0; pointer-events: auto; }
body.touch #joy { display: block; position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 3px solid rgba(255,255,255,.4); left: 40px; bottom: 40px; top: auto; opacity: .5; }
body.touch #joy.on { opacity: 1; bottom: auto; }
#joyKnob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.7); }
body.touch #touchBtns { display: flex; position: absolute; right: 18px; bottom: 22px; gap: 12px; align-items: flex-end; pointer-events: auto; }
#touchBtns button, #tHint, #tPause { min-width: 0; width: 64px; height: 64px; padding: 0; border-radius: 50%; font-size: 28px; font-family: system-ui; background: rgba(255,255,255,.88); }
#touchBtns #tPhoto { width: 86px; height: 86px; font-size: 38px; background: var(--y); }
body.touch #tHint { display: block; position: absolute; left: 14px; top: 64px; width: 48px; height: 48px; font-size: 22px; pointer-events: auto; }
body.touch #tPause { display: block; position: absolute; left: 14px; top: 10px; width: 48px; height: 48px; font-size: 20px; pointer-events: auto; }
body.touch #topbar { top: 6px; transform: translateX(-50%) scale(.8); transform-origin: top center; }
body.touch #topright { top: 64px; }

/* ending */
#whiteout { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 1.2s; z-index: 22; }
#whiteout.on { opacity: 1; }
#aiScreen { position: fixed; inset: 0; z-index: 23; background: #000; display: flex; align-items: center; justify-content: center; padding: 8vw;
  animation: fadein 1.5s; }
#aiText { font-family: "Courier New", ui-monospace, monospace; font-size: clamp(22px, 4vw, 46px); color: #3dff6e; text-align: center; text-shadow: 0 0 12px #3dff6e; }
.cursor { color: #3dff6e; font-size: clamp(22px, 4vw, 46px); animation: blink 1s steps(2) infinite; }
@keyframes fadein { from { opacity: 0; } }
#endPanel { z-index: 24; background: rgba(0,0,0,.4) !important; }
.endTitle { font-size: 64px !important; }
.stats { display: flex; justify-content: center; gap: 22px; margin-bottom: 8px; }
.stats div { display: flex; flex-direction: column; font-size: 14px; color: #555; }
.stats b { font-family: var(--meme); font-size: 32px; color: #111; }
#aiScreen.up { align-items: flex-start; padding-top: 9vh; transition: padding .6s; }
#endPanel.panel { backdrop-filter: none; background: transparent !important; justify-content: flex-end; padding-bottom: 5vh; }
#aiScreen.up #aiText, #aiScreen.up .cursor { font-size: clamp(18px, 2.6vw, 30px); }
.bubble span { display: block; }
.bubble small { display: block; font-weight: 600; font-size: 12px; color: #555; margin-top: 3px; }
.bubble small:empty { display: none; }
#useBtn.small { font-size: 18px; padding: 6px 16px; min-width: 0; animation: none; opacity: .85; bottom: 3vh; }
#game::after { content: ''; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.28) 100%); }
#aiScreen { flex-direction: column; gap: 28px; }
#aiScreen .aiLine { display: flex; align-items: center; justify-content: center; }
#aiCredits { text-align: center; color: #3dff6e; font-family: "Courier New", ui-monospace, monospace; opacity: 0; animation: fadein 1.2s 3.2s forwards; }
#aiCredits small { display: block; font-size: 14px; letter-spacing: 6px; opacity: .7; margin-bottom: 6px; }
#aiCredits div { font-size: clamp(18px, 2.6vw, 28px); text-shadow: 0 0 10px #3dff6e; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
#aiScreen.up { justify-content: flex-start; align-items: center; padding-top: 6vh; gap: 14px; }
#endPanel .card { gap: 8px; padding: 18px 26px; }
@media (max-height: 760px) { #endPanel .card { transform: scale(.82); transform-origin: bottom center; } .endTitle { font-size: 48px !important; } }
.sensBox { display: flex; align-items: center; gap: 8px; } .sensBox b { min-width: 42px; font-size: 15px; }
#rotate { display: none; }
@media (orientation: portrait) { body.touch #rotate { display: flex; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.88); color: #fff; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 30px; font-family: var(--meme); font-size: 22px; }
  body.touch #rotate div { font-size: 64px; animation: wobble 1.6s infinite; } }
body.touch .keys { grid-template-columns: 1fr; }
body.touch #useBtn { bottom: auto; top: 46%; left: auto; right: 18px; transform: none; font-size: 22px; padding: 10px 18px; min-width: 0; }
body.touch #useBtn.small { top: 30%; bottom: auto; }
/* short screens (phones in landscape) */
.card > button.big, .card > .backBtn { position: sticky; bottom: 0; z-index: 2; }
@media (max-height: 520px) {
  .card { padding: 12px 18px; gap: 6px; max-height: 96vh; border-width: 3px; box-shadow: 0 5px 0 #000; max-width: min(640px, 94vw); }
  .card h2 { font-size: 26px; } .card h3 { font-size: 16px; } .card p { font-size: 13px; line-height: 1.3; } .card p.small { font-size: 11px; }
  .keys, body.touch .keys { grid-template-columns: 1fr 1fr; gap: 3px 10px; margin: 2px 0; }
  .keys div { font-size: 12px; } kbd { font-size: 11px; min-width: 22px; padding: 1px 5px; }
  button { font-size: 17px; padding: 6px 18px; min-width: 150px; } button.big { font-size: 22px; padding: 7px 26px; }
  .title { font-size: clamp(40px, 9vw, 80px); } .tagline { font-size: 16px; margin-bottom: 6px; } .btns { gap: 6px; }
  .row { font-size: 14px; } .flag { width: 54px; height: 38px; } .credits .names div { font-size: 28px; }
  #polaroid { width: 170px; } #polaroid .ptitle { font-size: 15px; } #polaroid .pcap { font-size: 11px; } #polaroid .stamp { font-size: 26px; top: 20px; }
  .toast { font-size: 13px; padding: 7px 12px; } .toast.meme, .toast.gold { font-size: 17px; }
  .bubble { font-size: 12px; max-width: 200px; padding: 6px 9px; }
}
body.touch #useBtn, body.touch #useBtn.small { top: 12px; left: 74px; right: auto; bottom: auto; transform: none; font-size: 18px; padding: 8px 16px; min-width: 0; animation: none; opacity: 1; }
body.touch #useBtn:not(.small) { animation: wobble 1.2s infinite; }
