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

:root {
  --c1: #FF4D6D;
  --c2: #FF9500;
  --c3: #FFD60A;
  --c4: #06D6A0;
  --c5: #4CC9F0;
  --c6: #7B2FBE;
  --bg: #0A0A14;
  --bg2: #12121E;
  --panel: #1A1A2E;
  --text: #F0F0FF;
  --dim: #6060A0;
  --accent: #4CC9F0;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Arial Black', Arial, sans-serif;
  color: var(--text);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

/* ── SCREENS ── */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}
.screen.active {
  opacity: 1; pointer-events: all;
}

/* ── HOME ── */
.logo-wrap {
  position: relative;
  width: 160px; height: 160px;
  margin-bottom: 24px;
}
.logo-hex-ring {
  position: absolute; inset: 0;
  animation: spin 8s linear infinite;
}
.logo-hex {
  position: absolute;
  width: 36px; height: 36px;
  clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%);
}
.logo-hex.h1 { background: var(--c1); top: 0; left: 50%; transform: translateX(-50%); }
.logo-hex.h2 { background: var(--c2); top: 20%; right: 0; }
.logo-hex.h3 { background: var(--c3); bottom: 20%; right: 0; }
.logo-hex.h4 { background: var(--c4); bottom: 0; left: 50%; transform: translateX(-50%); }
.logo-hex.h5 { background: var(--c5); bottom: 20%; left: 0; }
.logo-hex.h6 { background: var(--c6); top: 20%; left: 0; }

.logo-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.logo-text {
  font-size: 32px; font-weight: 900;
  letter-spacing: -1px;
  color: #fff;
  text-shadow: 0 0 20px rgba(255,255,255,0.3);
}
.logo-text.accent { color: var(--accent); text-shadow: 0 0 20px var(--accent); }

.tagline {
  font-size: 14px; letter-spacing: 3px;
  color: var(--dim); margin-bottom: 16px;
  text-transform: uppercase;
}
.home-best {
  font-size: 18px; color: var(--accent);
  letter-spacing: 2px; margin-bottom: 36px;
}

/* ── BUTTONS ── */
.btn-play {
  background: linear-gradient(135deg, var(--accent), #7B2FBE);
  border: none; color: #fff;
  font-family: inherit; font-size: 20px; font-weight: 900;
  letter-spacing: 3px;
  padding: 18px 48px; border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 30px rgba(76,201,240,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  margin-bottom: 16px;
  text-transform: uppercase;
}
.btn-play:active { transform: scale(0.96); box-shadow: 0 2px 15px rgba(76,201,240,0.3); }

.btn-secondary {
  background: transparent;
  border: 2px solid var(--dim);
  color: var(--dim);
  font-family: inherit; font-size: 14px; font-weight: 700;
  letter-spacing: 2px; padding: 12px 32px; border-radius: 50px;
  cursor: pointer; transition: all 0.2s;
  text-transform: uppercase; margin-bottom: 12px;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-tertiary {
  background: transparent; border: none;
  color: var(--dim); font-family: inherit; font-size: 13px;
  letter-spacing: 1px; cursor: pointer;
  padding: 10px; text-transform: uppercase;
}

.home-footer {
  position: absolute; bottom: 24px;
  font-size: 11px; color: var(--dim);
  letter-spacing: 2px;
}

/* ── HUD ── */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px 16px 8px 114px;
  background: linear-gradient(to bottom, rgba(10,10,20,0.95), transparent);
  z-index: 10;
}
.hud-block { text-align: center; min-width: 70px; }
.hud-block.hud-center { flex: 1; }
.hud-label { font-size: 10px; letter-spacing: 2px; color: var(--dim); }
.hud-value { font-size: 24px; font-weight: 900; color: #fff; line-height: 1; }
.hud-level { font-size: 11px; color: var(--accent); letter-spacing: 2px; }

.level-bar-wrap {
  background: rgba(255,255,255,0.1);
  border-radius: 10px; height: 4px;
  margin: 4px 16px;
  overflow: hidden;
}
.level-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--c6));
  border-radius: 10px;
  transition: width 0.3s ease;
}

.combo-display {
  font-size: 13px; font-weight: 900;
  color: var(--c2); letter-spacing: 1px;
  min-height: 18px;
  text-shadow: 0 0 10px var(--c2);
}

