/* Keyboard Warrior - Layered background styles */
.kw-standalone-shell { width:100%; min-height:100vh; background: #05060a; }
.kw-game-frame { width:100%; height:100vh; position:relative; overflow:hidden; }
.kw-hud { position:absolute; top:0; left:0; right:0; height:60px; z-index:50; display:flex; justify-content:space-between; align-items:center; padding:0 1rem; background:rgba(2,6,23,0.6); border-bottom:1px solid rgba(255,255,255,0.04); }
.kw-hud .kw-hud-left { display:flex; gap:1rem; align-items:center; }
.kw-hud .kw-hud-actions { display:flex; gap:0.75rem; align-items:center; }
.kw-hud .kw-hud-value { color:#cbd5e1; font-weight:700; }
.kw-arena { position:absolute; inset:60px 0 0 0; bottom:0; overflow:hidden; }
.kw-world { position:relative; width:100%; height:calc(100vh - 60px); }

/* PRIMARY single-image background - static full-screen cover */
.kw-single-bg { position:absolute; inset:0; z-index:8; display:flex; align-items:center; justify-content:center; pointer-events:none; }
.kw-single-bg .kw-bg-img { width:100%; height:100%; object-fit:cover; display:block; }

/* Battle layer (player and enemies) */
.kw-battle-layer { position:absolute; inset:0; pointer-events:none; z-index:120; }
.kw-canvas { position:absolute; inset:0; z-index:120; pointer-events:none; }
.kw-stickman { width:100%; height:100%; }

.kw-enemies { position:absolute; right:6%; bottom:18%; width:220px; height:220px; pointer-events:none; }
.kw-enemy { position:absolute; right:0; bottom:0; width:120px; height:220px; transition: transform 80ms linear; }
.kw-enemy .kw-stickman { filter: drop-shadow(0 8px 12px rgba(0,0,0,0.45)); }

.kw-word { position:absolute; top:-40px; left:50%; transform:translateX(-50%); background:rgba(0,0,0,0.6); color:#fff; padding:6px 10px; border-radius:6px; font-family:Inter,system-ui,Arial; pointer-events:none; }
.kw-word .kw-progress { color:#9cffb2; font-weight:700; }

/* When player attacks */
.kw-player.attack { animation: kw-attack 260ms ease-out; }
@keyframes kw-attack { 0% { transform: translateX(0) } 50% { transform: translateX(12%) scale(1.02) } 100% { transform: translateX(0) } }

/* Walking animation */
.kw-walk { animation: kw-walk 400ms steps(4) infinite; }
@keyframes kw-walk { 0% { transform: translateY(0) } 50% { transform: translateY(-4px) } 100% { transform: translateY(0) } }

.kw-enemy.approaching { transition: transform 80ms linear; }
.kw-player.ready { transform:translateX(0%); }

/* State banner & dev controls */
.kw-state-banner { position: absolute; left:50%; transform:translateX(-50%); top:72px; padding:0.35rem 0.6rem; background: rgba(2,6,23,0.6); border-radius:6px; color:#cbd5e1; font-weight:700; z-index:60; }

/* ── Help / Controls Button (💡 Bulb) ─────────────────────────────────── */
.kw-help-wrapper { position:relative; display:inline-flex; align-items:center; }

.kw-help-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 234, 0, 0.45);
  background: radial-gradient(circle, rgba(255, 234, 0, 0.22) 0%, rgba(15, 23, 42, 0.85) 100%);
  color: #ffea00;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(255, 234, 0, 0.35), inset 0 0 6px rgba(255, 234, 0, 0.2);
}
.kw-help-btn:hover, .kw-help-btn:focus-visible {
  transform: scale(1.1);
  border-color: #ffea00;
  box-shadow: 0 0 20px rgba(255, 234, 0, 0.7), inset 0 0 10px rgba(255, 234, 0, 0.4);
  background: radial-gradient(circle, rgba(255, 234, 0, 0.4) 0%, rgba(15, 23, 42, 0.95) 100%);
}
.kw-help-btn:active {
  transform: scale(0.95);
}

/* First-Time Hint Tooltip */
.kw-help-hint {
  position: absolute;
  top: 48px;
  right: 0;
  white-space: nowrap;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98));
  color: #ffea00;
  border: 1px solid rgba(255, 234, 0, 0.4);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 8px rgba(255, 234, 0, 0.2);
  pointer-events: none;
  z-index: 100;
  animation: kw-hint-pulse 2s infinite alternate;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.kw-help-hint::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 14px;
  width: 10px;
  height: 10px;
  background: rgba(30, 41, 59, 0.96);
  border-left: 1px solid rgba(255, 234, 0, 0.4);
  border-top: 1px solid rgba(255, 234, 0, 0.4);
  transform: rotate(45deg);
}
.kw-help-hint.kw-hint-fade {
  opacity: 0;
  transform: translateY(-4px);
}
@keyframes kw-hint-pulse {
  0%   { transform: translateY(0); }
  100% { transform: translateY(3px); }
}

/* ── Help / Controls Modal Backdrop ──────────────────────────────────── */
.kw-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 1rem;
  opacity: 1;
  transition: opacity 0.25s ease;
}
.kw-modal-backdrop.kw-modal-hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

