:root {
  --accent: #ff5fa2;
  --accent-dark: #c93b7d;
  --gold: #ffd27a;
  --text: #f4e9f0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: #0a0714;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

#wrap {
  position: relative;
  width: 390px;
  max-width: 100vw;
  height: 620px;
  max-height: 100vh;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #0a0714;
}

#hud, #best {
  position: absolute;
  top: 10px;
  z-index: 5;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: var(--text);
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  font-variant-numeric: tabular-nums;
}

#hud { left: 14px; }
#best { right: 14px; color: var(--gold); }

#controlsHint {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 5;
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: rgba(244,233,240,0.55);
  font-weight: 700;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, rgba(60,20,60,0.75), rgba(8,6,18,0.94));
  color: var(--text);
}

#overlay.hidden {
  display: none;
}

#overlay h1 {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 2px;
  text-shadow: 0 0 18px rgba(255,95,162,0.6);
}

#overlay h1 span {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255,210,122,0.7);
}

#overlay .tagline {
  font-size: 0.75rem;
  letter-spacing: 3px;
  color: rgba(244,233,240,0.7);
  margin: 0 0 22px;
}

#overlay p {
  font-size: 0.8rem;
  margin: 4px 0;
  color: rgba(244,233,240,0.75);
}

#overlay .credit {
  margin-top: 18px;
}

#overlay .credit a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

#btnStart {
  border: none;
  background: linear-gradient(135deg, #ff8fc0, var(--accent));
  color: white;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 13px 36px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(255, 95, 162, 0.5);
  cursor: pointer;
}

#btnStart:active {
  transform: scale(0.96);
}

.ghost-btn {
  border: 2px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 11px 24px;
  border-radius: 999px;
  cursor: pointer;
}

.ghost-btn:active {
  transform: scale(0.96);
}

.ghost-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.save-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
}

.pseudo-field {
  font-family: inherit;
  font-weight: 700;
  text-align: center;
  padding: 9px 12px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
  color: var(--text);
  font-size: 0.9rem;
  width: 180px;
  max-width: 65vw;
}

.pseudo-field::placeholder {
  color: rgba(244,233,240,0.55);
  font-weight: 600;
}

.save-status {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 700;
  min-height: 14px;
}

.lb-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 18, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
  backdrop-filter: blur(2px);
}

.lb-modal.hidden {
  display: none;
}

.lb-box {
  background: #17101f;
  border: 1px solid rgba(255,210,122,0.25);
  border-radius: 20px;
  padding: 24px 20px;
  max-width: 320px;
  width: 100%;
  max-height: 78vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  text-align: center;
  color: var(--text);
}

.lb-box h2 {
  margin: 0 0 14px;
  font-size: 1.4rem;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255,210,122,0.5);
}

.lb-msg {
  font-size: 0.85rem;
  color: rgba(244,233,240,0.65);
  line-height: 1.5;
}

.lb-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  text-align: left;
}

.lb-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.lb-list li:last-child {
  border-bottom: none;
}

.lb-rank {
  font-weight: 800;
  color: var(--gold);
  width: 26px;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

#closeLbBtn {
  margin-top: 16px;
  border: none;
  background: linear-gradient(135deg, #ff8fc0, var(--accent));
  color: white;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 11px 30px;
  border-radius: 999px;
  cursor: pointer;
}

#closeLbBtn:active {
  transform: scale(0.96);
}

.final-score {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--gold);
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px rgba(255,210,122,0.5);
}

.final-label {
  font-size: 0.72rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(244,233,240,0.6);
}
