/* 
 * Pulse Recall Style Sheet 
 * Custom Minimalist Design System for NNPLAYS
 */

:root {
  --bg-color: #121212;
  --panel-bg: #1a1a1a;
  --grid-line: #f4f1eb;
  --pulse-color: #ffd23f;
  --input-color: #3b82f6;
  --success-color: #10b981;
  --error-color: #ef4444;
  --text-primary: #f4f1eb;
  --text-muted: #888888;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --border-radius: 12px;
  --border-radius-sm: 6px;
  --transition-speed: 0.25s;
  --pulse-speed: 1x;
}

/* Reduced Motion Settings */
@media (prefers-reduced-motion: reduce) {
  body {
    --transition-speed: 0s !important;
  }
}

.reduced-motion {
  --transition-speed: 0s !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-family);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  width: 100%;
  max-width: 600px;
  height: 100%;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--bg-color);
}

/* Screen Management */
.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  justify-content: space-between;
  align-items: center;
  animation: fadeIn 0.3s ease-out;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Headers and Titles */
h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  text-align: center;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.title-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 40px;
}

.title-logo span.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* Minimalist Button Styling */
button.btn {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--grid-line);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--border-radius);
  cursor: pointer;
  width: 100%;
  max-width: 280px;
  transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.btn:hover, button.btn:focus-visible {
  background: var(--text-primary);
  color: var(--bg-color);
  transform: translateY(-2px);
}

button.btn:active {
  transform: translateY(0);
}

button.btn-primary {
  border-color: var(--pulse-color);
  color: var(--pulse-color);
}

button.btn-primary:hover, button.btn-primary:focus-visible {
  background: var(--pulse-color);
  color: var(--bg-color);
}

button.btn-text {
  border: none;
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: transparent;
}

button.btn-text:hover, button.btn-text:focus-visible {
  color: var(--text-primary);
  transform: none;
  background: rgba(255, 255, 255, 0.05);
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
  margin-bottom: 40px;
}

/* Layout Panels */
.panel {
  background: var(--panel-bg);
  border: 1px solid rgba(244, 241, 235, 0.1);
  border-radius: var(--border-radius);
  padding: 20px;
  width: 100%;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Gameplay Header */
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 0 16px 0;
  border-bottom: 1px solid rgba(244, 241, 235, 0.1);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.hud-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.hud-value.highlight {
  color: var(--pulse-color);
}

/* Rule Indicator Display */
.rule-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(244, 241, 235, 0.2);
  border-radius: var(--border-radius);
  padding: 14px 20px;
  width: 100%;
  margin: 12px 0;
  text-align: center;
  min-height: 80px;
}

.rule-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.rule-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--pulse-color);
}

.rule-icon {
  font-size: 1.4rem;
}

.rule-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Grid Board styles */
.grid-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  flex-grow: 1;
  padding: 16px 0;
}

.grid-board {
  display: grid;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 380px;
  max-height: 380px;
  background: rgba(255, 255, 255, 0.02);
  border: 2px solid var(--grid-line);
  border-radius: var(--border-radius);
  padding: 12px;
  gap: 12px;
  position: relative;
  transition: transform var(--transition-speed) cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.grid-board.grid-3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.grid-board.grid-4 {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
}

.grid-board.grid-5 {
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 6px;
  padding: 6px;
}

/* Grid Cells */
.grid-cell {
  background: transparent;
  border: 1px solid rgba(244, 241, 235, 0.3);
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  transition: background-color var(--transition-speed) ease, 
              border-color var(--transition-speed) ease,
              transform 0.1s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  outline: none;
  aspect-ratio: 1/1;
}

/* Hover & Focus state */
.grid-cell:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(244, 241, 235, 0.6);
}

