/* YandexGuesser - Clean Gaming UI (Inspired by OpenGuessr) */
:root {
  --bg-dark: #0e121a;
  --panel-bg: #1d222e;
  --panel-bg-subtle: #161a24;
  --panel-border: #2d3546;
  --panel-border-light: #3f495e;
  
  /* Buttons */
  --btn-grey-top: #3d4554;
  --btn-grey-bottom: #2f3643;
  --btn-grey-border: #4a5468;
  --btn-grey-hover-top: #4a5365;
  --btn-grey-hover-bottom: #373f4e;

  --btn-red-top: #ff2d2d;
  --btn-red-bottom: #d91414;
  --btn-red-border: #ff5c5c;
  --btn-red-hover-top: #ff4747;
  --btn-red-hover-bottom: #eb1c1c;

  --btn-disabled-bg: #272d3b;
  --btn-disabled-border: #353d4f;
  --btn-disabled-text: #616c80;

  /* Typography */
  --text-white: #ffffff;
  --text-muted: #8e9aae;
  --text-dim: #5c667a;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-white);
  user-select: none;
}

/* Background Scenic Landscape for Menus */
.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle at center, rgba(14, 18, 26, 0.7) 0%, rgba(10, 13, 19, 0.95) 100%),
              url('https://images.unsplash.com/photo-1507525428034-b723cf961d3e?auto=format&fit=crop&w=1920&q=80') center/cover no-repeat;
  filter: blur(8px);
  transform: scale(1.05);
  pointer-events: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.screen.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

/* UI Panel Card */
.game-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-top: 1px solid var(--panel-border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.4);
  padding: 24px;
  color: var(--text-white);
  position: relative;
}

/* Clean OpenGuessr Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--radius-md);
  padding: 13px 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-decoration: none;
  outline: none;
  letter-spacing: 0.2px;
}

.btn:active {
  transform: translateY(1px);
}

/* Grey Standard Button */
.btn-grey {
  background: linear-gradient(180deg, var(--btn-grey-top) 0%, var(--btn-grey-bottom) 100%);
  border: 1px solid var(--btn-grey-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 3px 6px rgba(0, 0, 0, 0.35);
  color: var(--text-white);
}

.btn-grey:hover {
  background: linear-gradient(180deg, var(--btn-grey-hover-top) 0%, var(--btn-grey-hover-bottom) 100%);
  border-color: #5c687e;
}

/* Red Highlight Button (Guess / Log In / Start) */
.btn-red {
  background: linear-gradient(180deg, var(--btn-red-top) 0%, var(--btn-red-bottom) 100%);
  border: 1px solid var(--btn-red-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 3px 8px rgba(217, 20, 20, 0.35);
  color: var(--text-white);
}

.btn-red:hover {
  background: linear-gradient(180deg, var(--btn-red-hover-top) 0%, var(--btn-red-hover-bottom) 100%);
  border-color: #ff7575;
}

.btn-red:disabled {
  background: var(--btn-disabled-bg);
  border-color: var(--btn-disabled-border);
  color: var(--btn-disabled-text);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Danger / Leave Button */
.btn-dark {
  background: #191e29;
  border: 1px solid #2d3444;
  color: #a0aec0;
}

.btn-dark:hover {
  background: #232936;
  color: #ffffff;
}

/* Inputs */
.input-clean {
  background: #141822;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-white);
  font-size: 15px;
  font-weight: 500;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.input-clean:focus {
  border-color: #4a6fa5;
}

.input-clean::placeholder {
  color: var(--text-dim);
}

select.input-clean {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238e9aae'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

select.input-clean option {
  background: #1d222e;
  color: #fff;
}

/* ============================================================
   SCREEN 1: MENU
   ============================================================ */
#screen-menu {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.menu-card {
  width: 100%;
  max-width: 440px;
  text-align: center;
}

.menu-header-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.logo-tag {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.logo-tag span {
  color: #ff3b3b;
}

.menu-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
}

/* Nickname Block */
.nickname-block {
  background: #141822;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  text-align: left;
}

.nickname-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  color: #041224;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
}

.nickname-inputs {
  flex: 1;
}

.nickname-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.nickname-input-field {
  background: transparent;
  border: none;
  color: var(--text-white);
  font-size: 15px;
  font-weight: 700;
  outline: none;
  width: 100%;
}

.map-selector-group {
  margin-bottom: 20px;
  text-align: left;
}

.map-selector-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

/* Action Stack matching photo 2 */
.menu-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-btn-stack .btn {
  justify-content: space-between;
  padding: 15px 20px;
  font-size: 16px;
}

.join-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.join-row input {
  text-transform: uppercase;
  text-align: center;
  font-weight: 700;
  letter-spacing: 2px;
}

/* ============================================================
   SCREEN 2: LOBBY
   ============================================================ */
#screen-lobby {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lobby-card {
  width: 100%;
  max-width: 620px;
}

.lobby-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.room-badge {
  background: #141822;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.room-badge:hover {
  background: #1a202d;
  border-color: #3b4559;
}

.room-badge-code {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ff4747;
}

.lobby-content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 600px) {
  .lobby-content-grid { grid-template-columns: 1fr; }
}

.player-box {
  background: #141822;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1c222e;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* ============================================================
   SCREEN 3: IN-GAME
   ============================================================ */
#screen-game {
  position: absolute;
  inset: 0;
}

.panorama-viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
}

