/* Perfect Slice -- Neon Arcade + Premium Casual visual style */

:root {
  --bg-0: #070a16;
  --bg-1: #0d1024;
  --panel-bg: rgba(20, 22, 45, 0.55);
  --panel-border: rgba(255, 255, 255, 0.10);
  --accent-cyan: #00ffc8;
  --accent-violet: #7c4dff;
  --accent-pink: #ff4dd2;
  --accent-gold: #ffd23f;
  --text-0: #f4f5ff;
  --text-1: #b7bbe0;
  --danger: #ff5f6d;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow-glow: 0 0 24px rgba(124, 77, 255, 0.35);
  --font-display: 'Poppins', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 800px at 50% -10%, #17143a 0%, var(--bg-0) 55%), var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
p { margin: 0 0 0.8em; color: var(--text-1); line-height: 1.6; }
a { color: var(--accent-cyan); }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Layout ---------- */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; max-width: 1100px; margin: 0 auto; width: 100%;
}
.brand { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.06em; font-size: 15px; color: var(--text-0); }
.brand span { color: var(--accent-cyan); }
.site-header nav a {
  color: var(--text-1); text-decoration: none; font-size: 13px; margin-left: 18px;
}
.site-header nav a:hover { color: var(--accent-cyan); }

.game-shell { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }

.glass {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-glow);
}

.ad-slot {
  margin: 18px auto; max-width: 728px; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed rgba(255,255,255,0.12); border-radius: var(--radius-md);
  color: rgba(255,255,255,0.28); font-size: 12px; letter-spacing: 0.05em;
}

/* ---------- Game frame ---------- */
.game-frame {
  position: relative;
  aspect-ratio: 9 / 14;
  max-height: 78vh;
  margin: 18px auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), var(--shadow-glow);
  background: var(--bg-1);
}
@media (min-width: 720px) {
  .game-frame { aspect-ratio: 16 / 10; max-height: 640px; }
}

.screen {
  position: absolute; inset: 0; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 22px;
}
.screen.is-active { display: flex; }

/* ---------- Home screen ---------- */
.home-panel {
  width: 100%; max-width: 380px; padding: 34px 28px; text-align: center;
}
.logo-title {
  font-size: 34px; font-weight: 800; line-height: 1.05; letter-spacing: 0.03em;
  text-shadow: 0 0 26px rgba(124,77,255,0.65);
}
.logo-title span { color: var(--accent-cyan); text-shadow: 0 0 26px rgba(0,255,200,0.7); }
.tagline { margin-top: 10px; font-size: 14px; }

.btn {
  border: none; border-radius: 14px; padding: 12px 16px; font-weight: 700;
  font-size: 12px; letter-spacing: 0.01em; transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 46px; line-height: 1.25;
  display: flex; align-items: center; justify-content: center; text-align: center;
  white-space: normal; word-break: break-word;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
  color: #060716; box-shadow: 0 8px 26px rgba(0,255,200,0.28);
  width: 100%; margin-top: 22px; font-size: 15px;
}
.btn-ghost {
  background: rgba(255,255,255,0.06); color: var(--text-0);
  border: 1px solid var(--panel-border);
}
.btn-text {
  background: transparent; color: var(--text-1); text-decoration: underline;
  padding: 8px; font-weight: 500; font-size: 13px; min-height: auto;
}

.home-best { margin-top: 18px; font-weight: 700; font-size: 15px; color: var(--accent-gold); }
.mini-leaderboard { list-style: none; margin: 14px 0 0; padding: 0; text-align: left; }
.home-actions { display: flex; gap: 10px; margin-top: 18px; }
.home-actions .btn { flex: 1; }
.toggle-row { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.06); color: var(--text-0); font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn.is-off { opacity: 0.4; }

/* ---------- Game HUD ---------- */
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; pointer-events: none;
}
.hud-item { display: flex; flex-direction: column; align-items: flex-start; }
.hud-combo { align-items: center; }
.hud-label { font-size: 10px; letter-spacing: 0.12em; color: var(--text-1); }
#hud-score { font-size: 22px; font-weight: 800; text-shadow: 0 0 10px rgba(0,255,200,0.5); }
#hud-combo { font-size: 20px; font-weight: 800; color: var(--accent-gold); transition: transform 0.15s ease; }
#hud-combo.is-hot { color: var(--accent-pink); text-shadow: 0 0 14px rgba(255,77,210,0.7); animation: pulse 0.6s ease infinite; }

.hud-lives { display: flex; gap: 4px; font-size: 18px; }
.hud-lives .heart { transition: opacity 0.2s ease, transform 0.2s ease; }
.hud-lives .heart.is-lost { opacity: 0.18; transform: scale(0.85); filter: grayscale(1); }

.btn-pause {
  position: absolute; top: 14px; right: 14px; z-index: 4;
  transform: translateY(52px);
}

.hud-bottom {
  position: absolute; bottom: 14px; left: 0; right: 0; z-index: 3;
  text-align: center; font-size: 12px; color: var(--text-1); letter-spacing: 0.08em;
  pointer-events: none;
}
.hud-bottom span:last-child { color: var(--text-0); font-weight: 700; }

