/* Reset & base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #fff;
}

/* Canvas */
#game-canvas {
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  touch-action: none;
}

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(0, 0, 20, 0.75);
  backdrop-filter: blur(4px);
}

.overlay.hidden { display: none; }

.overlay-box {
  background: linear-gradient(135deg, #1a1a3e, #0d0d2b);
  border: 2px solid rgba(100, 150, 255, 0.3);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 420px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(80, 120, 255, 0.15);
}

.overlay-box.wide { max-width: 560px; }

h1 {
  font-size: 2rem;
  margin-bottom: 6px;
  background: linear-gradient(90deg, #7eb8ff, #ff9de2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 12px;
  color: #aaddff;
}

.subtitle {
  color: #8899cc;
  font-size: 0.95rem;
  margin-bottom: 20px;
}

/* Form */
.form-group {
  margin-bottom: 12px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px solid rgba(100, 150, 255, 0.4);
  background: rgba(255,255,255,0.07);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  border-color: rgba(100, 180, 255, 0.9);
}

input[type="text"]::placeholder {
  color: #556;
}

.error-text {
  color: #ff8080;
  font-size: 0.85rem;
  min-height: 18px;
  margin-bottom: 8px;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 13px;
  margin: 8px 0;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #4e8ef7, #7b5ea7);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #6aabff, #9b7ec7);
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #aac4ff;
  border: 1px solid rgba(100,150,255,0.3);
}

.btn-secondary:hover { background: rgba(255,255,255,0.14); }

.btn-small {
  width: auto;
  display: inline-block;
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* Item guide on start screen */
.item-guide {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.guide-section { flex: 1; min-width: 120px; }

.guide-title {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
.good-title { color: #80ff99; }
.bad-title  { color: #ff8080; }

.guide-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  font-size: 1.3rem;
}

.guide-items span {
  cursor: default;
  title: attr(title);
}

/* Game Over */
.big-score {
  font-size: 3rem;
  font-weight: 900;
  color: #ffd700;
  margin: 10px 0;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.pb-badge {
  background: linear-gradient(90deg, #ffd700, #ff8c00);
  color: #000;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.rank-text {
  color: #aaddff;
  font-size: 1rem;
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  font-size: 0.9rem;
  color: #99aacc;
  margin: 12px 0;
  text-align: left;
}

.stats-grid strong { color: #fff; }

.achievements-row {
  margin: 12px 0;
}

.achieve-title {
  font-size: 0.8rem;
  color: #8899cc;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.achieve-badge {
  display: inline-block;
  background: rgba(255,215,0,0.15);
  border: 1px solid rgba(255,215,0,0.4);
  color: #ffd700;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.8rem;
  margin: 3px;
}

/* Leaderboard */
#lb-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

#lb-table th {
  color: #7799cc;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(100,150,255,0.2);
}

#lb-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: #cce;
}

#lb-table tr.lb-me td {
  background: rgba(100, 150, 255, 0.15);
  color: #fff;
  font-weight: 600;
}

#lb-table tr:hover td { background: rgba(255,255,255,0.04); }

.lb-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 14px 0 8px;
  color: #7799cc;
  font-size: 0.9rem;
}

/* Joke overlay */
.joke-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,10,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.joke-overlay.hidden { display: none; }

.joke-box {
  background: linear-gradient(135deg, #1a0030, #0a001a);
  border: 2px solid rgba(200, 100, 255, 0.4);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 60px rgba(180, 80, 255, 0.2);
}

.joke-item {
  font-size: 3.5rem;
  margin-bottom: 16px;
  display: inline-block;
}

.joke-item.bounce {
  animation: itemBounce 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes itemBounce {
  0%   { transform: scale(0.3) translateY(-40px); opacity: 0; }
  60%  { transform: scale(1.15) translateY(4px); opacity: 1; }
  80%  { transform: scale(0.95) translateY(-2px); }
  100% { transform: scale(1) translateY(0); }
}

.joke-text {
  font-size: 1rem;
  color: #e0c8ff;
  line-height: 1.5;
  min-height: 60px;
  margin-bottom: 16px;
}

.joke-tap {
  font-size: 0.8rem;
  color: rgba(200, 150, 255, 0.6);
  transition: opacity 0.3s;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* Toast */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(20, 20, 50, 0.92);
  border: 1px solid rgba(100,180,255,0.4);
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 0.9rem;
  color: #fff;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  white-space: nowrap;
  max-width: 90vw;
}

.toast.hidden { display: none; }
.toast.show { display: block; }

.toast.fade-out {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* Special items guide */
.special-guide {
  margin-top: 16px;
  text-align: left;
}

.special-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7799cc;
  margin-bottom: 6px;
}

.special-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.special-items div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.82rem;
  color: #aabbdd;
}

.sp-emoji {
  font-size: 1rem;
  width: 22px;
  flex-shrink: 0;
}

.sp-text {
  line-height: 1.3;
}

/* Scrollbar for overlay-box */
.overlay-box::-webkit-scrollbar { width: 6px; }
.overlay-box::-webkit-scrollbar-track { background: transparent; }
.overlay-box::-webkit-scrollbar-thumb { background: rgba(100,150,255,0.3); border-radius: 3px; }
