:root {
  --bg-color: #f7f5f0;
  --surface-color: rgb(255 255 255 / 85%);
  --surface-solid: #fff;
  --text-primary: #2e3a2b;
  --text-secondary: #6b7568;
  --primary-color: #5d8b4a;
  --primary-hover: #4a7339;
  --error-color: #d9534f;
  --border-color: rgb(226 223 216 / 60%);
  --shadow-glass: 0 4px 16px rgb(46 58 43 / 10%);
  --radius: 16px;
  --radius-sm: 8px;
  --mono-font: "Roboto Mono", "SF Mono", Consolas, monospace;
  --top-panel-offset: 68px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, sans-serif;
}

body {
  background: #222;
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
}

.glass {
  background: var(--surface-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-glass);
  border: 1px solid var(--border-color);
}

.top-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  min-height: 56px;
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  z-index: 1000;
  gap: 10px;
}

.tp-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.debug-toggle-word {
  cursor: pointer;
  text-decoration: underline dotted transparent;
  text-underline-offset: 3px;
}

.debug-toggle-word:hover {
  text-decoration-color: rgb(93 139 74 / 65%);
}

.logo-icon {
  width: 24px;
  height: 24px;
  background: var(--primary-color);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  padding: 4px 12px;
  border-left: 1px solid var(--border-color);
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.easter-egg-word {
  cursor: pointer;
  text-decoration: underline dotted transparent;
  text-underline-offset: 3px;
}

.easter-egg-word:hover {
  text-decoration-color: rgb(93 139 74 / 65%);
}

.stat-value {
  font-weight: 600;
  font-size: 15px;
  font-family: var(--mono-font);
}

.image-type-badge,
.load-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.image-type-badge {
  background: rgb(93 139 74 / 15%);
  color: var(--primary-hover);
}

.load-status {
  background: rgb(0 0 0 / 7%);
  color: var(--text-secondary);
}

.load-status.is-loading {
  background: rgb(230 81 0 / 15%);
  color: #e65100;
}

.load-status.is-ok {
  background: rgb(93 139 74 / 15%);
  color: var(--primary-hover);
}

.load-status.is-error {
  background: rgb(217 83 79 / 15%);
  color: var(--error-color);
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgb(255 255 255 / 50%);
  border-top-color: currentcolor;
  border-radius: 50%;
  display: none;
}

.load-status.is-loading .spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn {
  background: var(--primary-color);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgb(0 0 0 / 10%);
}

.btn:disabled {
  background: #ccc;
  color: #777;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.auth-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-user-label {
  font-size: 12px;
  color: var(--text-primary);
  background: rgb(255 255 255 / 35%);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 10px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 48%);
}

.auth-modal-panel {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.auth-modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.auth-modal-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.auth-form-row input {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: rgb(255 255 255 / 88%);
  color: var(--text-primary);
}

.auth-form-row input:focus {
  outline: 2px solid rgb(93 139 74 / 35%);
  outline-offset: 1px;
}

.auth-error-text {
  margin: 0;
  font-size: 12px;
  color: var(--error-color);
}

.auth-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.round-time-control {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 25%);
  border: 1px solid var(--border-color);
}

.round-time-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.round-time-select {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--mono-font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
}

.db-panorama-meta {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.db-inspector-actions {
  display: flex;
  gap: 6px;
}

.db-popup {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(var(--top-panel-offset) + 8px) 16px 16px;
}

.db-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 38%);
}

.db-popup-panel {
  position: relative;
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - var(--top-panel-offset) - 24px);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.db-popup-header h3 {
  font-size: 16px;
  margin: 0;
}

.db-popup-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.db-popup-table-wrap {
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgb(255 255 255 / 60%);
  min-height: 220px;
}

.db-popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.db-popup-table th,
.db-popup-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgb(0 0 0 / 8%);
  white-space: nowrap;
}

.db-popup-table tbody tr {
  cursor: pointer;
}

.db-popup-table tbody tr:hover {
  background: rgb(93 139 74 / 10%);
}

.db-popup-table tbody tr.is-selected {
  background: rgb(93 139 74 / 18%);
}

.region-picker-btn {
  border: 1px solid var(--border-color);
  background: rgb(255 255 255 / 80%);
  color: var(--text-primary);
  font-family: var(--mono-font);
  font-size: 12px;
  min-width: 190px;
  max-width: 230px;
  border-radius: 6px;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
}

.region-picker-menu {
  position: absolute;
  margin-top: 46px;
  min-width: 260px;
  max-width: 320px;
  max-height: 280px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 8px 20px rgb(0 0 0 / 18%);
  z-index: 1250;
  padding: 8px;
}