.grid-cell:focus-visible {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(244, 241, 235, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.grid-cell:active {
  transform: scale(0.95);
}

/* Grid cell accessibility shapes */
.cell-shape {
  position: absolute;
  width: 25%;
  height: 25%;
  border-radius: 50%;
  background: transparent;
  transition: all var(--transition-speed) ease;
  pointer-events: none;
  opacity: 0.15;
}

.grid-3 .cell-shape { width: 20%; height: 20%; }
.grid-4 .cell-shape { width: 18%; height: 18%; }
.grid-5 .cell-shape { width: 14%; height: 14%; }

/* Default cell shape pattern helper for colorblind accessibility */
.grid-cell::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: rgba(244, 241, 235, 0.2);
  border-radius: 50%;
  pointer-events: none;
}

/* Active playback pulse state */
.grid-cell.pulse {
  background-color: var(--pulse-color) !important;
  border-color: var(--pulse-color) !important;
  box-shadow: 0 0 20px var(--pulse-color);
  animation: pulseScale 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.grid-cell.pulse::after {
  background: var(--bg-color) !important;
  width: 12px;
  height: 12px;
}

/* Double Beat playback pulse state */
.grid-cell.pulse.double-beat-pulse {
  box-shadow: 0 0 25px var(--pulse-color), 0 0 0 4px var(--bg-color), 0 0 0 6px var(--pulse-color);
}

/* Skip playback state */
.grid-cell.pulse.skip-pulse {
  background-color: #555555 !important;
  border-color: #777777 !important;
  box-shadow: none;
}

.grid-cell.pulse.skip-pulse::after {
  content: '×';
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-primary);
  background: transparent !important;
  border-radius: 0;
  width: auto;
  height: auto;
}

/* Tapped state */
.grid-cell.tapped {
  background-color: rgba(59, 130, 246, 0.2) !important;
  border-color: var(--input-color) !important;
  border-style: dashed;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.grid-cell.tapped::after {
  background: var(--input-color);
  border-radius: 3px; /* square center for tapped */
  width: 8px;
  height: 8px;
}

/* Correct feedback state */
.grid-cell.success-flash {
  background-color: var(--success-color) !important;
  border-color: var(--success-color) !important;
  box-shadow: 0 0 20px var(--success-color);
  transition: none;
}

/* Error feedback state */
.grid-cell.error-flash {
  background-color: var(--error-color) !important;
  border-color: var(--error-color) !important;
  box-shadow: 0 0 20px var(--error-color);
  transition: none;
}

/* Correct path indicator show */
.grid-cell.expected-path {
  border-color: var(--pulse-color) !important;
  background-color: rgba(255, 210, 63, 0.1) !important;
  box-shadow: 0 0 8px rgba(255, 210, 63, 0.2);
}

.grid-cell.expected-path::after {
  background: var(--pulse-color);
  width: 10px;
  height: 10px;
}

/* Keyframe animations */
@keyframes pulseScale {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Success Ripple wave */
@keyframes successRipple {
  0% { transform: scale(1); background-color: transparent; }
  30% { transform: scale(1.08); background-color: rgba(16, 185, 129, 0.3); border-color: var(--success-color); }
  100% { transform: scale(1); background-color: transparent; }
}

.grid-cell.ripple-effect {
  animation: successRipple 0.5s ease-out;
}

/* Screen shake for mistakes */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

/* Info message on UI */
.info-msg {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0;
  min-height: 20px;
}

.info-msg.warning {
  color: var(--error-color);
}

.info-msg.success {
  color: var(--success-color);
}

/* Tutorial Layout */
.tutorial-box {
  width: 100%;
  max-width: 450px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tutorial-step {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tutorial-step.active {
  display: block;
}

.tut-graphic {
  width: 100%;
  height: 160px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(244, 241, 235, 0.1);
  border-radius: var(--border-radius);
  margin: 16px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.tut-cell-demo {
  width: 60px;
  height: 60px;
  border: 1px solid rgba(244, 241, 235, 0.3);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.tut-cell-demo.active-demo {
  background-color: var(--pulse-color);
  box-shadow: 0 0 15px var(--pulse-color);
}

.tut-cell-demo.input-demo {
  border-color: var(--input-color);
  border-style: dashed;
  background-color: rgba(59, 130, 246, 0.2);
}

.tut-cell-demo.double-demo {
  box-shadow: 0 0 15px var(--pulse-color), 0 0 0 3px var(--bg-color), 0 0 0 5px var(--pulse-color);
  background-color: var(--pulse-color);
}

.tut-cell-demo.skip-demo {
  background-color: #555;
  border-color: #777;
}

.tut-cell-demo.skip-demo::after {
  content: '×';
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
}

.tut-desc {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
  text-align: center;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
}

.tut-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
}

.tut-dot.active {
  background: var(--pulse-color);
}

/* Stats / Leaderboard screen */
.stats-scroll {
  width: 100%;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.stats-scroll::-webkit-scrollbar {
  width: 6px;
}

.stats-scroll::-webkit-scrollbar-thumb {
  background: rgba(244, 241, 235, 0.2);
  border-radius: 3px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(244, 241, 235, 0.08);
  border-radius: var(--border-radius-sm);
  padding: 12px;
  text-align: center;
}

.stat-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--pulse-color);
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.01);
  border-bottom: 1px solid rgba(244, 241, 235, 0.05);
  font-size: 0.85rem;
}

.history-item:last-child {
  border-bottom: none;
}

/* Settings Form elements */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  padding: 10px 0;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(244, 241, 235, 0.05);
}

.setting-info {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.setting-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.setting-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Accessible Checkbox/Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: .2s;
  border-radius: 24px;
  border: 1px solid rgba(244, 241, 235, 0.15);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-primary);
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--pulse-color);
  border-color: var(--pulse-color);
}

input:checked + .slider:before {
  transform: translateX(24px);
  background-color: var(--bg-color);
}

/* Practice Modifier Selector */
.modifier-select-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  margin: 10px 0;
}