/* ── NEXT HEX ── */
#next-hex-wrap {
  position: absolute; top: 80px; right: 12px;
  display: flex; flex-direction: column; align-items: center;
  z-index: 10;
}
.next-label { font-size: 10px; color: var(--dim); letter-spacing: 2px; margin-bottom: 6px; }
.hex-preview {
  width: 44px; height: 44px;
  clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%);
  transition: background 0.2s;
}

/* ── GAME AREA ── */
#game-area {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
#game-canvas {
  display: block;
  image-rendering: crisp-edges;
}

#drop-indicator {
  position: absolute;
  width: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  pointer-events: none;
  top: 60px; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  transition: left 0.05s;
}

/* ── MULTIPLIER FLASH ── */
.multiplier-flash {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 72px; font-weight: 900;
  color: #fff; opacity: 0;
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 0 40px currentColor;
  transition: none;
}
.multiplier-flash.pop {
  animation: multpop 0.6s ease-out forwards;
}

/* ── GAME OVER ── */
.go-title {
  font-size: 42px; font-weight: 900;
  letter-spacing: 4px; margin-bottom: 32px;
  color: var(--c1);
  text-shadow: 0 0 30px var(--c1);
}
.go-label { font-size: 11px; letter-spacing: 3px; color: var(--dim); margin-bottom: 4px; }
.go-score { font-size: 72px; font-weight: 900; color: #fff; line-height: 1; margin-bottom: 8px; }
.go-best { font-size: 32px; font-weight: 900; color: var(--accent); line-height: 1; }
.go-score-wrap { text-align: center; margin-bottom: 16px; }
.go-best-wrap { text-align: center; margin-bottom: 24px; }
.go-stats {
  font-size: 12px; color: var(--dim);
  letter-spacing: 1px; text-align: center;
  margin-bottom: 32px; line-height: 2;
}

.new-best-badge {
  background: linear-gradient(135deg, var(--c2), var(--c1));
  color: #fff; font-size: 14px; font-weight: 900;
  letter-spacing: 3px; padding: 8px 24px;
  border-radius: 50px; margin-bottom: 16px;
  animation: pulse 1s ease-in-out infinite;
}
.new-best-badge.hidden { display: none; }

/* ── CHALLENGE ── */
.challenge-title {
  font-size: 28px; font-weight: 900;
  letter-spacing: 4px; margin-bottom: 16px;
  color: var(--c2);
}
.challenge-score-big {
  font-size: 88px; font-weight: 900;
  color: #fff; line-height: 1; margin-bottom: 16px;
}
.challenge-msg {
  font-size: 14px; color: var(--dim);
  text-align: center; line-height: 1.6; margin-bottom: 40px;
}

/* ── SHARE MODAL ── */
#particles-canvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 100;
}

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-inner {
  background: var(--panel);
  border: 1px solid rgba(76,201,240,0.3);
  border-radius: 20px; padding: 32px;
  max-width: 320px; width: 90%;
  text-align: center;
  position: relative;
}
.modal-title { font-size: 22px; font-weight: 900; letter-spacing: 3px; margin-bottom: 12px; }
.modal-text { font-size: 13px; color: var(--dim); margin-bottom: 16px; }
.share-link-box {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--dim);
  border-radius: 8px; padding: 10px;
  font-size: 11px; color: var(--accent);
  word-break: break-all; margin-bottom: 16px;
  letter-spacing: 0;
}
.btn-copy {
  background: var(--accent); border: none;
  color: var(--bg); font-family: inherit;
  font-size: 14px; font-weight: 900;
  letter-spacing: 2px; padding: 12px 28px;
  border-radius: 50px; cursor: pointer;
  margin-bottom: 10px; display: block; width: 100%;
}
.btn-share-native {
  background: var(--c6); border: none;
  color: #fff; font-family: inherit;
  font-size: 14px; font-weight: 900;
  letter-spacing: 2px; padding: 12px 28px;
  border-radius: 50px; cursor: pointer;
  margin-bottom: 10px; display: block; width: 100%;
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none;
  color: var(--dim); font-size: 22px; cursor: pointer;
}

/* ── ANIMATIONS ── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes multpop {
  0%   { transform: translate(-50%,-50%) scale(0.3); opacity: 1; }
  40%  { transform: translate(-50%,-50%) scale(1.3); opacity: 1; }
  70%  { transform: translate(-50%,-50%) scale(1); opacity: 0.9; }
  100% { transform: translate(-50%,-70%) scale(0.8); opacity: 0; }
}

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

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

.shake { animation: shake 0.4s ease; }
