/* ===== MUSCLE MATCH 3 - DARK NEON THEME ===== */

:root {
  --bg: #0a0a0f;
  --surface: #14141f;
  --neon-pink: #ff1493;
  --neon-cyan: #00e5ff;
  --neon-green: #39ff14;
  --neon-gold: #ffd700;
  --text: #e0e0e0;
  --text-dim: #888;
  --board-size: min(90vw, 420px);
  --cell-size: calc(var(--board-size) / 8);
}

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

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

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

/* ===== SCREENS ===== */
.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

.en {
  font-size: 0.7em;
  color: var(--text-dim);
  font-weight: normal;
}

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

.title-emoji {
  font-size: 64px;
  display: block;
  margin-bottom: 8px;
  animation: pulse 1.5s ease-in-out infinite;
}

.title-content h1 {
  font-size: 2.2em;
  background: linear-gradient(135deg, var(--neon-pink), var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  margin-bottom: 4px;
}

.title-sub {
  font-size: 1em;
  color: var(--text-dim);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.title-pieces {
  font-size: 32px;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.title-pieces span {
  animation: bounce 1.2s ease-in-out infinite;
}
.title-pieces span:nth-child(2) { animation-delay: 0.1s; }
.title-pieces span:nth-child(3) { animation-delay: 0.2s; }
.title-pieces span:nth-child(4) { animation-delay: 0.3s; }
.title-pieces span:nth-child(5) { animation-delay: 0.4s; }
.title-pieces span:nth-child(6) { animation-delay: 0.5s; }

.title-desc {
  font-size: 0.95em;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.6;
}

.how-to-play {
  background: var(--surface);
  border: 1px solid rgba(255, 20, 147, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  text-align: left;
}

.how-to-play h3 {
  font-size: 1em;
  color: var(--neon-cyan);
  margin-bottom: 8px;
  text-align: center;
}

.how-to-play ul {
  list-style: none;
  font-size: 0.85em;
  line-height: 1.8;
}

.how-to-play li {
  padding-left: 20px;
  position: relative;
}

.how-to-play li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--neon-green);
}

/* ===== BUTTONS ===== */
.btn-neon {
  display: inline-block;
  padding: 14px 40px;
  font-size: 1.1em;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, var(--neon-pink), #ff006a);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(255, 20, 147, 0.4);
  text-align: center;
  line-height: 1.4;
  margin: 6px;
}

.btn-neon:hover, .btn-neon:active {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(255, 20, 147, 0.6);
}

.btn-share {
  background: linear-gradient(135deg, var(--neon-cyan), #0090ff);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

.btn-share:hover, .btn-share:active {
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.6);
}

.btn-secondary {
  background: var(--surface);
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.btn-secondary:hover, .btn-secondary:active {
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

/* ===== PATREON LINK ===== */
.patreon-link {
  margin-top: 20px;
}

.patreon-link a {
  display: inline-block;
  padding: 10px 24px;
  background: var(--surface);
  border: 1px solid var(--neon-gold);
  border-radius: 30px;
  color: var(--neon-gold);
  text-decoration: none;
  font-size: 0.85em;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.15);
}

.patreon-link a:hover {
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
  transform: scale(1.03);
}

/* ===== GAME HUD ===== */
.game-hud {
  display: flex;
  justify-content: space-around;
  width: var(--board-size);
  max-width: 420px;
  margin: 0 auto;
  padding: 10px 0;
}

.hud-item {
  text-align: center;
}

.hud-label {
  font-size: 0.75em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.hud-value {
  font-size: 1.6em;
  font-weight: bold;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
  min-width: 60px;
}

#time-display {
  color: var(--neon-green);
  text-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
}

#time-display.warning {
  color: var(--neon-pink);
  text-shadow: 0 0 10px rgba(255, 20, 147, 0.5);
  animation: pulse 0.5s ease-in-out infinite;
}

#combo-display.active {
  color: var(--neon-gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  animation: comboGlow 0.3s ease;
}

/* ===== COMBO POPUP ===== */
.combo-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2em;
  font-weight: bold;
  color: var(--neon-gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  pointer-events: none;
  z-index: 100;
  transition: all 0.3s ease;
}

.combo-popup.hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
}

.combo-popup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.2);
  animation: comboPopAnim 0.6s ease forwards;
}