.panorama-viewport iframe {
  position: absolute;
  top: -55px;
  left: 0;
  width: calc(100vw + 65px);
  height: calc(100vh + 105px);
  border: none;
}

/* Top & Bottom gradient bars masking external controls */
.top-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: linear-gradient(180deg, rgba(14, 18, 26, 0.98) 0%, rgba(14, 18, 26, 0.7) 65%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}

.bottom-mask {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(0deg, rgba(14, 18, 26, 0.9) 0%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}

/* Top Game HUD Bar */
.game-hud-bar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-pill {
  background: #1d222e;
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-btn {
  cursor: pointer;
  background: #232a3b;
  color: var(--text-white);
  transition: all 0.15s ease;
  user-select: none;
}

.hud-btn:hover {
  background: #2f384f;
  border-color: #3b82f6;
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(1px);
}

.timer-text {
  font-family: monospace;
  font-size: 16px;
  color: #4facfe;
}

.timer-text.urgent {
  color: #ff3b3b;
  animation: pulseTimer 1s infinite;
}

@keyframes pulseTimer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Left Players HUD */
.game-left-hud {
  position: absolute;
  top: 80px;
  left: 16px;
  z-index: 10;
  background: #1d222e;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
  width: 200px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.hud-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* ============================================================
   BOTTOM-RIGHT GUESS MAP (MATCHING OPENGUESSR IMAGE 1)
   ============================================================ */
.guess-map-container {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.guess-map-card {
  width: 340px;
  height: 230px;
  background: #1a202c;
  border: 2px solid #2d3748;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), height 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease;
  opacity: 0.92;
}

.guess-map-card.expanded,
.guess-map-card.hover-expanded {
  width: 650px;
  height: 440px;
  opacity: 1;
}

@media (max-width: 768px) {
  .guess-map-card {
    width: 280px;
    height: 210px;
  }
  .guess-map-card.expanded {
    width: calc(100vw - 32px);
    height: 360px;
  }
}

/* Header bar above map */
.map-header-bar {
  background: #141822;
  border-bottom: 1px solid #2d3748;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.map-control-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}

.map-control-btn:hover {
  background: #2d3748;
  color: #fff;
}

/* The Leaflet Map Canvas — Normal arrow cursor without hand grab */
#leaflet-map {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #e5e3df; /* Warm map background preventing grey flashes */
  cursor: default !important;
}

/* Override all Leaflet grabbing hands to regular pointer/default arrow */
#leaflet-map .leaflet-container,
#leaflet-map .leaflet-grab,
#leaflet-map .leaflet-grabbing,
#leaflet-map .leaflet-pane,
#leaflet-map .leaflet-tile-pane,
#leaflet-map .leaflet-marker-pane,
#leaflet-map .leaflet-interactive,
#results-map .leaflet-container,
#results-map .leaflet-grab,
#results-map .leaflet-grabbing,
.leaflet-grab,
.leaflet-grabbing,
.leaflet-container {
  cursor: default !important;
}

/* Custom Number Input and Preset Chips */
.input-with-presets {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-number-input {
  background: #141822;
  border: 1px solid var(--panel-border);
  color: var(--text-white);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}

.custom-number-input:focus {
  border-color: #3b82f6;
}

.custom-number-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.presets-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-chip {
  background: #232a3b;
  border: 1px solid #2d3748;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.preset-chip:hover:not(:disabled) {
  background: #313a4e;
  color: #fff;
  border-color: #3b82f6;
}

.preset-chip.active {
  background: #3b82f6;
  color: #fff;
  border-color: #60a5fa;
}

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

/* Action Bar below map */
.map-bottom-bar {
  margin-top: 8px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-guess-action {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Return button pill matching photo 1 */
.return-btn-pill {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 20;
  background: #1d222e;
  border: 1px solid var(--panel-border);
  color: var(--text-white);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.return-btn-pill:hover {
  background: #293040;
}

/* ============================================================
   SCREEN 4: RESULTS
   ============================================================ */
#screen-results {
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 13, 19, 0.85);
}

.results-card {
  width: 100%;
  max-width: 820px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results-map-box {
  width: 100%;
  height: 340px;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  background: #e5e3df;
}

#results-map {
  width: 100%;
  height: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  text-align: center;
}

.stat-box {
  background: #141822;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.results-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--panel-border);
}

.results-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #232936;
}

.results-table tr.me {
  background: rgba(79, 172, 254, 0.1);
  font-weight: 700;
}

/* ============================================================
   SCREEN 5: GAME OVER
   ============================================================ */
#screen-game-over {
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 13, 19, 0.9);
}

.game-over-card {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.podium-box {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 30px 0;
}

.podium-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.step-bar {
  width: 100%;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #333d4f;
  background: #1a202c;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.step-1 { height: 110px; background: #283347; border-color: #f59e0b; color: #f59e0b; }
.step-2 { height: 80px; }
.step-3 { height: 60px; }

/* Custom Pins */
.custom-pin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ff2d2d;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  cursor: pointer;
}

.actual-pin {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #10b981;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.other-pin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
