:root {
  --ink: #2b2b3a; --paper: #fffef6; --cream: #f6efd9; --red: #e5484d; --blue: #3b82f6; --gold: #ffd93b; --green: #4cb782;
  --hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Marker Felt", "Comic Sans MS", "Comic Neue", cursive;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--cream); color: var(--ink); font-family: var(--sans); touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
#app { position: fixed; inset: 0; height: 100vh; height: 100dvh; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#vig { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 90px rgba(110, 80, 30, .28), inset 0 0 12px rgba(110, 80, 30, .25); }
[hidden] { display: none !important; }

/* chip / butonlar */
.chip { position: absolute; z-index: 5; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 12px; margin: 0; color: var(--ink); background: rgba(255, 254, 246, .93); border: 2.5px solid var(--ink); border-radius: 14px 18px 12px 16px / 16px 12px 18px 14px; box-shadow: 2px 3px 0 var(--ink); font: 700 15px var(--hand); text-decoration: none; cursor: pointer; }
.chip:active { transform: translate(2px, 2px); box-shadow: 0 1px 0 var(--ink); }
.chip:focus-visible, .sticker:focus-visible, .linkbtn:focus-visible, #nick:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
#back { top: calc(var(--st) + 8px); left: calc(var(--sl) + 10px); letter-spacing: .04em; transform: rotate(-1.5deg); }
#snd { top: calc(var(--st) + 8px); right: calc(var(--sr) + 10px); padding: 0; transform: rotate(1.5deg); }
#snd .xx { display: none; }
#snd.off .xx { display: inline; } #snd.off .wav { display: none; }
#hud { position: absolute; z-index: 4; left: 0; right: 0; top: calc(var(--st) + 60px); display: flex; justify-content: center; gap: 8px; padding: 0 calc(var(--sr) + 10px) 0 calc(var(--sl) + 10px); pointer-events: none; }
#hud .chip { position: static; pointer-events: auto; }
#hud .stat { flex-direction: column; gap: 0; padding: 2px 12px; line-height: 1.1; min-width: 78px; pointer-events: none; }
#hud .stat .lbl { font: 700 9px var(--sans); letter-spacing: .14em; opacity: .65; }
#hud .stat span:last-child { font-size: 20px; }
#starChip span:last-child { color: #c98a00; }
.shieldchip { background: #ffe1e5 !important; color: var(--red); font-size: 14px; animation: pulse 1.2s ease-in-out infinite; }
#pauseBtn { padding: 0; }
#hint { position: absolute; z-index: 4; left: 50%; bottom: calc(var(--sb) + 8%); transform: translateX(-50%) rotate(-1deg); font: 700 18px var(--hand); background: rgba(255, 254, 246, .92); border: 2.5px dashed var(--ink); border-radius: 12px; padding: 8px 16px; white-space: nowrap; pointer-events: none; animation: pulse 1.6s ease-in-out infinite; }
#banner { position: absolute; z-index: 6; left: 50%; top: 32%; transform: translate(-50%, 0) rotate(-6deg) scale(.6); font: 700 clamp(30px, 9vw, 58px) var(--hand); color: var(--red); border: 5px double var(--red); padding: 4px 22px 8px; border-radius: 10px; background: rgba(255, 254, 246, .55); opacity: 0; pointer-events: none; text-align: center; line-height: 1.05; white-space: nowrap; }
#banner small { display: block; font-size: .36em; letter-spacing: .12em; color: var(--ink); }
#banner.show { animation: bannerIn 2.2s ease-out forwards; }

/* ekranlar */
.screen { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: calc(var(--st) + 62px) calc(var(--sr) + 14px) calc(var(--sb) + 16px) calc(var(--sl) + 14px); overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.screen.center { justify-content: center; background: rgba(246, 239, 217, .55); }
.tcol { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tcol.right { align-items: center; }
#title > .tcol.left { margin-top: 0; }

/* logo */
#logo { width: min(86vw, 380px); height: auto; overflow: visible; }
.lt { font: 700 82px var(--hand); stroke-width: 2.4; stroke-linejoin: round; stroke-dasharray: 900; stroke-dashoffset: 900; fill-opacity: 0; animation: draw 1.7s ease-out forwards, fillin .7s ease-out 1.6s forwards; }
.l1 { stroke: var(--ink); fill: #8fb8ff; }
.l2 { stroke: var(--ink); fill: #ff8f8f; animation-delay: .55s, 2.1s; }
.ul { fill: none; stroke: var(--red); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 340; stroke-dashoffset: 340; animation: draw 1s ease-out 2.2s forwards; }
.pl { fill: #fff; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw 1s ease-out 2.6s forwards; }
.how { list-style: none; margin: 0; padding: 0; text-align: center; font: 700 16px/1.45 var(--hand); }
.how li { background: rgba(255, 254, 246, .8); border-radius: 10px; padding: 4px 10px; margin-bottom: 4px; }
.gold { color: #d99a00; } .red { color: var(--red); }
.nick { display: flex; flex-direction: column; gap: 4px; width: min(100%, 300px); font: 700 14px var(--hand); text-align: left; }
.nick input { font: 700 20px var(--hand); text-align: center; min-height: 48px; width: 100%; border: 3px solid var(--ink); border-radius: 14px 18px 12px 16px / 16px 12px 18px 14px; background: #fff; color: var(--ink); padding: 6px 12px; -webkit-user-select: text; user-select: text; box-shadow: inset 0 2px 0 rgba(0,0,0,.06); }
.nick input.bad { animation: shake .35s; border-color: var(--red); }
.err { min-height: 18px; margin-top: -4px; color: var(--red); font: 700 14px var(--hand); text-align: center; }
.bestline { font: 700 14px var(--hand); opacity: .75; min-height: 18px; }

.sticker { display: inline-flex; align-items: center; justify-content: center; min-height: 54px; padding: 8px 34px; font: 700 26px var(--hand); letter-spacing: .08em; color: var(--ink); text-decoration: none; background: var(--gold); border: 3px solid var(--ink); border-radius: 16px 20px 14px 22px / 20px 14px 22px 16px; box-shadow: 4px 5px 0 var(--ink); transform: rotate(-1.5deg); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.sticker:active { transform: translate(3px, 4px) rotate(-1.5deg); box-shadow: 1px 1px 0 var(--ink); }
.sticker.alt { background: #fff; font-size: 20px; padding: 8px 22px; transform: rotate(1.2deg); }
#play { font-size: 32px; padding: 8px 52px; min-height: 60px; animation: wob 2.4s ease-in-out infinite; }
.linkbtn { background: none; border: 0; font: 700 14px var(--hand); color: var(--blue); text-decoration: underline; min-height: 44px; cursor: pointer; }

/* not kagidi */
.note { position: relative; width: 100%; background: var(--paper) repeating-linear-gradient(transparent 0 25px, rgba(100, 150, 215, .38) 25px 26px); border: 2px solid rgba(58, 58, 70, .55); border-radius: 4px; padding: 26px 16px 12px; box-shadow: 3px 4px 0 rgba(58, 58, 70, .35), 0 8px 18px rgba(80, 60, 20, .22); transform: rotate(1.2deg); }
.note::before { content: ""; position: absolute; left: 34px; top: 0; bottom: 0; width: 2px; background: rgba(229, 72, 77, .5); }
.note h2 { margin: 0 0 4px 22px; font: 700 20px var(--hand); letter-spacing: .08em; }
.note h2.hand { font-size: 28px; text-align: center; margin: 0; letter-spacing: .02em; }
.note.small { max-width: 280px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; padding: 28px 20px 20px; }
.tape { position: absolute; top: -13px; left: 50%; width: 92px; height: 26px; margin-left: -46px; background: rgba(255, 217, 59, .68); border-left: 2px dotted rgba(0, 0, 0, .15); border-right: 2px dotted rgba(0, 0, 0, .15); transform: rotate(-3deg); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.pin { position: absolute; top: -12px; left: 50%; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff9aa0, var(--red) 55%, #a1252a); border: 2px solid var(--ink); box-shadow: 2px 4px 0 rgba(0, 0, 0, .25); }
.board { list-style: none; margin: 0 0 0 22px; padding: 0; font: 700 15px/26px var(--hand); }
.board li { display: grid; grid-template-columns: 26px 1fr auto; gap: 6px; align-items: baseline; white-space: nowrap; }
.board li .r { opacity: .55; text-align: right; }
.board li .n { overflow: hidden; text-overflow: ellipsis; }
.board li .s { font-variant-numeric: tabular-nums; }
.board li.me { background: rgba(255, 217, 59, .55); border-radius: 6px; margin-left: -4px; padding-left: 4px; }
.board li.muted { display: block; opacity: .6; }
.board.small { font-size: 13px; line-height: 22px; max-height: 232px; overflow: hidden; margin-left: 22px; }

/* oyun bitti karti */
.over-col { max-width: 400px; }
.card { padding-top: 30px; padding-bottom: 14px; }
.bigscore { text-align: center; font: 700 64px/1.1 var(--hand); color: var(--ink); margin-left: 22px; }
.bigscore small { font-size: 16px; margin-left: 6px; opacity: .6; }
.stamp { position: absolute; right: 2px; top: 2px; width: 84px; height: 84px; border: 4px double var(--red); border-radius: 50%; color: var(--red); display: none; flex-direction: column; align-items: center; justify-content: center; transform: rotate(-16deg); background: rgba(255, 254, 246, .6); pointer-events: none; }
.stamp b { font: 700 34px/1 var(--hand); } .stamp span { font: 700 9px var(--sans); letter-spacing: .08em; }
.stamp.show { display: flex; animation: stampIn .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.stats { display: flex; justify-content: space-around; margin: 4px 0 4px 22px; font: 700 13px var(--hand); text-align: center; }
.stats span { display: block; opacity: .6; } .stats b { font-size: 20px; }
.msg { margin: 0 0 4px 22px; min-height: 20px; text-align: center; font: 700 14px var(--hand); color: #8a5a00; }
.btnrow { display: flex; gap: 12px; justify-content: center; margin: 8px 0 2px 22px; flex-wrap: wrap; }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fillin { to { fill-opacity: .9; } }
@keyframes pulse { 50% { transform: scale(1.04); } }
#hint { --r: -1deg; }
@keyframes wob { 0%, 100% { transform: rotate(-1.5deg) scale(1); } 50% { transform: rotate(1deg) scale(1.05); } }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes stampIn { 0% { transform: rotate(-16deg) scale(3.2); opacity: 0; } 70% { transform: rotate(-16deg) scale(.9); opacity: 1; } 100% { transform: rotate(-16deg) scale(1); opacity: 1; } }
@keyframes bannerIn { 0% { opacity: 0; transform: translate(-50%, 0) rotate(-6deg) scale(2.2); } 12% { opacity: 1; transform: translate(-50%, 0) rotate(-6deg) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -30px) rotate(-6deg) scale(1); } }

/* baslik ucagi */
#tplane { position: absolute; z-index: 9; left: 0; top: 0; width: 96px; height: 60px; pointer-events: none; animation: glide 11s linear infinite; }
@keyframes glide { 0% { transform: translate(-110px, 14vh) rotate(8deg); } 25% { transform: translate(25vw, 9vh) rotate(-10deg); } 50% { transform: translate(52vw, 16vh) rotate(10deg); } 75% { transform: translate(78vw, 10vh) rotate(-8deg); } 100% { transform: translate(112vw, 15vh) rotate(6deg); } }

/* yatay / dusuk yukseklik */
@media (orientation: landscape) and (max-height: 560px) {
  .screen { flex-direction: row; align-items: flex-start; justify-content: center; gap: 22px; padding-top: calc(var(--st) + 52px); }
  .tcol { max-width: 400px; gap: 4px; }
  #logo { width: min(32vw, 240px); margin-bottom: -6px; }
  .err { min-height: 0; margin: -2px 0 0; } .bestline { min-height: 0; }
  .how { font-size: 13px; line-height: 1.3; } .how li { margin-bottom: 2px; padding: 2px 8px; }
  #play { min-height: 48px; font-size: 24px; padding: 4px 40px; }
  .nick { flex-direction: row; align-items: center; } .nick span { white-space: nowrap; }
  .note { padding-top: 22px; } .board { line-height: 22px; font-size: 14px; }
  .bigscore { font-size: 44px; } .card { padding-top: 24px; }
  .over-col { max-width: 460px; }
  .board.small { max-height: 110px; columns: 2; column-gap: 10px; }
  .screen.center { align-items: center; }
  #hud { top: calc(var(--st) + 8px); }
  #back { left: calc(var(--sl) + 10px); }
  #hint { bottom: calc(var(--sb) + 6%); }
}
@media (prefers-reduced-motion: reduce) {
  .lt, .ul, .pl { animation-duration: .01s; animation-delay: 0s; }
  #play, #hint, .shieldchip { animation: none; }
  #tplane { animation-duration: 30s; }
}
