/* Word Rush (Game CMB) -- Neon Arcade + Clean Typography, per this
   project's own visual-style brief. Original identity: no other Word
   Rush game's UI referenced or copied. */

:root {
  --bg-deep: #0c0620;
  --bg-navy: #140a33;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.12);
  --cyan: #4ce0e8;
  --violet: #8b5cf6;
  --pink: #f472b6;
  --gold: #fbbf24;
  --green: #34d399;
  --red: #f76c6c;
  --text: #f4f2ff;
  --text-dim: #b8b0d8;
  --radius: 16px;
  --radius-sm: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: 'Poppins', 'Inter', sans-serif; margin: 0; }

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(139,92,246,0.35), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(76,224,232,0.18), transparent),
    linear-gradient(180deg, var(--bg-deep), var(--bg-navy) 60%, var(--bg-deep));
  background-attachment: fixed;
}

.app::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black, transparent 90%);
}

/* ---------- Loading ---------- */
.screen-loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; z-index: 999; background: var(--bg-deep);
}
.loading-logo { font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 32px; letter-spacing: 2px; color: var(--text); }
.loading-logo span { color: var(--cyan); }
.loading-bar { width: 200px; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.1); overflow: hidden; }
.loading-bar-fill { height: 100%; width: 10%; background: linear-gradient(90deg, var(--violet), var(--cyan)); transition: width .2s ease; }
.loading-text { color: var(--text-dim); font-size: 13px; }

/* ---------- Topbar ---------- */
.topbar { position: relative; z-index: 5; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.brand { font-family: 'Poppins', sans-serif; font-weight: 800; letter-spacing: 1px; font-size: 18px; }
.brand span { color: var(--cyan); }
.icon-btn {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px;
  width: 38px; height: 38px; font-size: 16px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active { border-color: var(--cyan); box-shadow: 0 0 10px rgba(76,224,232,0.4); }

main { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; }

.screen { width: 100%; }

/* ---------- Home ---------- */
.screen-home { display: flex; flex-direction: column; align-items: center; padding: 24px 16px 8px; }
.home-card {
  width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 14px; padding: 32px 20px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 40px rgba(139,92,246,0.15);
}
.game-title { font-size: 40px; font-weight: 800; letter-spacing: 1px; }
.game-title span { color: var(--cyan); text-shadow: 0 0 18px rgba(76,224,232,0.6); }
.game-tagline { color: var(--text-dim); font-size: 13px; letter-spacing: 1.5px; font-weight: 600; }
.home-stat { color: var(--text-dim); font-size: 13px; }
.home-stat strong { color: var(--gold); font-size: 15px; }

.btn {
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 13.5px; letter-spacing: 0.5px;
  border: none; border-radius: 14px; padding: 14px 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.25;
  touch-action: manipulation; user-select: none; color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  box-shadow: 0 6px 24px rgba(139,92,246,0.45);
  font-size: 15px;
}
.btn-ghost { background: var(--panel); border: 1px solid var(--panel-border); }
.btn-play { width: 100%; padding: 16px; font-size: 17px; }
.btn-small { padding: 12px 14px; font-size: 12.5px; flex: 1; }

.home-actions { display: flex; gap: 10px; width: 100%; }
.home-actions .btn { flex: 1; }

.seo-content { max-width: 640px; width: 100%; margin: 36px auto 0; padding: 0 8px 16px; color: var(--text-dim); font-size: 14px; line-height: 1.65; }
.seo-content h2 { color: var(--text); font-size: 18px; margin: 22px 0 8px; }
.seo-content p { margin: 0 0 4px; }
.related-games { display: flex; flex-wrap: wrap; gap: 8px 14px; list-style: none; padding: 0; margin: 6px 0 0; }
.related-games a { color: var(--cyan); text-decoration: none; font-weight: 600; }
.related-games a:hover { text-decoration: underline; }

/* ---------- Ad slots ---------- */
.ad-slot {
  width: 100%; max-width: 640px; margin: 18px auto; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--panel-border); border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
}

/* ---------- Game screen ---------- */
.screen-game {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  padding: 10px 12px 14px; gap: 8px; overflow: hidden;
}
.hud { display: flex; align-items: flex-start; justify-content: space-between; }
.hud-stat, .hud-timer { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.hud-label { font-size: 10px; letter-spacing: 1.5px; color: var(--text-dim); font-weight: 600; }
.hud-value { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 22px; }
.hud-timer-value { color: var(--cyan); transition: color .2s ease; }
.hud-timer-wrap.warning .hud-timer-value { color: var(--gold); }
.hud-timer-wrap.critical .hud-timer-value { color: var(--red); animation: pulse-fast 0.5s infinite; }

.fever-badge {
  align-self: center; font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 15px;
  padding: 6px 18px; border-radius: 999px; color: #1a0a2e;
  background: linear-gradient(90deg, var(--gold), var(--pink));
  box-shadow: 0 0 28px rgba(251,191,36,0.6);
  animation: fever-pulse 0.6s infinite alternate;
}
@keyframes fever-pulse { from { transform: scale(1); } to { transform: scale(1.06); } }

.combo-indicator {
  align-self: center; font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14px;
  color: var(--gold); letter-spacing: 1px;
  text-shadow: 0 0 14px rgba(251,191,36,0.5);
}
.combo-indicator.combo-hot { color: var(--pink); font-size: 16px; }

.game-stage { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 0; }
.particles-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }

.tile-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  width: 100%; max-width: 320px; z-index: 1;
}
.tile {
  aspect-ratio: 1 / 1; min-height: 52px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: clamp(20px, 6vw, 30px);
  background: linear-gradient(160deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 6px 18px rgba(0,0,0,0.35);
  color: var(--text); cursor: pointer; user-select: none; touch-action: manipulation;
  transition: transform .1s ease, box-shadow .15s ease, background .15s ease;
}
.tile:active, .tile.tile-press { transform: scale(1.08); box-shadow: 0 0 22px rgba(76,224,232,0.55), inset 0 1px 0 rgba(255,255,255,0.3); }
.tile.tile-used { background: linear-gradient(160deg, rgba(76,224,232,0.35), rgba(139,92,246,0.2)); }

.word-input-wrap { width: 100%; max-width: 320px; z-index: 1; }
.word-input {
  min-height: 46px; border-radius: var(--radius-sm); background: rgba(0,0,0,0.35);
  border: 1px solid var(--panel-border); display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 20px; letter-spacing: 3px;
  color: var(--cyan); padding: 6px 10px; word-break: break-all; text-align: center;
}
.word-input.shake { animation: shake .3s ease; color: var(--red); }
.word-input.pop { animation: pop-word .25s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes pop-word { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }

.game-controls { display: flex; gap: 10px; width: 100%; max-width: 320px; z-index: 1; }
.btn-delete { flex: 0 0 52px; padding: 12px 0; font-size: 18px; }

.countdown-overlay {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: rgba(12,6,32,0.75); backdrop-filter: blur(4px);
}
.countdown-number {
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 96px; color: var(--cyan);
  text-shadow: 0 0 40px rgba(76,224,232,0.8);
  animation: countdown-pop 0.7s ease;
}
@keyframes countdown-pop { 0% { transform: scale(0.4); opacity: 0; } 40% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

@keyframes pulse-fast { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ---------- Result ---------- */
.screen-result { display: flex; flex-direction: column; align-items: center; padding: 28px 16px; }
.result-card {
  width: 100%; max-width: 420px; text-align: center; padding: 30px 22px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--panel-border); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.result-banner {
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 14px; letter-spacing: 1px;
  padding: 8px 16px; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--pink)); color: #1a0a2e;
}
.result-title { font-size: 22px; font-weight: 800; letter-spacing: 1px; color: var(--text-dim); }
.result-score { font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 52px; color: var(--cyan); text-shadow: 0 0 24px rgba(76,224,232,0.5); line-height: 1; }
.result-score-label { font-size: 11px; letter-spacing: 2px; color: var(--text-dim); margin-bottom: 6px; }
.result-rank { font-weight: 700; color: var(--gold); font-size: 14px; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; margin: 8px 0; }
.result-stats div { display: flex; flex-direction: column; }
.result-stats span { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 18px; }
.result-stats label { font-size: 9px; color: var(--text-dim); letter-spacing: 0.5px; }
.result-card .btn-play { margin-top: 6px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(6,3,18,0.72); backdrop-filter: blur(3px); padding: 16px;
}
.modal-card {
  position: relative; width: 100%; max-width: 380px; background: var(--bg-navy);
  border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 26px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5); max-height: 85vh; overflow-y: auto;
}
.modal-card-wide { max-width: 460px; }
.modal-card h3 { font-size: 17px; letter-spacing: 1px; margin-bottom: 14px; text-align: center; }
.modal-close {
  position: absolute; top: 12px; right: 12px; background: transparent; border: none; color: var(--text-dim);
  font-size: 16px; cursor: pointer; width: 30px; height: 30px;
}

.nickname-input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.3); color: var(--text); font-size: 15px; font-family: 'Poppins', sans-serif;
  text-align: center; margin-bottom: 8px;
}
.nickname-error { color: var(--red); font-size: 12px; text-align: center; margin: 4px 0 8px; }
.nickname-actions { display: flex; gap: 8px; }
.nickname-actions .btn { flex: 1; font-size: 12px; padding: 12px 8px; }