.streak-banner {
  position: absolute; top: 40%; left: 50%; z-index: 5;
  transform: translate(-50%, -50%) scale(0.7);
  font-size: 22px; font-weight: 800; color: var(--accent-gold);
  text-shadow: 0 0 18px rgba(255,210,63,0.8);
  opacity: 0; pointer-events: none;
}
.streak-banner.show { animation: streak-pop 1.1s ease forwards; }
@keyframes streak-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  30% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ---------- Game over screen ---------- */
.gameover-panel {
  width: 100%; max-width: 400px; padding: 30px 26px; text-align: center;
  max-height: 100%; overflow-y: auto;
}
.go-newbest {
  color: var(--accent-gold); font-weight: 800; font-size: 15px; margin-bottom: 6px;
  opacity: 0; height: 0; overflow: hidden;
}
.go-newbest.is-visible { opacity: 1; height: auto; animation: pulse 1s ease infinite; }
.go-score { font-size: 42px; font-weight: 800; margin: 6px 0 16px; text-shadow: 0 0 24px rgba(124,77,255,0.6); }
.go-stats { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.go-stats > div { flex: 1; background: rgba(255,255,255,0.05); border-radius: var(--radius-md); padding: 10px 6px; }
.go-stats span { display: block; }
.go-stats span:last-child { font-weight: 700; font-size: 16px; margin-top: 2px; }
.go-gap { font-size: 13px; }

.nickname-prompt-wrap { margin: 16px 0; }
.nickname-prompt-wrap.is-hidden { display: none; }
#nickname-form label { display: block; font-size: 11px; letter-spacing: 0.1em; color: var(--text-1); margin-bottom: 6px; text-align: left; }
#nickname-input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--panel-border); background: rgba(0,0,0,0.35); color: var(--text-0);
  font-size: 15px; outline: none;
}
#nickname-input:focus { border-color: var(--accent-cyan); }
.nickname-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 6px; text-align: left; display: none; }
.nickname-error.show { display: block; }
.nickname-actions { display: flex; gap: 8px; margin-top: 12px; }
.nickname-actions .btn-primary { margin-top: 0; }
.nickname-actions .btn { flex: 1; font-size: 13px; padding: 12px 10px; }

.submit-success { display: none; color: var(--accent-cyan); font-weight: 700; margin: 10px 0; }
.submit-success.show { display: block; }

.go-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.go-actions .btn-primary { margin-top: 0; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(4,5,14,0.72); backdrop-filter: blur(4px);
}
.modal.is-open { display: flex; }
.modal-panel {
  width: 100%; max-width: 440px; max-height: 82vh; overflow-y: auto;
  padding: 22px; position: relative;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-header h3 { font-size: 16px; letter-spacing: 0.06em; }
.modal-close {
  background: rgba(255,255,255,0.08); border: none; color: var(--text-0);
  width: 32px; height: 32px; border-radius: 50%; font-size: 15px;
}

.howto-steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.howto-steps li {
  counter-increment: step; position: relative; padding: 8px 0 8px 34px; font-size: 14px; color: var(--text-0);
}
.howto-steps li::before {
  content: counter(step); position: absolute; left: 0; top: 6px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent-violet);
  color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

.lb-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.lb-tabs button {
  flex: 1; background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border);
  color: var(--text-1); border-radius: 999px; padding: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
}
.lb-tabs button.is-active { background: var(--accent-violet); color: #fff; border-color: transparent; }

.lb-list, .mini-leaderboard { list-style: none; padding: 0; margin: 0; }
.lb-row, .mini-leaderboard .lb-row {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 8px; align-items: center;
  padding: 9px 8px; border-radius: 10px; font-size: 13px;
}
.lb-row:nth-child(odd) { background: rgba(255,255,255,0.03); }
.lb-row.is-me { background: rgba(0,255,200,0.14); outline: 1px solid rgba(0,255,200,0.4); }
.lb-rank { color: var(--accent-gold); font-weight: 700; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; }
.lb-loading, .lb-empty { text-align: center; color: var(--text-1); padding: 20px 0; font-size: 13px; }

/* ---------- SEO content ---------- */
.seo-content { max-width: 760px; margin: 30px auto 0; padding: 0 6px; }
.seo-content h2 { font-size: 20px; margin: 26px 0 10px; }
.seo-content h3 { font-size: 16px; margin: 18px 0 8px; color: var(--text-0); }
.seo-content ul { color: var(--text-1); padding-left: 20px; }
.faq-item { margin-bottom: 14px; }
.related-games { display: flex; flex-wrap: wrap; gap: 10px; padding: 0; list-style: none; }
.related-games a {
  display: block; padding: 9px 14px; border-radius: 999px; text-decoration: none;
  background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border); font-size: 13px;
}

.site-footer {
  text-align: center; padding: 26px 16px; color: var(--text-1); font-size: 12px;
}
.site-footer a { color: var(--text-1); }

/* ---------- In-game mobile focus mode ---------- */
@media (max-width: 719px) {
  body.in-game .site-header,
  body.in-game .ad-slot,
  body.in-game .seo-content,
  body.in-game .site-footer { display: none; }
  body.in-game .game-shell { padding: 0; max-width: none; }
  body.in-game .game-frame {
    aspect-ratio: auto; max-height: none; height: 100dvh; margin: 0; border-radius: 0; border: none;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #hud-combo.is-hot, .go-newbest.is-visible { animation: none; }
  .streak-banner.show { animation-duration: 0.01s; }
}

/* ---------- Focus visibility ---------- */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-cyan); outline-offset: 2px;
}
