*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  /* portrait: scale by whichever is tighter — width or height */
  font-size: min(calc(100vw / 37.5), calc(min(100vh, 800px) / 75), 16px);
  background: #242625;
}

@media (orientation: landscape) {
  .viewport {
    overflow-y: auto;
  }

  /* page2 scrolls in landscape instead of squishing into one screen */
  #page2 {
    min-height: 95vh;
    justify-content: flex-start;
  }

  .page2-bg {
    flex: none;
    width: 70%;
    height: auto;
    object-fit: contain;
    object-position: center;
  }
}

body {
  display: flex;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
}

.viewport {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

/* ── Lang Icon Button ── */
.lang-icon-btn {
  position: absolute;
  top: 1.6rem;
  right: 1.6rem;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  transition: opacity 0.2s;
}

.lang-icon-btn svg {
  width: 2.4rem;
  height: 2.4rem;
}

.lang-icon-btn:active {
  opacity: 0.7;
}

/* ── Lang Modal List ── */
.lang-list {
  display: flex;
  flex-direction: column;
}

.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1.4rem 1.6rem;
  font-size: 1.5rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  border: none;
  border-bottom: 0.1rem solid #3a4142;
  cursor: pointer;
  transition: background 0.15s;
}

.lang-item:last-child {
  border-bottom: none;
}

.lang-item--active {
  color: #39ff6e;
}

.lang-item__check {
  font-size: 1.4rem;
  color: #39ff6e;
}

/* ── Pages ── */
.page {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page.hidden {
  display: none;
}

/* ── PAGE 1 ── */
#page1 {
  justify-content: flex-end;
}

.page-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.page1-content {
  align-items: center;
  display: flex;
  flex-direction: column;
  margin-bottom: 2rem;
  padding: 3.2rem 1.5rem 7rem;
  position: relative;
  width: 100%;
  z-index: 1;
}

.safe-title {
  font-size: 2rem;
  font-weight: 500;
  color: #1ed71e;
  text-align: center;
  line-height: normal;
  margin-bottom: 1rem;
}

.safe-desc {
  font-size: 1.3rem;
  color: #fff;
  text-align: center;
  margin-bottom: 3.2rem;
  line-height: 1.6;
}

.enter-btn {
  display: flex;
  height: 4.4rem;
  padding: 0 1rem;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  align-self: stretch;
  font-weight: 600;
  font-size: 1.6rem;
  color: #050d0a;
  background: linear-gradient(90deg, #24ee89 0%, #80ef7c 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.enter-btn:active {
  opacity: 0.85;
}

/* ── PAGE 2 ── */
#page2 {
  justify-content: flex-start;
  height: 100%;
}

.page2-bg {
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
}

.page2-logo {
  display: flex;
  justify-content: center;
  padding-top: 4rem;
}

.page2-logo img {
  width: 20rem;
  height: 5.8rem;
  object-fit: contain;
}

.page2-actions {
  width: 100%;
  padding: 0 1.5rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  height: 4.4rem;
  padding: 0 2rem;
  font-size: 1.6rem;
  font-weight: 700;
  color: #0a1a0e;
  background: linear-gradient(90deg, #24ee89 0%, #80ef7c 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
}

.action-btn:active {
  opacity: 0.82;
}

.action-btn--half {
  flex: 1;
}

.action-btn-row {
  display: flex;
  gap: 1.2rem;
}

.btn-icon {
  flex-shrink: 0;
}

.btn-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.btn-label {
  font-size: 1.6rem;
}

/* ── Modal (共用) ── */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  padding: 2rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
  width: 100%;
}

.modal {
  width: 100%;
  border-radius: 1.2rem;
  border: 0.1rem solid #3a4142;
  background: #34393a;
  overflow: hidden;
}

.modal-title {
  display: flex;
  height: 5.4rem;
  padding: 1.6rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  font-size: 1.6rem;
  color: #fff;
  border-bottom: 0.1rem solid #3a4142;
}

.modal-body {
  padding: 1.6rem;
}

.route-list {
  display: flex;
  flex-direction: column;
  max-height: 40rem;
  overflow-y: auto;
}

.route-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.3rem;
  padding: 0.8rem 0;
  border-bottom: 0.1rem solid #3a4142;
}

.route-item:last-child {
  border-bottom: none;
}

.route-signal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  width: 36px;
}

.route-signal svg {
  width: 1.6rem;
  height: 1.6rem;
}

.route-ms {
  font-size: 0.8rem;
  font-weight: 500;
  color: inherit;
  line-height: 1;
  text-align: center;
}

@keyframes route-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

/* Signal bars */
.lines {
  display: flex;
  align-items: flex-end;
  gap: 0.2rem;
  height: 1.4rem;
}

.line-icon {
  width: 0.35rem;
  border-radius: 0.1rem;
  opacity: 0.2;
  background: currentColor;
}

.line-1 {
  height: 0.5rem;
}
.line-2 {
  height: 0.9rem;
}
.line-3 {
  height: 1.4rem;
}

.route-signal.signal--green {
  color: #1ed71e;
}
.route-signal.signal--green .line-1,
.route-signal.signal--green .line-2,
.route-signal.signal--green .line-3 {
  opacity: 1;
}

.route-signal.signal--yellow {
  color: #f5a623;
}
.route-signal.signal--yellow .line-1,
.route-signal.signal--yellow .line-2 {
  opacity: 1;
}

.route-signal.signal--red {
  color: #ff4444;
}
.route-signal.signal--red .line-1 {
  opacity: 1;
}

.route-signal.signal--gray {
  color: #6b7374;
}

.route-signal.signal--detecting {
  color: #6b7374;
}
.route-signal.signal--detecting .lines {
  animation: route-pulse 1.2s ease-in-out infinite;
}

.route-ms--detecting {
  font-size: 0.85rem;
  opacity: 0.5;
}

.route-name {
  flex: 1;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.9);
  padding: 0 1.2rem;
}

.play-btn {
  display: flex;
  height: 2.5rem;
  padding: 0 1rem;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #050d0a;
  background: #24ee89;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.play-btn:active {
  opacity: 0.85;
}

.play-btn:disabled {
  background: #3a4142;
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
}

.modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.modal-close svg {
  width: 3rem;
  height: 3rem;
}

.modal-close:active {
  opacity: 0.7;
}
