:root {
  --void: #05040f;
  --nebula-violet: #8b5cf6;
  --nebula-cyan: #22d3ee;
  --nebula-magenta: #e879f9;

  --primary-gradient: linear-gradient(135deg, #8b5cf6, #22d3ee);

  --glass-bg: rgba(21, 15, 51, 0.5);
  --glass-border: rgba(167, 163, 201, 0.16);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35);

  --text: #f4f2ff;
  --text-secondary: #a7a3c9;
  --surface: rgba(255, 255, 255, 0.06);

  --snake: #8b5cf6;
  --snake-head: #f5d0fe;
  --food: #22d3ee;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0% 0%, rgba(139, 92, 246, 0.18) 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(34, 211, 238, 0.14) 0%, transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(232, 121, 249, 0.1) 0%, transparent 45%),
    var(--void);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.top-header {
  width: 100%;
  padding: 14px 20px;
  background: rgba(8, 6, 22, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--glass-border);
}

.back-link {
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}
.back-link:hover { background: rgba(255,255,255,0.12); }
.back-link:focus-visible { outline: 2px solid var(--nebula-cyan); outline-offset: 2px; }

.header-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 18px;
  font-weight: 600;
}

.header-right { width: 34px; }

.wrapper {
  max-width: 450px;
  margin: auto;
  padding: 24px 16px 40px;
  text-align: center;
}

/* Logo */
.logo {
  display: inline-block;
  font-family: 'Unbounded', sans-serif;
  font-size: 26px;
  font-weight: 700;
  margin: 4px 0 20px;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.logo .shiwan { color: var(--nebula-violet); }
.logo .online { color: var(--nebula-cyan); }
.logo:focus-visible { outline: 2px solid var(--nebula-cyan); outline-offset: 4px; border-radius: 6px; }

/* Phone body */
.phone {
  background: var(--glass-bg);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: 30px;
  padding: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  margin: auto;
}

.phone-top {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.speaker {
  width: 60px;
  height: 7px;
  background: #000;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
}

/* Screen */
.screen {
  background: #0a0620;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  position: relative;
}

canvas {
  width: 100%;
  border-radius: 10px;
  display: block;
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 16px;
  background: rgba(5, 4, 15, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  gap: 4px;
}

#overlay-text {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 12px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  margin: 12px auto 0;
  box-shadow: 0 4px 14px rgba(139,92,246,0.35);
  transition: 0.2s;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: 2px solid var(--nebula-cyan); outline-offset: 2px; }

.start-btn { display: block; }

.score-bar {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.score-bar #score { color: var(--nebula-cyan); font-weight: 700; }

/* Buttons (joystick) */
.phone-bottom {
  margin-top: 18px;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.key-row:last-child { margin-bottom: 0; }

.btn-dir {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-dir:hover { background: rgba(255,255,255,0.12); }
.btn-dir:active { transform: scale(0.9); background: rgba(139,92,246,0.3); }
.btn-dir:focus-visible { outline: 2px solid var(--nebula-cyan); outline-offset: 2px; }

/* Hint */
.hint {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}
