/* 全局变量 - 从微信小程序移植 */
:root {
  --bg-color: #1a1a1a;
  --text-color: #f5f5dc;
  --text-secondary: rgba(245, 245, 220, 0.6);
  --accent-color: #d4a574;
}

/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  background-color: var(--bg-color);
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif CN", serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  touch-action: manipulation;
}

.page {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 15vw 8vw 10vw;
}

/* 标题 */
.title {
  font-size: 7vw;
  color: var(--text-color);
  letter-spacing: 2.5vw;
  font-weight: 300;
  margin-bottom: 5vw;
}

/* 指南针区域 */
.compass-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.compass-container {
  position: relative;
  width: 50vw;
  height: 50vw;
  max-width: 300px;
  max-height: 300px;
}

/* 外圈 */
.compass-ring {
  position: absolute;
  top: 2.5%;
  left: 2.5%;
  width: 95%;
  height: 95%;
  border: 1px solid rgba(245, 245, 220, 0.2);
  border-radius: 50%;
}

/* 指针容器 */
.compass-pointer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  will-change: transform;
}

/* 指针箭头 */
.pointer-arrow {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 2vw solid transparent;
  border-right: 2vw solid transparent;
  border-bottom: 17.5vw solid var(--accent-color);
}

@media (min-width: 600px) {
  .pointer-arrow {
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 105px solid var(--accent-color);
  }
}

/* 指针尾部 */
.pointer-tail {
  position: absolute;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 0.5vw;
  height: 15vw;
  background: linear-gradient(to top, rgba(212, 165, 116, 0.2), var(--accent-color));
}

@media (min-width: 600px) {
  .pointer-tail {
    width: 3px;
    height: 90px;
  }
}

/* 中心点 */
.compass-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.5vw;
  height: 2.5vw;
  max-width: 15px;
  max-height: 15px;
  background-color: var(--accent-color);
  border-radius: 50%;
  box-shadow: 0 0 2.5vw rgba(212, 165, 116, 0.5);
  z-index: 10;
}

/* 占位符 */
.compass-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5vw;
}

.placeholder-circle {
  width: 37.5vw;
  height: 37.5vw;
  max-width: 225px;
  max-height: 225px;
  border: 1px dashed rgba(245, 245, 220, 0.3);
  border-radius: 50%;
}

.placeholder-text {
  font-size: 3.5vw;
  color: var(--text-secondary);
  letter-spacing: 0.5vw;
}

@media (min-width: 600px) {
  .placeholder-text {
    font-size: 21px;
    letter-spacing: 3px;
  }
}

/* 距离显示 */
.distance-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2vw;
  margin-bottom: 8vw;
}

.distance-text {
  font-size: 4vw;
  color: var(--text-secondary);
  letter-spacing: 1vw;
}

@media (min-width: 600px) {
  .distance-text {
    font-size: 24px;
    letter-spacing: 6px;
  }
}

.distance-value {
  font-size: 9vw;
  color: var(--text-color);
  letter-spacing: 0.5vw;
  font-weight: 300;
}

@media (min-width: 600px) {
  .distance-value {
    font-size: 54px;
    letter-spacing: 3px;
  }
}

/* 故乡名称 */
.hometown-name {
  font-size: 4.5vw;
  color: var(--text-secondary);
  letter-spacing: 1vw;
  margin-bottom: 8vw;
}

@media (min-width: 600px) {
  .hometown-name {
    font-size: 27px;
    letter-spacing: 6px;
  }
}

/* 诗词文案 */
.poem-section {
  margin-bottom: 8vw;
  padding: 0 5vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 15vw;
  transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}

.poem-section.fade-in {
  opacity: 1;
  transform: translateY(0);
}

.poem-section.fade-out {
  opacity: 0;
  transform: translateY(-2.5vw);
}

.poem-text {
  font-size: 3.5vw;
  color: var(--text-secondary);
  letter-spacing: 0.5vw;
  line-height: 1.8;
  text-align: center;
}

@media (min-width: 600px) {
  .poem-text {
    font-size: 21px;
    letter-spacing: 3px;
  }
}

.poem-source {
  font-size: 3vw;
  color: var(--text-secondary);
  letter-spacing: 0.25vw;
  margin-top: 2vw;
  align-self: flex-end;
}

@media (min-width: 600px) {
  .poem-source {
    font-size: 18px;
    letter-spacing: 1.5px;
    margin-top: 12px;
  }
}

/* 操作区 */
.action-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3vw;
}

.action-btn {
  padding: 3vw 8vw;
  border: 1px solid rgba(245, 245, 220, 0.3);
  border-radius: 1vw;
  background: transparent;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:active {
  background-color: rgba(245, 245, 220, 0.05);
}

.action-btn span {
  font-size: 3.25vw;
  color: var(--text-secondary);
  letter-spacing: 0.5vw;
  font-family: inherit;
}

.action-btn.secondary {
  border-color: rgba(245, 245, 220, 0.15);
  padding: 2vw 6vw;
}

.action-btn.secondary span {
  font-size: 2.75vw;
  color: rgba(245, 245, 220, 0.4);
}

@media (min-width: 600px) {
  .action-section {
    gap: 18px;
  }
  .action-btn {
    padding: 18px 48px;
    border-radius: 6px;
  }
  .action-btn span {
    font-size: 19.5px;
    letter-spacing: 3px;
  }
  .action-btn.secondary {
    padding: 12px 36px;
  }
  .action-btn.secondary span {
    font-size: 16.5px;
  }
}

/* 故乡选择弹窗 */
.hometown-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hometown-modal-content {
  width: 90%;
  max-width: 400px;
  background: var(--bg-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(245, 245, 220, 0.1);
}

.hometown-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(245, 245, 220, 0.1);
}

.hometown-modal-title {
  font-size: 18px;
  color: var(--text-color);
  letter-spacing: 2px;
}

.hometown-modal-close {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hometown-selectors {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hometown-select {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(245, 245, 220, 0.2);
  border-radius: 8px;
  color: var(--text-color);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f5f5dc' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

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

.hometown-select option {
  background: #2a2a2a;
  color: var(--text-color);
}

.hometown-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(245, 245, 220, 0.1);
}

.confirm-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent-color);
  border: none;
  border-radius: 8px;
  color: #1a1a1a;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 2px;
}

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

/* 权限弹窗 */
.permission-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.permission-modal-content {
  width: 80%;
  max-width: 320px;
  background: var(--bg-color);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  border: 1px solid rgba(245, 245, 220, 0.1);
}

.permission-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.permission-title {
  font-size: 20px;
  color: var(--text-color);
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.permission-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.permission-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent-color);
  border: none;
  border-radius: 8px;
  color: #1a1a1a;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 2px;
}

/* 安全区适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .container {
    padding-bottom: calc(10vw + env(safe-area-inset-bottom));
  }
}