.howto-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; color: var(--text-dim); line-height: 1.5; }
.howto-list strong { color: var(--text); }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--panel-border); background: transparent;
  color: var(--text-dim); font-weight: 600; font-size: 12px; cursor: pointer;
}
.tab.active { background: linear-gradient(135deg, var(--violet), var(--cyan)); color: var(--text); border-color: transparent; }

.leaderboard-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.leaderboard-row {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 10px; background: rgba(255,255,255,0.04);
  font-size: 13px;
}
.leaderboard-row.rank-1 { background: linear-gradient(90deg, rgba(251,191,36,0.25), transparent); }
.leaderboard-row .rank { font-weight: 700; color: var(--text-dim); }
.leaderboard-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-row .score { font-weight: 700; color: var(--cyan); }
.leaderboard-you { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--panel-border); font-size: 12.5px; color: var(--text-dim); text-align: center; }
.leaderboard-empty { text-align: center; color: var(--text-dim); font-size: 13px; padding: 20px 0; }

.site-footer { text-align: center; color: var(--text-dim); font-size: 11px; padding: 6px 0 4px; position: relative; z-index: 1; }

[hidden] { display: none !important; }

/* ---------- Responsive ---------- */
@media (min-width: 700px) {
  .tile-grid { max-width: 360px; }
  .game-stage { gap: 20px; }
}
@media (max-height: 640px) {
  .tile-grid { max-width: 260px; gap: 7px; }
  .tile { min-height: 44px; }
}