.modifier-option {
  border: 1px solid rgba(244, 241, 235, 0.15);
  border-radius: var(--border-radius-sm);
  padding: 10px;
  text-align: center;
  font-size: 0.85rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: all var(--transition-speed) ease;
}

.modifier-option.selected {
  border-color: var(--pulse-color);
  background: rgba(255, 210, 63, 0.1);
  color: var(--pulse-color);
  font-weight: 600;
}

.grid-select-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.grid-option {
  flex: 1;
  border: 1px solid rgba(244, 241, 235, 0.15);
  border-radius: var(--border-radius-sm);
  padding: 8px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: all var(--transition-speed) ease;
}

.grid-option.selected {
  border-color: var(--pulse-color);
  background: rgba(255, 210, 63, 0.1);
  color: var(--pulse-color);
  font-weight: 600;
}

/* Guest Score Nudge Wrapper in Game */
.nn-score-nudge {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--border-radius);
  padding: 14px;
  margin-top: 14px;
  width: 100%;
  text-align: center;
}

.nn-score-nudge p {
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.nn-nudge-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.nn-nudge-signup {
  background: var(--input-color);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.nn-nudge-later {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(244, 241, 235, 0.2);
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
}

.nn-nudge-later:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

/* Results Details */
.results-board {
  text-align: center;
  margin-top: 20px;
}

.results-score-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.results-score-val {
  font-size: 3.2rem;
  font-weight: 900;
  color: var(--pulse-color);
  line-height: 1.1;
  margin-bottom: 10px;
}

.results-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
}

.results-badge.fail {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error-color);
}

.results-stats-row {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin: 16px 0;
  border-top: 1px solid rgba(244, 241, 235, 0.08);
  border-bottom: 1px solid rgba(244, 241, 235, 0.08);
  padding: 16px 0;
}

.results-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.results-stat .lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.results-stat .val {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Footer credits */
.game-footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(244, 241, 235, 0.05);
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
}

.footer-link:hover {
  color: var(--text-primary);
}
