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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
  padding-bottom: 160px;
}

.step {
  display: none;
  padding: 20px;
  min-height: calc(100vh - 160px);
}

.step.active {
  display: block;
}

.header {
  text-align: center;
  padding: 30px 20px 20px;
  position: relative;
}

.brand-logo {
  margin-bottom: 20px;
}

.logo-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: #C8102E;
  margin-bottom: 4px;
  letter-spacing: 2px;
}

.brand-english {
  font-size: 12px;
  color: #999;
  letter-spacing: 2px;
}

.back-btn {
  position: absolute;
  left: 20px;
  top: 30px;
  background: none;
  border: none;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  padding: 8px 12px;
}

.header h1 {
  font-size: 22px;
  color: #333;
  margin-bottom: 8px;
}

.header p {
  font-size: 14px;
  color: #999;
}

.reference-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 20px;
}

.ref-btn {
  display: flex;
  align-items: center;
  padding: 20px;
  background: #f8f9fa;
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.ref-btn:hover {
  border-color: #667eea;
  background: #fff;
}

.ref-btn:active {
  transform: scale(0.98);
}

.ref-icon {
  font-size: 48px;
  margin-right: 20px;
}

.ref-info {
  text-align: left;
}

.ref-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.ref-size {
  font-size: 14px;
  color: #999;
}

.instructions {
  margin: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 16px;
}

.instructions-title {
  font-size: 18px;
  color: #333;
  margin-bottom: 16px;
  text-align: center;
}

.instruction-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.instruction-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-num {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
}

.step-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.step-desc {
  font-size: 13px;
  color: #888;
  line-height: 1.5;
  margin: 0;
}

.calibration-area {
  width: 100%;
  height: 300px;
  background: #f8f9fa;
  border-radius: 16px;
  margin-bottom: 24px;
  position: relative;
  touch-action: none;
  overflow: hidden;
}

.calibration-shape {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 3px dashed #667eea;
  background: rgba(102, 126, 234, 0.1);
}

.calibration-shape.id-card {
  width: 125px;
  height: 200px;
}

.calibration-shape.coin {
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

.slider-container {
  padding: 0 20px;
  margin-bottom: 24px;
}

.slider-container.measure-slider {
  margin-bottom: 16px;
}

.slider-container input[type="range"] {
  width: 100%;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  -webkit-appearance: none;
  appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  background: #667eea;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 14px;
  color: #999;
}

.slider-labels span:nth-child(2) {
  font-weight: 600;
  color: #667eea;
  font-size: 16px;
}

.confirm-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 16px auto;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.confirm-btn:active {
  transform: scale(0.98);
}

.hint {
  text-align: center;
  font-size: 14px;
  color: #999;
}

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px;
  background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
  border: 2px solid #e9ecef;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mode-btn:hover {
  border-color: #667eea;
  transform: translateY(-2px);
}

.mode-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.mode-name {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.mode-desc {
  font-size: 14px;
  color: #999;
}

.landscape-hint {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: #fff;
  padding: 16px;
  border-radius: 12px;
  text-align: center;
  margin-bottom: 16px;
}

.rotate-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: rotateHint 1.5s ease-in-out infinite;
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}

.landscape-hint p {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

.measure-area {
  width: 100%;
  height: 450px;
  background: #f8f9fa;
  border-radius: 16px;
  margin-bottom: 24px;
  position: relative;
  touch-action: none;
  overflow: hidden;
}

.ring-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #ff4757;
  border-radius: 50%;
  background: transparent;
}

.finger-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.finger-line {
  position: absolute;
  width: 4px;
  height: 300px;
  background: #ff4757;
  border-radius: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.finger-line.horizontal {
  width: 4px;
  height: 300px;
}

.finger-line.horizontal.left {
  transform: translateY(-50%) rotate(90deg);
}

.finger-line.horizontal.right {
  transform: translateY(-50%) rotate(90deg);
}

.device-info {
  background: #f8f9fa;
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
}

.device-info .info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e9ecef;
}

.device-info .info-row:last-child {
  border-bottom: none;
}

.device-info .info-row.highlight {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  margin: 8px -20px;
  padding: 12px 20px;
}

.device-info .info-label {
  font-size: 14px;
  color: #999;
}

.device-info .info-value {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.device-info .info-row.highlight .info-value {
  color: #667eea;
  font-size: 18px;
}

.live-result {
  background: #f8f9fa;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.live-result .result-item {
  text-align: center;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
}

.live-result .result-item.highlight {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.live-result .result-label {
  font-size: 12px;
  color: #999;
  display: block;
  margin-bottom: 4px;
}

.live-result .result-value {
  font-size: 18px;
  font-weight: 700;
  color: #333;
}

.live-result .result-item.highlight .result-value {
  color: #667eea;
  font-size: 20px;
}

.result-card {
  background: #f8f9fa;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid #e9ecef;
}

.result-row:last-child {
  border-bottom: none;
}

.result-row.highlight {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  margin: 8px -24px;
  padding: 16px 24px;
}

.result-label {
  font-size: 16px;
  color: #666;
}

.result-value {
  font-size: 20px;
  font-weight: 700;
  color: #333;
}

.result-row.highlight .result-value {
  color: #667eea;
  font-size: 24px;
}

.booking-section {
  text-align: center;
  padding: 20px;
  margin: 20px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, rgba(200, 16, 46, 0.1) 100%);
  border-radius: 16px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.booking-hint {
  font-size: 16px;
  color: #333;
  font-weight: 500;
  margin-bottom: 16px;
}

.qr-code {
  width: 160px;
  height: 160px;
  margin: 0 auto 12px;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.qr-code img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.qr-hint {
  font-size: 14px;
  color: #999;
  margin-top: 0;
}

.result-actions {
  display: flex;
  gap: 16px;
  padding: 0 20px;
}

.action-btn {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.action-btn:active {
  transform: scale(0.98);
}

.action-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.action-btn.secondary {
  background: #f0f0f0;
  color: #666;
}

.footer {
  text-align: center;
  padding: 30px 20px 20px;
}

.footer-text {
  font-size: 12px;
  color: #ccc;
  letter-spacing: 2px;
}

.floating-slider {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  border-radius: 20px 20px 0 0;
  z-index: 100;
}

.floating-slider.hidden {
  display: none;
}

.floating-slider input[type="range"] {
  width: 100%;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  -webkit-appearance: none;
  appearance: none;
}

.floating-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(102, 126, 234, 0.5);
}

.floating-slider .slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 14px;
  color: #999;
}

.floating-slider .slider-labels span:nth-child(2) {
  font-weight: 600;
  color: #667eea;
  font-size: 18px;
}

.floating-slider .confirm-btn {
  width: 100%;
  margin: 16px 0 0;
}

@media screen and (max-width: 480px) {
  .header {
    padding: 20px 15px 15px;
  }

  .logo-icon {
    width: 60px;
    height: 60px;
  }

  .brand-name {
    font-size: 16px;
    letter-spacing: 1px;
  }

  .header h1 {
    font-size: 18px;
  }

  .ref-btn {
    padding: 16px;
  }

  .ref-icon {
    font-size: 40px;
  }

  .calibration-area {
    height: 280px;
  }

  .measure-area {
    height: 400px;
  }
}

@media screen and (orientation: landscape) {
  .measure-area {
    height: 300px;
  }
  
  .finger-line.horizontal {
    width: 4px;
    height: 200px;
  }
}