/* Modal Panel */
.kw-modal-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(10, 15, 30, 0.99) 100%);
  border: 1.5px solid rgba(0, 229, 255, 0.35);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 32px rgba(0, 229, 255, 0.15);
  overflow: hidden;
  animation: kw-modal-pop 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes kw-modal-pop {
  0%   { transform: scale(0.92) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Modal Header */
.kw-modal-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  background: rgba(2, 6, 23, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.kw-modal-icon { font-size: 1.4rem; }
.kw-modal-title {
  margin: 0;
  flex: 1;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #00e5ff;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}
.kw-modal-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.kw-modal-close:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #f87171;
}

/* Modal Body */
.kw-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Control Section */
.kw-ctrl-section {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}
.kw-ctrl-heading {
  margin: 0 0 0.5rem 0;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: #64748b;
  text-transform: uppercase;
}
.kw-ctrl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
}
.kw-ctrl-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 180px;
}
.kw-ctrl-keys {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.kw-key-sep {
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
}
.kw-ctrl-label {
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── Keyboard Keycap Styling ─────────────────────────────────────────── */
.kw-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  border: 1px solid #475569;
  border-bottom: 3px solid #0f172a;
  border-radius: 6px;
  color: #00e5ff;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
  user-select: none;
  transition: all 0.1s ease;
}
.kw-key-wide { min-width: 38px; }
.kw-key-xl   { min-width: 60px; }

/* Active/Pressed Keycap visual feedback */
.kw-key:active, .kw-key.kw-key-active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.8);
}

/* Tips */
.kw-modal-tip {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: rgba(0, 229, 255, 0.07);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
}
.kw-modal-tip p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.8rem;
  line-height: 1.45;
}
.kw-modal-tip strong { color: #e2e8f0; }
.kw-tip-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

.kw-modal-tip-alt {
  background: rgba(255, 234, 0, 0.06);
  border-color: rgba(255, 234, 0, 0.25);
}
.kw-modal-tip-alt p { color: #cbd5e1; }
.kw-modal-tip-alt em { color: #ffea00; font-style: normal; font-weight: 700; }

/* Modal Footer */
.kw-modal-footer {
  padding: 0.9rem 1.25rem;
  background: rgba(2, 6, 23, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: flex-end;
}
.kw-modal-got-it {
  width: 100%;
  padding: 0.65rem 1.25rem;
  background: linear-gradient(135deg, #00e5ff 0%, #0088ff 100%);
  color: #020617;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 1px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 229, 255, 0.35);
  transition: all 0.2s ease;
}
.kw-modal-got-it:hover, .kw-modal-got-it:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.6);
  background: linear-gradient(135deg, #38edf8 0%, #1a94ff 100%);
}
.kw-modal-got-it:active {
  transform: translateY(1px);
}

/* Pause overlay */
.kw-pause-overlay { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; z-index:220; }
.kw-pause-overlay.hidden { display:none; }
.kw-pause-overlay::before { content:''; position:absolute; inset:0; background:rgba(2,6,23,0.6); }
.kw-pause-menu { position:relative; z-index:230; background:linear-gradient(180deg, rgba(6,8,14,0.95), rgba(10,12,20,0.98)); padding:28px 36px; border-radius:12px; box-shadow: 0 12px 40px rgba(2,6,23,0.6); text-align:center; min-width:260px; }
.kw-pause-menu h2 { margin:0 0 16px 0; color:#e2e8f0; font-size:20px; letter-spacing:1px; }
.kw-pause-actions { display:flex; flex-direction:column; gap:10px; }
.kw-pause-actions .game-btn { min-width:180px; margin:0 auto; }

.kw-seo-intro, .kw-game-guide { max-width: 1000px; margin: 0 auto; padding: 2rem 1.25rem; color: #cbd5e1; line-height: 1.7; }
.kw-seo-intro { padding-top: 2.5rem; text-align: center; }
.kw-seo-intro h1, .kw-game-guide h2, .kw-game-guide h3 { color: #f8fafc; }
.kw-seo-intro h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 0 0 .5rem; }
.kw-seo-intro p { margin: 0 auto; max-width: 720px; }
.kw-game-guide { padding-top: .5rem; padding-bottom: 3rem; }
.kw-guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.kw-guide-grid article { background: rgba(15, 23, 42, .72); border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 1rem; }
.kw-game-guide a { color: #67e8f9; }

/* Responsive Adjustments */
@media (max-width: 640px) {
  .kw-hud { height:52px; }
  .kw-state-banner{ top:64px; }
  .kw-modal-panel { max-height: 95vh; margin: 0.5rem; }
  .kw-ctrl-item { min-width: 140px; }
}

/* ── On-Screen Control Buttons (Touch/Mouse) ─────────────────────────── */
.kw-touch-controls {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 150;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.kw-touch-group {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.kw-touch-btn {
  background: rgba(15, 23, 42, 0.85);
  color: #00e5ff;
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-bottom: 3px solid rgba(0, 150, 200, 0.6);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.12s ease;
  user-select: none;
}
.kw-touch-btn:hover, .kw-touch-btn:focus-visible {
  border-color: #00e5ff;
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
}
.kw-touch-btn:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
}
.kw-touch-jump {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}
.kw-touch-crouch {
  color: #a855f7;
  border-color: rgba(168, 85, 247, 0.4);
}
.kw-touch-special {
  color: #ffea00;
  border-color: rgba(255, 234, 0, 0.4);
}

/* Prefers-reduced-motion support */
@media (prefers-reduced-motion: reduce) {
  .kw-layer, .kw-modal-panel, .kw-help-hint { animation: none !important; transition: none !important; }
}