.region-picker-search {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.region-picker-options {
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.region-picker-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 2px 0;
}

.region-picker-option small {
  color: var(--text-secondary);
}

.region-availability-hint {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--mono-font);
  background: rgb(255 255 255 / 25%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}

.btn-ghost {
  background: rgb(255 255 255 / 35%);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover:not(:disabled) {
  background: rgb(255 255 255 / 55%);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.zoom-reset-btn {
  width: 50px;
  border-radius: 20px;
  font-size: 12px;
}

.kbd {
  background: rgb(0 0 0 / 10%);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: var(--mono-font);
}

.panorama-container {
  position: absolute;
  top: var(--top-panel-offset);
  right: 0;
  bottom: 0;
  left: 0;
}

.panorama-container::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgb(20 20 20 / 20%) 0%, rgb(20 20 20 / 8%) 30%, transparent 65%);
}

.panorama-iframe {
  width: 100%;
  height: 100%;
  border: none;
  transform-origin: center center;
  transition: transform 120ms ease-out;
}

.pano-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 25%, rgb(93 139 74 / 30%), transparent 35%),
    radial-gradient(circle at 75% 10%, rgb(255 255 255 / 22%), transparent 30%),
    linear-gradient(180deg, rgb(18 28 25 / 45%), rgb(18 28 25 / 25%));
  padding: 24px;
}

.pano-placeholder.is-hidden {
  display: none;
}

.pano-placeholder-inner {
  max-width: 540px;
  text-align: center;
  color: #f6f6f2;
  background: rgb(0 0 0 / 22%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 14px;
  padding: 18px 20px;
  backdrop-filter: blur(2px);
}

.pano-placeholder-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
}

.pano-placeholder-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
  color: rgb(246 246 242 / 88%);
}

.welcome-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.welcome-stat {
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 10px;
  background: rgb(0 0 0 / 20%);
  padding: 8px 10px;
  text-align: left;
}

.welcome-stat-label {
  display: block;
  font-size: 10px;
  color: rgb(246 246 242 / 70%);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.welcome-stat-value {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: #fff;
  font-weight: 700;
}

.map-controls {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
}

.app.is-pregame .minimap-wrap,
.app.is-pregame .map-controls,
.app.is-pregame #resultBanner {
  display: none;
}

.minimap-wrap {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: 420px;
  height: 300px;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 800;
  transition: width 0.3s ease, height 0.3s ease, transform 0.3s ease, right 0.3s ease, bottom 0.3s ease;
}

.minimap-wrap.focus-mode {
  width: 520px;
  height: 380px;
  box-shadow: 0 8px 24px rgb(46 58 43 / 20%);
}

.minimap-header {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.minimap-title {
  font-size: 13px;
  font-weight: 600;
}

.minimap-actions {
  display: flex;
  gap: 4px;
}

.toggle-minimap-btn {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

.minimap-body {
  flex: 1;
  position: relative;
  background: #ddd;
}

#guessMap {
  width: 100%;
  height: 100%;
}

.minimap-footer {
  min-height: 38px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  background: var(--surface-color);
}

#resultText {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.minimap-action-bar {
  height: 0;
  overflow: hidden;
  background: var(--surface-color);
  backdrop-filter: blur(12px);
  transition: height 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}

.minimap-wrap.focus-mode .minimap-action-bar {
  height: 56px;
  border-top: 1px solid var(--border-color);
}

.check-answer-btn {
  width: 100%;
}

.result-banner {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(150%);
  width: 100%;
  max-width: 620px;
  padding: 14px 20px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  z-index: 900;
  transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.result-banner.show {
  transform: translateX(-50%) translateY(0);
}

.result-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.result-distance {
  font-size: 14px;
  color: var(--text-secondary);
}

.result-distance span {
  font-family: var(--mono-font);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 16px;
}

.result-points {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-color);
  font-family: var(--mono-font);
}

.minimap-wrap.is-expanded {
  width: calc(100% - 40px);
  height: calc(100% - 106px);
  right: 20px;
  bottom: 20px;
}

.minimap-wrap.is-expanded ~ .map-controls {
  display: none;
}

.minimap-wrap.is-collapsed {
  height: 44px;
  width: 220px;
}

.minimap-wrap.is-collapsed .minimap-body,
.minimap-wrap.is-collapsed .minimap-footer,
.minimap-wrap.is-collapsed .minimap-action-bar {
  display: none;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .top-panel {
    top: 0;
    left: 0;
    right: 0;
    min-height: 50px;
    padding: 6px 10px;
    border-radius: 0 0 12px 12px;
  }

  .hide-mobile {
    display: none;
  }

  .logo {
    font-size: 16px;
  }

  .round-time-control {
    padding: 3px 6px;
  }

  .auth-controls {
    gap: 4px;
  }

  .auth-controls .btn {
    padding: 6px 9px;
    font-size: 12px;
  }

  .auth-form-actions {
    flex-direction: column;
  }

  .panorama-container {
    top: var(--top-panel-offset);
  }

  .map-controls {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
  }

  .minimap-wrap {
    width: calc(100% - 16px);
    right: 8px;
    bottom: 8px;
    height: 260px;
  }

  .minimap-wrap.focus-mode {
    width: calc(100% - 16px);
    height: 360px;
  }

  .minimap-wrap.is-expanded {
    width: calc(100% - 16px);
    height: calc(100% - 64px);
    right: 8px;
    bottom: 8px;
  }

  .minimap-wrap.is-collapsed {
    width: 140px;
    height: 40px;
  }

  .result-banner {
    bottom: 8px;
    width: calc(100% - 16px);
    padding: 12px;
  }

  .welcome-stats {
    grid-template-columns: 1fr;
  }

  .result-points {
    font-size: 17px;
  }
}
