@font-face {
  font-family: 'Tomorrow';
  src: url('fonts/Tomorrow-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Tomorrow';
  src: url('fonts/Tomorrow-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #000;
  --fg: #ffffff;
  --accent: #ffffff;
  --glass-gradient: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0.05) 45%,
    rgba(0, 0, 0, 0.3) 50%,
    rgba(0, 0, 0, 0.6) 100%
  );
  --glass-border: 1px solid rgba(255, 255, 255, 0.3);
  --glass-shadow:
    0 0 15px rgba(255, 255, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  --radius: 12px;
  --transition: 600ms cubic-bezier(.2, .9, .2, 1);
  --avatar-size: 120px;
}

* { box-sizing: border-box; }

button, input, select, textarea {
  font-family: inherit;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Tomorrow', sans-serif;
  font-size: 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.5px;
  overflow: hidden;
}

body.has-bottom-nav .login-overlay {
  padding-bottom: 100px;
}

body.has-bottom-nav .hud {
  padding-bottom: 88px;
}

body.has-bottom-nav .bottom-menu {
  z-index: 30;
}

#parkinglotApp {
  position: relative;
  width: 100%;
  min-height: 100%;
}

#parkinglotApp:fullscreen,
#parkinglotApp:-webkit-full-screen,
#parkinglotApp.is-fullscreen-fallback {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

#parkinglotApp.is-fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 9999;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

body.parkinglot-fullscreen .bottom-menu {
  display: none;
}

#parkinglotApp:fullscreen .game-stage,
#parkinglotApp:-webkit-full-screen .game-stage,
#parkinglotApp.is-fullscreen-fallback .game-stage,
#parkinglotApp:fullscreen .login-overlay,
#parkinglotApp:-webkit-full-screen .login-overlay,
#parkinglotApp.is-fullscreen-fallback .login-overlay {
  inset: 0;
}

.hidden { display: none !important; }

/* —— Login —— */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.95));
}

.login-card {
  width: min(480px, 100%);
  background: rgba(10, 15, 20, 0.75);
  background-image: var(--glass-gradient);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(12px);
}

.login-title {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: clamp(24px, 3vw, 36px);
  color: #fff;
  background: none;
  -webkit-text-fill-color: #fff;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.login-lead {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  line-height: 1.4;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  letter-spacing: 0.6px;
}

.field input[type="text"],
.field input[type="file"],
.chat-bar input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  text-shadow: none;
  letter-spacing: 0.3px;
}

.field input[type="file"] {
  padding: 8px;
  cursor: pointer;
}

.field input:focus,
.chat-bar input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.field-meta {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 5px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

.avatar-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 16px 0 18px;
}

.avatar-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-cycle-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar-preview {
  position: relative;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: var(--glass-shadow);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.18), transparent 55%),
    rgba(0, 0, 0, 0.55);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.avatar-preview.transparent {
  border-radius: 0;
  border: none;
  box-shadow: none;
  background-color: transparent;
  background-size: contain;
  background-repeat: no-repeat;
  overflow: visible;
}

.avatar-preview.transparent::before {
  content: '';
  position: absolute;
  inset: -4%;
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.28) 38%,
    rgba(255, 255, 255, 0.1) 62%,
    rgba(255, 255, 255, 0) 78%
  );
  filter: blur(2px);
}

.login-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status {
  min-height: 1.2em;
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.status.error { color: #ff9b9b; }
.status.success { color: #9dffc0; }

.btn {
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  box-shadow: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-shadow: 0 1px 2px black;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 10px var(--accent);
  text-shadow: 0 0 5px var(--accent);
  transform: translateY(-2px);
  color: #fff;
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* —— World —— */
.game-stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

.world-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.08), transparent 50%),
    #050505;
  -webkit-user-select: none;
  user-select: none;
}

.world-viewport.is-panning {
  cursor: grabbing;
}

.world-camera {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.world {
  position: relative;
  margin: 0;
  background-color: #0a0a0a;
  background-image: url('asphalt-tile.jpg');
  background-repeat: repeat;
  background-position: 0 0;
  background-size: 525px 350px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.7);
}

.world-images {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.world-image {
  position: absolute;
  transform: translate(-50%, -50%);
  max-width: 400px;
  max-height: 400px;
  object-fit: contain;
  border: none;
  box-shadow: none;
  user-select: none;
  -webkit-user-drag: none;
}

.ghettoblasta-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.ghettoblasta {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 280px;
  object-fit: contain;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: manipulation;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.65));
  z-index: 1;
}

.ghettoblasta.is-playing {
  filter:
    drop-shadow(0 0 10px rgba(255, 236, 80, 0.55))
    drop-shadow(0 6px 14px rgba(0, 0, 0, 0.65));
}