/* ===== GAME BOARD ===== */
#game-screen {
  flex-direction: column;
}

.game-board {
  width: var(--board-size);
  height: var(--board-size);
  max-width: 420px;
  max-height: 420px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  background: var(--surface);
  border: 2px solid rgba(255, 20, 147, 0.3);
  border-radius: 12px;
  padding: 4px;
  position: relative;
  overflow: hidden;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.55);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  position: relative;
}

.cell:active {
  transform: scale(0.9);
}

.cell.selected {
  background: rgba(0, 229, 255, 0.25);
  box-shadow: inset 0 0 8px rgba(0, 229, 255, 0.5);
  animation: selectedPulse 0.6s ease-in-out infinite;
}

.cell.hint {
  animation: hintPulse 1s ease-in-out infinite;
}

.cell.matched {
  animation: matchPop 0.35s ease forwards;
}

.cell.falling {
  animation: fallIn 0.3s ease-out;
}

.cell.swap-left { animation: swapLeft 0.2s ease; }
.cell.swap-right { animation: swapRight 0.2s ease; }
.cell.swap-up { animation: swapUp 0.2s ease; }
.cell.swap-down { animation: swapDown 0.2s ease; }

.cell.invalid-swap {
  animation: shake 0.3s ease;
}

/* ===== SCORE FLOAT ===== */
.score-float {
  position: absolute;
  font-size: 0.9em;
  font-weight: bold;
  color: var(--neon-gold);
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
  pointer-events: none;
  animation: floatUp 0.8s ease-out forwards;
  z-index: 50;
}

/* ===== RESULT SCREEN ===== */
.result-content {
  text-align: center;
  padding: 20px;
  max-width: 420px;
  width: 100%;
}

.result-title {
  font-size: 2em;
  background: linear-gradient(135deg, var(--neon-pink), var(--neon-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.result-emoji {
  font-size: 48px;
  margin-bottom: 20px;
  animation: pulse 1.5s ease-in-out infinite;
}

.result-stats {
  background: var(--surface);
  border: 1px solid rgba(255, 20, 147, 0.3);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  font-size: 0.9em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.4em;
  font-weight: bold;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.result-rank {
  font-size: 1.3em;
  font-weight: bold;
  margin-bottom: 20px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
}

.result-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.result-buttons .btn-neon {
  padding: 12px 28px;
  font-size: 0.95em;
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

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

@keyframes selectedPulse {
  0%, 100% { box-shadow: inset 0 0 8px rgba(0, 229, 255, 0.5); }
  50% { box-shadow: inset 0 0 16px rgba(0, 229, 255, 0.8); }
}

@keyframes hintPulse {
  0%, 100% { background: rgba(255, 255, 255, 0.03); }
  50% { background: rgba(57, 255, 20, 0.15); }
}

@keyframes matchPop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.8; }
  100% { transform: scale(0); opacity: 0; }
}

@keyframes fallIn {
  0% { transform: translateY(-100%); opacity: 0.5; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes swapLeft { 0% { transform: translateX(100%); } 100% { transform: translateX(0); } }
@keyframes swapRight { 0% { transform: translateX(-100%); } 100% { transform: translateX(0); } }
@keyframes swapUp { 0% { transform: translateY(100%); } 100% { transform: translateY(0); } }
@keyframes swapDown { 0% { transform: translateY(-100%); } 100% { transform: translateY(0); } }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-50px) scale(1.3); }
}

@keyframes comboPopAnim {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1) translateY(-30px); }
}

@keyframes comboGlow {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== RESPONSIVE ===== */
@media (max-height: 600px) {
  .title-emoji { font-size: 40px; }
  .title-content h1 { font-size: 1.6em; }
  .how-to-play { padding: 8px 12px; margin-bottom: 12px; }
  .how-to-play ul { font-size: 0.75em; }
  .btn-neon { padding: 10px 30px; font-size: 0.95em; }
}

@media (min-width: 768px) {
  .title-content h1 { font-size: 2.8em; }
  .cell { font-size: calc(var(--cell-size) * 0.6); }
}
