:root {
  --lime: #CCFF00; --pale: #EDFFB0; --ink: #080A04; --panel: #0E1206; --line: #23271a; --muted: #A6AA9C;
  --white: #F4F6F4; --red: #FF2A3C;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--ink); color: var(--white); font: 500 16px/1.4 'Chakra Petch', system-ui, sans-serif; overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
kbd { font: 700 0.8em 'JetBrains Mono', monospace; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 5px; padding: 1px 6px; color: var(--pale); }
.red { color: var(--red); }

.logo { font: 900 clamp(54px, 12vmin, 132px)/0.86 Unbounded, sans-serif; color: var(--lime); letter-spacing: -0.03em; text-shadow: 0 0 40px rgba(204, 255, 0, 0.3); }
.tag { font: 700 12px 'JetBrains Mono', monospace; letter-spacing: 0.14em; color: var(--pale); border: 1px solid rgba(204, 255, 0, 0.35); border-radius: 99px; padding: 5px 12px; display: inline-block; }
.fine { font-size: 13px; color: var(--muted); }

.btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 20px; min-height: 48px; border: 1.5px solid var(--line); border-radius: 12px; background: rgba(14, 18, 6, 0.86); transition: transform 0.08s, border-color 0.15s, background 0.15s; text-align: left; }
.btn b { font: 900 16px Unbounded, sans-serif; letter-spacing: 0.01em; }
.btn span { font: 500 13px 'Chakra Petch', sans-serif; color: var(--muted); }
.btn:hover { border-color: var(--lime); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .tabs button:focus-visible, .skin:focus-visible, input:focus-visible { outline: 2px solid var(--pale); outline-offset: 2px; }
.btn.primary { background: var(--lime); border-color: var(--lime); color: var(--ink); box-shadow: 0 0 34px rgba(204, 255, 0, 0.28); }
.btn.primary span { color: #3b4a00; font-weight: 700; }
.btn.primary:hover { background: var(--pale); }
.btn.small { padding: 10px 14px; min-height: 42px; font: 700 13px 'Chakra Petch', sans-serif; letter-spacing: 0.06em; flex-direction: row; align-items: center; }
.btn.solid { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.btn.toggle::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--lime); margin-right: 8px; box-shadow: 0 0 8px var(--lime); }
.btn.toggle.off { color: var(--muted); }
.btn.toggle.off::before { background: #3a3f30; box-shadow: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

.screen { position: fixed; inset: 0; z-index: 10; display: flex; }
.modal { align-items: center; justify-content: center; background: rgba(4, 6, 2, 0.78); backdrop-filter: blur(5px); padding: calc(14px + var(--sat)) calc(14px + var(--sar)) calc(14px + var(--sab)) calc(14px + var(--sal)); animation: fade 0.18s ease-out; }
@keyframes fade { from { opacity: 0; } }
.panel { width: min(760px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1.5px solid var(--line); border-radius: 18px; padding: 26px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); touch-action: pan-y; }
@keyframes rise { from { transform: translateY(18px) scale(0.97); opacity: 0; } }
.panel.narrow { width: min(380px, 100%); }
.panel.narrow .btn { align-items: center; }
.panel.wide { width: min(980px, 100%); flex-direction: row; gap: 28px; }
.panel h2 { font: 900 clamp(24px, 5vmin, 38px)/1 Unbounded, sans-serif; color: var(--lime); }
.panel h3 { font: 900 14px Unbounded, sans-serif; color: var(--pale); letter-spacing: 0.04em; }

#loading { align-items: center; justify-content: center; background: var(--ink); text-align: center; }
#loading p { margin-top: 18px; color: var(--muted); font: 700 13px 'JetBrains Mono', monospace; letter-spacing: 0.1em; }

#title { background: var(--ink); }
.title-art { position: absolute; inset: 0; background: url(../assets/title.webp) 70% 50% / cover no-repeat; }
.title-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8, 10, 4, 0.96) 0%, rgba(8, 10, 4, 0.82) 34%, rgba(8, 10, 4, 0.1) 70%), linear-gradient(0deg, rgba(8, 10, 4, 0.7), transparent 30%); }
.title-body { position: relative; width: min(520px, 100%); padding: calc(28px + var(--sat)) 28px calc(20px + var(--sab)) calc(40px + var(--sal)); display: flex; flex-direction: column; justify-content: center; gap: 14px; overflow-y: auto; touch-action: pan-y; }
.title-body .tag { align-self: flex-start; }
.lead { font-size: 18px; color: var(--white); max-width: 30em; }
.title-body .btn:not(.small) { width: 100%; }
footer { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 6px; font-size: 13px; }
footer a { color: var(--pale); text-decoration: none; border-bottom: 1px solid rgba(237, 255, 176, 0.3); }
footer a:hover { color: var(--lime); }
.ca { font: 700 12px 'JetBrains Mono', monospace; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; padding: 3px 8px; }
.ca:hover { color: var(--lime); border-color: var(--lime); }
footer small { flex-basis: 100%; color: #7c8072; font-size: 11.5px; }


.over-l { flex: 1.25; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.over-r { flex: 1; min-width: 0; border-left: 1.5px solid var(--line); padding-left: 24px; display: flex; flex-direction: column; gap: 10px; }
.big { font: 900 clamp(48px, 10vmin, 84px)/0.95 Unbounded, sans-serif; color: var(--white); font-variant-numeric: tabular-nums; }
.big.best { color: var(--lime); text-shadow: 0 0 30px rgba(204, 255, 0, 0.4); }
.stats { display: flex; gap: 10px; }
.stats div { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #0a0d05; }
.stats b { display: block; font: 700 20px 'JetBrains Mono', monospace; color: var(--pale); }
.stats span { font-size: 12px; color: var(--muted); }
.unlock { border: 1.5px solid var(--lime); border-radius: 10px; padding: 9px 12px; color: var(--lime); font-weight: 700; background: rgba(204, 255, 0, 0.08); }
#post { display: flex; gap: 8px; }
input { flex: 1; min-width: 0; font: 700 16px 'Chakra Petch', sans-serif; color: var(--white); background: #0a0d05; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 14px; user-select: text; -webkit-user-select: text; }
input::placeholder { color: #6d7163; }
.over-l .row .btn { flex: 1; align-items: center; padding: 14px 10px; }

.board { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; counter-reset: r; min-height: 60px; }
.board li { counter-increment: r; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; background: #0a0d05; font-weight: 700; }
.board li::before { content: counter(r); font: 700 13px 'JetBrains Mono', monospace; color: var(--muted); width: 1.6em; }
.board li:nth-child(1) { color: var(--lime); border: 1px solid rgba(204, 255, 0, 0.4); }
.board li:nth-child(1)::before { color: var(--lime); }
.board li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li b { font: 700 15px 'JetBrains Mono', monospace; }
.board li.me { outline: 1.5px solid var(--pale); }
.board .empty { color: var(--muted); font-weight: 500; background: none; }
.board .empty::before { content: ''; width: 0; }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); font: 700 13px 'Chakra Petch', sans-serif; letter-spacing: 0.06em; color: var(--muted); min-height: 44px; }
.tabs button.on { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.btn.close { align-self: flex-start; }

.skin-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.skin { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; background: #0a0d05; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.skin canvas { width: 104px; height: 96px; }
.skin b { font: 900 12px Unbounded, sans-serif; }
.skin span { font-size: 12px; color: var(--muted); }
.skin.on { border-color: var(--lime); box-shadow: 0 0 22px rgba(204, 255, 0, 0.2); }
.skin.locked canvas { filter: brightness(0.25) saturate(0); }
.skin.locked { cursor: not-allowed; }

#card { width: 100%; height: auto; border-radius: 12px; border: 1.5px solid var(--line); }

#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; padding: calc(12px + var(--sat)) calc(16px + var(--sar)) 0 calc(16px + var(--sal)); display: flex; justify-content: space-between; align-items: flex-start; }
.hud-l { display: flex; flex-direction: column; gap: 2px; }
#hearts { display: flex; gap: 5px; height: 22px; }
#hearts i { width: 24px; height: 22px; background: var(--lime); clip-path: path('M12 21 C2 13 0 9 0 6 A6 6 0 0 1 12 4 A6 6 0 0 1 24 6 C24 9 22 13 12 21Z'); filter: drop-shadow(0 0 5px rgba(204, 255, 0, 0.6)); transition: transform 0.2s, background 0.2s; }
#hearts i.off { background: #2a2f1f; transform: scale(0.8); }
#score { font: 900 clamp(30px, 6.2vmin, 52px)/1 Unbounded, sans-serif; text-shadow: 0 3px 0 var(--ink), 0 0 20px rgba(0, 0, 0, 0.7); font-variant-numeric: tabular-nums; }
#score.x2 { color: var(--lime); }
.hud-sub { display: flex; gap: 14px; font: 700 14px 'JetBrains Mono', monospace; color: var(--pale); text-shadow: 0 2px 0 var(--ink); }
.coin::before { content: ''; display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--lime); border: 2px solid var(--ink); margin-right: 5px; vertical-align: -1px; }
#combo { position: absolute; left: 50%; top: calc(14% + var(--sat)); transform: translateX(-50%); font: 900 clamp(22px, 5vmin, 40px) Unbounded, sans-serif; color: var(--pale); text-shadow: 0 3px 0 var(--ink); opacity: 0; transition: opacity 0.2s; }
#combo.on { opacity: 1; animation: pop 0.25s; }
@keyframes pop { from { transform: translateX(-50%) scale(1.6); } }
.hud-r { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-top { display: flex; align-items: center; gap: 10px; }
#chip { font: 700 11px 'JetBrains Mono', monospace; letter-spacing: 0.08em; color: var(--pale); background: rgba(8, 10, 4, 0.7); border: 1px solid rgba(204, 255, 0, 0.3); border-radius: 99px; padding: 4px 10px; }
.icon { pointer-events: auto; width: 46px; height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: rgba(14, 18, 6, 0.8); font: 900 14px Unbounded, sans-serif; color: var(--pale); }
#pows { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
#pows div { font: 700 11px 'JetBrains Mono', monospace; letter-spacing: 0.06em; background: rgba(8, 10, 4, 0.75); border: 1px solid var(--lime); border-radius: 8px; padding: 4px 9px 7px; color: var(--lime); position: relative; min-width: 120px; overflow: hidden; }
#pows div i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--lime); width: 100%; transform-origin: left; }
#cd { width: 120px; height: 18px; border-radius: 6px; border: 1px solid var(--line); background: rgba(8, 10, 4, 0.7); position: relative; overflow: hidden; }
#cd i { position: absolute; inset: 0; background: var(--lime); transform-origin: left; opacity: 0.85; }
#cd span { position: absolute; inset: 0; text-align: center; font: 700 10px/17px 'JetBrains Mono', monospace; letter-spacing: 0.12em; color: var(--ink); mix-blend-mode: difference; filter: invert(1); }

#banner { position: fixed; left: 0; right: 0; top: 24%; z-index: 6; text-align: center; pointer-events: none; animation: banner 2.4s both; }
#banner b { display: block; font: 900 clamp(26px, 7vmin, 64px)/1 Unbounded, sans-serif; color: var(--lime); text-shadow: 0 4px 0 var(--ink), 0 0 40px rgba(204, 255, 0, 0.45); }
#banner span { font: 700 clamp(13px, 2.6vmin, 18px) 'Chakra Petch', sans-serif; letter-spacing: 0.16em; color: var(--white); text-transform: uppercase; text-shadow: 0 2px 0 var(--ink); }
#banner.red b { color: var(--red); text-shadow: 0 4px 0 var(--ink), 0 0 40px rgba(255, 42, 60, 0.5); }
#banner.big { top: 13%; animation: banner-big 2.4s both; }
@media (orientation: portrait) { #banner.big { top: 20%; } }
#banner.big b { font-size: clamp(34px, 10.5vw, 104px); letter-spacing: -0.02em; color: var(--pale, #EDFFB0); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink), 0 0 26px rgba(204, 255, 0, 0.95), 0 0 90px rgba(204, 255, 0, 0.7); }
#banner.big span { font-size: clamp(15px, 3.4vmin, 26px); letter-spacing: 0.5em; color: var(--lime); }
@keyframes banner-big { 0% { opacity: 0; transform: scale(2.4); } 9% { opacity: 1; transform: scale(0.94); } 15% { transform: scale(1.04); } 22% { transform: scale(1); } 82% { opacity: 1; transform: scale(1.03); } 100% { opacity: 0; transform: scale(1.12) translateY(-22px); } }
@keyframes banner { 0% { opacity: 0; transform: scale(1.5); } 10% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px); } }

#touch { position: fixed; inset: auto 0 calc(10% + var(--sab)) 0; z-index: 6; display: flex; pointer-events: none; animation: hint 5s both; }
#touch div { flex: 1; text-align: center; font: 700 11px 'JetBrains Mono', monospace; letter-spacing: 0.14em; color: var(--muted); }
#touch b { display: block; font: 900 18px Unbounded, sans-serif; color: var(--pale); }
@keyframes hint { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 760px) {
  .title-art { background-position: 78% 0; background-size: auto 62%; }
  .title-art::after { background: linear-gradient(0deg, rgba(8, 10, 4, 1) 46%, rgba(8, 10, 4, 0.55) 68%, rgba(8, 10, 4, 0.15) 100%); }
  .title-body { width: 100%; justify-content: flex-end; padding: 20px 18px calc(16px + var(--sab)); gap: 10px; }
  .lead { font-size: 15px; }
  .panel { padding: 18px; gap: 12px; }
  .panel.wide { flex-direction: column; gap: 16px; }
  .over-r { border-left: 0; padding-left: 0; border-top: 1.5px solid var(--line); padding-top: 14px; }
  #chip { display: none; }
}
@media (max-height: 520px) {
  .title-body { justify-content: flex-start; gap: 8px; padding-top: 14px; }
  .logo { font-size: clamp(40px, 15vh, 80px); }
  .logo br { display: none; }
  .lead { display: none; }
  .btn { padding: 9px 16px; }
  .panel { padding: 16px; gap: 10px; }
  .stats div { padding: 5px 10px; }
  .big { font-size: 44px; }
}
@media (prefers-reduced-motion: reduce) { .panel, .modal { animation: none; } }
.title-body .row .btn { flex: 1 1 auto; justify-content: center; }
.modal { z-index: 11; }
@media (max-width: 760px) { .over-l .row .btn { padding: 14px 6px; } .over-l .row .btn b { font-size: 13px; white-space: nowrap; } }

#intro { z-index: 20; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: radial-gradient(120% 90% at 50% 0%, #14200a 0%, var(--ink) 62%); padding: calc(64px + var(--sat)) calc(18px + var(--sar)) calc(18px + var(--sab)) calc(18px + var(--sal)); cursor: pointer; user-select: none; -webkit-user-select: none; }
#intro-skip { position: absolute; top: calc(12px + var(--sat)); right: calc(12px + var(--sar)); min-height: 46px; padding: 12px 20px; z-index: 1; }
.intro-main { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(680px, 100%); min-height: 0; }
#intro-cv { width: min(100%, 74vh); aspect-ratio: 8 / 5; border: 1.5px solid var(--line); border-radius: 16px; box-shadow: 0 0 60px rgba(204, 255, 0, 0.12); }
.intro-text { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-height: 148px; }
#intro-head { font: 900 clamp(22px, 5.2vmin, 40px)/1.05 Unbounded, sans-serif; color: var(--lime); text-shadow: 0 0 34px rgba(204, 255, 0, 0.35); }
#intro-line { font-size: clamp(15px, 2.4vmin, 19px); color: var(--white); max-width: 30em; }
#intro-keys { min-height: 1.6em; }
#intro-keys b { color: var(--lime); }
.intro-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(680px, 100%); }
#intro-dots { display: flex; gap: 8px; }
#intro-dots i { width: 9px; height: 9px; border-radius: 50%; background: #3a3f30; transition: width 0.2s, background 0.2s; }
#intro-dots i.on { width: 26px; border-radius: 5px; background: var(--lime); box-shadow: 0 0 10px rgba(204, 255, 0, 0.6); }
#intro-next { min-width: 150px; align-items: center; }
#intro.swap .intro-text { animation: rise 0.25s ease-out; }
@media (orientation: landscape) and (max-height: 560px) {
  #intro { gap: 10px; padding-top: calc(14px + var(--sat)); }
  .intro-main { flex-direction: row; width: min(900px, 100%); gap: 22px; padding-right: 0; }
  #intro-cv { width: min(52%, 96vh); }
  .intro-text { align-items: flex-start; text-align: left; min-height: 0; padding-top: 40px; }
  .intro-foot { width: min(900px, 100%); }
}
@media (prefers-reduced-motion: reduce) { #intro.swap .intro-text, #intro-dots i { animation: none; transition: none; } }
