:root {
  --stripe-a: #ffcb05;
  --stripe-b: #1a1a2e;
  --accent: #ff6b35;
  --card-bg: rgba(255, 255, 255, 0.08);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  overflow: hidden;
  text-align: center;
  background: linear-gradient(-45deg, #1a1a2e, #16213e, #0f3460, #533483);
  background-size: 400% 400%;
  animation: gradientShift 16s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---------- Card ---------- */
.card {
  position: relative;
  z-index: 2;
  width: min(560px, 100%);
  padding: 2.5rem 2rem 2rem;
  border-radius: 24px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px dashed var(--stripe-a);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  animation: floatIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Worker emoji ---------- */
.hardhat {
  font-size: 5rem;
  line-height: 1;
  display: inline-block;
  cursor: pointer;
  animation: bob 2.4s ease-in-out infinite;
  user-select: none;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-12px) rotate(3deg); }
}

.hardhat.spin {
  animation: spin 0.7s ease;
}

@keyframes spin {
  to { transform: rotate(360deg) scale(1.15); }
}

/* ---------- Title ---------- */
.title {
  margin: 0.75rem 0 0.5rem;
  font-size: clamp(2rem, 7vw, 3.25rem);
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

/* Each word stays on a single line; wrapping only happens between words. */
.title .word {
  display: inline-block;
  white-space: nowrap;
}

.title .word + .word {
  margin-left: 0.35em;
}

.title .word > span {
  display: inline-block;
  animation: wave 2.4s ease-in-out infinite;
}

/* stagger each letter */
.title .word > span:nth-child(odd) { animation-delay: 0.1s; }
.title .word > span:nth-child(3n) { animation-delay: 0.2s; color: var(--stripe-a); }
.title .word > span:nth-child(5n) { animation-delay: 0.35s; color: var(--accent); }

@keyframes wave {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---------- Tagline ---------- */
.tagline {
  font-size: 1.05rem;
  opacity: 0.9;
  margin-bottom: 1.5rem;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Progress bar (barber pole) ---------- */
.progress {
  position: relative;
  height: 26px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 14px;
  transition: width 0.4s ease;
  background-image: repeating-linear-gradient(
    45deg,
    var(--stripe-a),
    var(--stripe-a) 14px,
    var(--stripe-b) 14px,
    var(--stripe-b) 28px
  );
  background-size: 56px 56px;
  animation: barberpole 1.2s linear infinite;
}

@keyframes barberpole {
  from { background-position: 0 0; }
  to { background-position: 56px 0; }
}

.progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* ---------- CTA button ---------- */
.cta {
  margin-top: 1.5rem;
  padding: 0.85rem 1.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a2e;
  background: var(--stripe-a);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 0 #c79b00;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #c79b00;
}

.cta:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #c79b00;
}

/* ---------- Game launch link ---------- */
.game-link {
  display: inline-block;
  margin-top: 1.75rem;
  padding: 0.7rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 5px 0 #c34d1c;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  animation: gamePulse 2.2s ease-in-out infinite;
}

.game-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #c34d1c;
}

.game-link:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #c34d1c;
}

@keyframes gamePulse {
  0%, 100% { box-shadow: 0 5px 0 #c34d1c, 0 0 0 0 rgba(255, 107, 53, 0.5); }
  50% { box-shadow: 0 5px 0 #c34d1c, 0 0 0 10px rgba(255, 107, 53, 0); }
}

/* ---------- Game modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(360px, 100%);
  background: #16213e;
  border: 2px solid var(--stripe-a);
  border-radius: 20px;
  padding: 1.1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: floatIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease;
}

.modal-close:hover {
  background: rgba(255, 107, 53, 0.8);
}

.game-hud {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  padding: 0 0.2rem;
}

.game-hud b {
  color: var(--stripe-a);
}

.game-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #0d1530;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.game-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 1rem;
  background: rgba(13, 21, 48, 0.82);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.game-message.show {
  opacity: 1;
  pointer-events: auto;
}

.game-message p {
  font-size: 1rem;
  line-height: 1.5;
}

.game-message .cta {
  margin-top: 0;
}

.game-hint {
  margin-top: 0.7rem;
  text-align: center;
  font-size: 0.72rem;
  opacity: 0.55;
}

/* ---------- Countdown ---------- */
.countdown {
  margin-top: 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0.85;
  min-height: 1.4em;
}

.countdown b {
  color: var(--stripe-a);
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  opacity: 0.55;
  font-style: italic;
}

/* ---------- Floating emojis ---------- */
.floaties {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.floatie {
  position: absolute;
  bottom: -60px;
  font-size: 2rem;
  opacity: 0.6;
  animation: rise linear infinite;
}

@keyframes rise {
  to {
    transform: translateY(-110vh) rotate(360deg);
    opacity: 0;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  body,
  .hardhat,
  .title .word > span,
  .progress-fill,
  .floatie,
  .game-link,
  .card {
    animation: none !important;
  }
}
