/* ==========================================================================
   CSS Variables & Resets
   ========================================================================== */
:root {
  /* Palette */
  --c-red: #dc2626;
  --c-ink: #0a0a0a;
  --c-yellow: #facc15;
  --c-white: #fafafa;
  --c-gray: #333333;
  
  /* Layout */
  --max-width: 600px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--c-ink);
  color: var(--c-white);
  font-family: 'Space Mono', monospace;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Typography
   ========================================================================== */
.font-display {
  font-family: 'Anton', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.font-mono {
  font-family: 'Space Mono', monospace;
}

.text-red { color: var(--c-red); }
.text-yellow { color: var(--c-yellow); }
.text-center { text-align: center; }

h1 { font-size: clamp(3rem, 10vw, 4.5rem); margin-bottom: 0.5rem; }
h2 { font-size: clamp(2rem, 6vw, 3rem); margin-bottom: 1rem; }

/* ==========================================================================
   Layout & Containers
   ========================================================================== */
.app-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.3s ease-out forwards;
}

.content-wrapper {
  padding: 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 2;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Components: Hero & Start View
   ========================================================================== */
.hero-image {
  width: 100%;
  height: 40vh;
  min-height: 250px;
  background-size: cover;
  background-position: center;
  position: relative;
  border-bottom: 4px solid var(--c-red);
}

.hero-image::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(to top, var(--c-ink) 0%, transparent 100%);
}

.start-header {
  margin-top: -3rem;
  margin-bottom: 2rem;
  position: relative;
  text-align: center;
  text-shadow: 2px 2px 0 var(--c-ink), -2px -2px 0 var(--c-ink);
}

.subtitle {
  color: var(--c-yellow);
  font-size: 1.1rem;
  font-weight: 700;
}

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */
.entry-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.input-group {
  width: 100%;
}

input[type="text"],
input[type="email"] {
  width: 100%;
  background: transparent;
  border: 2px solid var(--c-gray);
  color: var(--c-white);
  padding: 1.2rem;
  font-family: 'Space Mono', monospace;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus {
  border-color: var(--c-yellow);
  box-shadow: 4px 4px 0 var(--c-yellow);
}

input::placeholder {
  color: #666;
}

.incentive-text {
  text-align: center;
  font-size: 0.9rem;
  color: #888;
  margin-top: 1rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  width: 100%;
  padding: 1.2rem 2rem;
  font-size: 1.5rem;
  cursor: pointer;
  border: 2px solid var(--c-white);
  outline: none;
  transition: all 0.1s ease;
  user-select: none;
}

.btn-primary {
  background-color: var(--c-red);
  color: var(--c-white);
  box-shadow: 6px 6px 0 var(--c-yellow);
}

.btn-primary:active {
  transform: translate(6px, 6px);
  box-shadow: 0px 0px 0 var(--c-yellow);
}

.btn-secondary {
  background-color: transparent;
  color: var(--c-white);
  border-color: var(--c-gray);
  font-size: 1.2rem;
}

.btn-secondary:hover {
  border-color: var(--c-white);
}

.btn-secondary:active {
  background-color: var(--c-gray);
}

/* ==========================================================================
   Game View
   ========================================================================== */
.game-hud {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom: 2px solid var(--c-gray);
}

.timer-container {
  margin-bottom: 1rem;
}

#timer-display {
  font-size: 5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--c-yellow);
  text-shadow: 0 0 20px rgba(250, 204, 21, 0.3);
}

.timer-warning {
  color: var(--c-red) !important;
  text-shadow: 0 0 20px rgba(220, 38, 38, 0.5) !important;
  animation: urgentPulse 0.5s infinite alternate !important;
}

.stats-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  font-weight: 700;
}

.combo {
  color: var(--c-yellow);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-high {
  color: var(--c-red);
  font-size: 1.2rem;
  text-shadow: 2px 2px 0 var(--c-white);
}

.question-container {
  padding: 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#question-text {
  text-align: center;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.answers-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 2rem;
}

.answer-btn {
  background: var(--c-ink);
  color: var(--c-white);
  border: 2px solid var(--c-gray);
  padding: 1.2rem;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s ease;
  position: relative;
  overflow: hidden;
}

.answer-btn:hover {
  border-color: var(--c-white);
  transform: translateX(5px);
}

.answer-btn:active {
  background: var(--c-gray);
}

.answer-btn.correct {
  background: var(--c-yellow);
  color: var(--c-ink);
  border-color: var(--c-yellow);
}

.answer-btn.wrong {
  background: var(--c-red);
  color: var(--c-white);
  border-color: var(--c-red);
}

.game-controls {
  padding: 1rem 2rem 2rem;
}

/* ==========================================================================
   Results View
   ========================================================================== */
.results-header {
  margin-bottom: 2rem;
}

.score-card {
  background: rgba(255,255,255,0.05);
  border: 2px solid var(--c-gray);
  padding: 2rem;
  margin-bottom: 2rem;
}

.score-main {
  font-size: 6rem;
  line-height: 1;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.5rem;
}

#res-score {
  font-size: 7rem;
}

.score-divider {
  color: #666;
}

.score-label {
  color: #888;
  margin-top: 1rem;
  letter-spacing: 0.1em;
}

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

.stat-box {
  background: transparent;
  border: 1px solid var(--c-gray);
  padding: 1rem 0.5rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.8rem;
  color: #888;
}

.pb-display {
  margin-bottom: 2rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.results-actions {
  margin-bottom: 2rem;
}

.share-box {
  border: 1px dashed var(--c-gray);
  padding: 1.5rem;
  margin-top: 1rem;
}

.share-input-group {
  display: flex;
  margin-top: 1rem;
  gap: 0.5rem;
}

.share-input-group input {
  flex: 1;
  padding: 0.8rem;
}

.share-input-group .btn {
  width: auto;
  padding: 0.8rem 1.5rem;
  box-shadow: none;
}

/* ==========================================================================
   Utility & Animations
   ========================================================================== */
#error-toast {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--c-red);
  color: var(--c-white);
  text-align: center;
  padding: 1rem;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  z-index: 1000;
}

#wbx-powered-by-slot {
  margin: auto auto 1rem auto;
  width: 100%;
}

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

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes urgentPulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.05); opacity: 0.8; }
}

.pulse-text {
  animation: mildPulse 2s infinite alternate;
}

@keyframes mildPulse {
  from { opacity: 0.8; }
  to { opacity: 1; }
}

/* Screen Flash overlay for wrong answer */
.flash-red {
  animation: flashRed 0.3s ease-out;
}
@keyframes flashRed {
  0% { background-color: rgba(220, 38, 38, 0.3); }
  100% { background-color: var(--c-ink); }
}

/* Screen Flash overlay for correct answer */
.flash-yellow {
  animation: flashYellow 0.3s ease-out;
}
@keyframes flashYellow {
  0% { background-color: rgba(250, 204, 21, 0.15); }
  100% { background-color: var(--c-ink); }
}