/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --pink: #ff2d7b;
  --cyan: #00f0ff;
  --dark: #0a0a0f;
  --dark2: #12121a;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --green: #00ff88;
  --red: #ff3344;
  --text: #ffffff;
  --text-dim: #888899;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--dark);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ==================== SCREENS ==================== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.screen.active {
  display: flex;
}

/* ==================== TITLE SCREEN ==================== */
.title-container {
  text-align: center;
  padding: 20px;
  max-width: 500px;
  width: 100%;
}

.brand {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  color: var(--pink);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.brand.small {
  font-size: 12px;
  margin-bottom: 8px;
}

.game-title {
  margin-bottom: 16px;
}

.title-jp {
  display: block;
  font-size: clamp(28px, 7vw, 48px);
  font-weight: 900;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.title-en {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(14px, 3.5vw, 22px);
  color: var(--cyan);
  letter-spacing: 3px;
  margin-top: 4px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.how-to-play {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}

.how-step {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-dim);
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  color: white;
  font-weight: 900;
  font-size: 14px;
  flex-shrink: 0;
}

/* ==================== BUTTONS ==================== */
.btn-main {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 48px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--pink), #ff6b9d);
  color: white;
  font-family: 'Orbitron', sans-serif;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 30px rgba(255, 45, 123, 0.3);
  min-width: 200px;
}

.btn-main .btn-sub {
  display: block;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 2px;
}

.btn-main:active {
  transform: scale(0.95);
}

.btn-main.share {
  background: linear-gradient(135deg, var(--cyan), #0088ff);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ==================== PATREON ==================== */
.patreon-link {
  display: inline-block;
  margin-top: 24px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}

.patreon-link:hover {
  color: var(--pink);
}

.patreon-cta {
  display: block;
  margin-top: 24px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(255, 45, 123, 0.15), rgba(0, 240, 255, 0.1));
  border: 1px solid rgba(255, 45, 123, 0.3);
  border-radius: 16px;
  text-decoration: none;
  text-align: center;
  transition: border-color 0.3s, transform 0.2s;
}

.patreon-cta:active {
  transform: scale(0.98);
}

.patreon-cta:hover {
  border-color: var(--pink);
}

.patreon-cta-text {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 8px;
}

.patreon-cta-btn {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--pink);
}

/* ==================== GAME SCREEN ==================== */
.round-indicator {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  color: var(--text-dim);
  z-index: 10;
  background: rgba(0, 0, 0, 0.6);
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.phase {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.phase.active {
  display: flex;
}

/* Wait phase */
#phase-wait {
  background: var(--dark);
  cursor: default;
}

.wait-text {
  text-align: center;
  animation: waitPulse 1.5s ease-in-out infinite;
}

.wait-jp {
  display: block;
  font-size: clamp(36px, 10vw, 64px);
  font-weight: 900;
  color: var(--red);
}

.wait-en {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(18px, 5vw, 32px);
  color: var(--red);
  opacity: 0.7;
  margin-top: 4px;
}

.wait-warning {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
}

@keyframes waitPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* GO phase */
#phase-go {
  background: var(--dark);
  cursor: pointer;
}

.go-image-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.go-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.go-text {
  position: fixed;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(48px, 15vw, 96px);
  font-weight: 900;
  color: var(--green);
  text-shadow: 0 0 40px rgba(0, 255, 136, 0.6), 0 0 80px rgba(0, 255, 136, 0.3);
  z-index: 5;
  animation: goFlash 0.3s ease-out;
  pointer-events: none;
}

@keyframes goFlash {
  0% { transform: translateX(-50%) scale(2); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Too early phase */
#phase-early {
  background: rgba(255, 0, 0, 0.15);
}

.early-container {
  text-align: center;
  padding: 20px;
}

.early-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-10px); }
  80% { transform: translateX(10px); }
}

.early-text-jp {
  font-size: clamp(32px, 8vw, 56px);
  font-weight: 900;
  color: var(--red);
}

.early-text-en {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(16px, 4vw, 28px);
  color: var(--red);
  opacity: 0.8;
  margin-bottom: 12px;
}

.early-sub {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 24px;
}

/* Round result phase */
#phase-result {
  background: var(--dark);
}

.result-container {
  text-align: center;
  padding: 20px;
}

.result-time {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(64px, 18vw, 120px);
  font-weight: 900;
  color: var(--cyan);
  line-height: 1;
  animation: resultPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-ms {
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.result-rating {
  font-size: clamp(24px, 6vw, 40px);
  font-weight: 900;
  margin-bottom: 20px;
  min-height: 48px;
}

@keyframes resultPop {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-image-small {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 24px;
  border: 3px solid var(--pink);
}

.result-image-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Rating colors */
.rating-godlike {
  background: linear-gradient(90deg, #ff0000, #ff8800, #ffff00, #00ff00, #0088ff, #8800ff, #ff0000);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: rainbow 1s linear infinite;
}

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

.rating-lightning {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.rating-fast {
  color: var(--silver);
  text-shadow: 0 0 15px rgba(192, 192, 192, 0.4);
}

.rating-average {
  color: var(--text-dim);
}

.rating-slow {
  color: #666;
}

/* ==================== FINAL SCREEN ==================== */
.final-container {
  text-align: center;
  padding: 20px;
  max-width: 500px;
  width: 100%;
  max-height: 100vh;
  overflow-y: auto;
}

.final-title {
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 900;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.final-stats {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px 24px;
  min-width: 120px;
}

.stat-box.best {
  border-color: var(--cyan);
  background: rgba(0, 240, 255, 0.08);
}

.stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.stat-value {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 900;
  color: var(--cyan);
}

.stat-unit {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  color: var(--text-dim);
}

.final-rating {
  font-size: clamp(22px, 5.5vw, 36px);
  font-weight: 900;
  margin-bottom: 16px;
  min-height: 44px;
}

.final-rounds {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.round-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
}

.round-row-label {
  color: var(--text-dim);
}

.round-row-time {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--cyan);
}

.round-row-rating {
  font-size: 12px;
  font-weight: 700;
}

.final-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.final-buttons .btn-main {
  width: 100%;
  max-width: 300px;
  font-size: 16px;
  padding: 14px 24px;
}

/* ==================== FLASH OVERLAY ==================== */
.flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}

.flash-overlay.flash-green {
  background: var(--green);
  opacity: 0.4;
  animation: flashOut 0.3s ease-out forwards;
}

.flash-overlay.flash-red {
  background: var(--red);
  opacity: 0.4;
  animation: flashOut 0.3s ease-out forwards;
}

@keyframes flashOut {
  0% { opacity: 0.4; }
  100% { opacity: 0; }
}

/* ==================== RESPONSIVE ==================== */
@media (max-height: 600px) {
  .how-to-play {
    margin-bottom: 16px;
  }
  .how-step {
    padding: 6px 12px;
    font-size: 12px;
  }
  .subtitle {
    margin-bottom: 12px;
    font-size: 12px;
  }
  .btn-main {
    padding: 12px 36px;
    font-size: 18px;
  }
  .final-container {
    padding: 10px 16px;
  }
  .stat-box {
    padding: 10px 16px;
  }
}

@media (min-width: 768px) {
  .how-to-play {
    flex-direction: row;
    justify-content: center;
  }
  .how-step {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding: 14px 20px;
  }
}