.ghettoblasta-panel {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 8;
  width: min(360px, calc(100vw - 24px));
  padding: 14px 16px 16px;
  background: rgba(10, 15, 20, 0.88);
  background-image: var(--glass-gradient);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  touch-action: manipulation;
}

.ghettoblasta-panel[hidden] {
  display: none !important;
}

.ghettoblasta-track {
  margin: 0 0 12px;
  min-height: 1.2em;
  font-size: 13px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghettoblasta-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.ghettoblasta-controls .btn {
  flex: 1;
  min-width: 0;
}

.avatar {
  position: absolute;
  width: var(--avatar-size);
  height: var(--avatar-size);
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

.avatar-circle {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    0 0 12px rgba(255, 255, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.avatar-circle.spinning {
  animation: avatar-spin var(--spin-duration, 0.75s) ease-in-out;
}

@keyframes avatar-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(calc(var(--spin-count, 1) * 360deg));
  }
}

.avatar.self .avatar-circle {
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow:
    0 0 16px rgba(255, 255, 255, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* Transparent PNG avatars: no round frame, filled circular soft glow.
   Glow lives on .avatar (not .avatar-circle) so /spin's transform does not
   promote a filtered child layer that composites over the image. */
.avatar.transparent .avatar-circle {
  border-radius: 0;
  border: none;
  box-shadow: none;
  overflow: visible;
  background-color: transparent;
  background-size: contain;
  background-repeat: no-repeat;
}

.avatar.transparent::before {
  content: '';
  position: absolute;
  inset: -4%;
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.28) 38%,
    rgba(255, 255, 255, 0.1) 62%,
    rgba(255, 255, 255, 0) 78%
  );
  filter: blur(2px);
}

.avatar.transparent.self::before {
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.7) 0%,
    rgba(255, 255, 255, 0.35) 40%,
    rgba(255, 255, 255, 0.12) 64%,
    rgba(255, 255, 255, 0) 80%
  );
}

.avatar-name {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-shadow: none;
}

/* Speech balloons — sized to text; must not shrink to the 120px avatar box */
.balloon {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 2200px;
  box-sizing: border-box;
  padding: 8px 12px;
  background: rgba(10, 15, 20, 0.9);
  background-image: var(--glass-gradient);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  text-shadow: none;
  word-break: normal;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  z-index: 3;
}

.balloon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: rgba(255, 255, 255, 0.3);
}

.balloon.whisper {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.55);
}

.heart-emote {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  font-size: 56px;
  line-height: 1;
  z-index: 4;
  pointer-events: none;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  animation: heart-pop 0.5s cubic-bezier(0.2, 0.9, 0.2, 1);
  user-select: none;
}

@keyframes heart-pop {
  0% {
    transform: translateX(-50%) translateY(12px) scale(0.35);
    opacity: 0;
  }
  55% {
    transform: translateX(-50%) translateY(-4px) scale(1.12);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

.balloon.typing {
  min-width: 48px;
  letter-spacing: 2px;
  font-weight: 700;
}

.balloon.typing .dots span {
  animation: blink 1.2s infinite;
  opacity: 0.25;
}

.balloon.typing .dots span:nth-child(2) { animation-delay: 0.2s; }
.balloon.typing .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* HUD / chat bar */
.hud {
  position: relative;
  z-index: 5;
  padding: 12px 16px 16px;
  background: rgba(0, 0, 0, 0.6);
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.15) 0%,
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.4) 100%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
}

.chat-bar {
  display: flex;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
}

.chat-bar input {
  flex: 1;
}

.world-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  margin: 0;
}

/* Chat log overlay */
.chat-log {
  position: fixed;
  top: 16px;
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: min(60vh, 520px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 20, 0.85);
  background-image: var(--glass-gradient);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.chat-log[hidden] {
  display: none !important;
}

.chat-log-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-log-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.chat-log-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

.chat-log-list {
  list-style: none;
  margin: 0;
  padding: 8px 16px 16px;
  overflow: auto;
  flex: 1;
}

.chat-log-list::-webkit-scrollbar { width: 10px; }
.chat-log-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
}
.chat-log-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #555, #333);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.chat-log-item {
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-log-item:first-child {
  border-top: none;
  padding-top: 4px;
}

.chat-log-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 12px;
}

.chat-log-item.whisper .chat-log-name {
  font-style: italic;
  opacity: 0.9;
}

.chat-log-item.admin .chat-log-name {
  letter-spacing: 0.6px;
  opacity: 0.88;
}

.chat-log-item.admin .chat-log-message {
  opacity: 0.92;
}

.chat-log-name {
  font-weight: 700;
  font-size: 14px;
}

.chat-log-time {
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}

.chat-log-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: none;
  word-break: break-word;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .login-card { padding: 18px; }
  .hud { padding: 10px 12px 12px; }
  .chat-log { top: 10px; right: 10px; }
  .ghettoblasta-panel { bottom: 12px; }
}
