/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: linear-gradient(180deg, #f5f5f7 0%, #ffffff 100%);
  background-attachment: fixed;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  line-height: 1.47;
  color: #1d1d1f;
  background: transparent;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 980px;
  margin: 0 auto;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 48px 40px;
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 
              0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.04);
  position: relative;
}

/* GitHub Button */
.github-button {
  position: absolute;
  top: 24px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background-color: #1d1d1f;
  color: #ffffff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  letter-spacing: -0.01em;
}

.github-button:hover {
  background-color: #0071e3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.github-button:active {
  transform: translateY(0);
}

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

/* Typography */
h1 {
  font-size: 2.5rem;
  margin-bottom: 12px;
  color: #1d1d1f;
  text-align: center;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.subtitle {
  text-align: center;
  color: #86868b;
  margin-bottom: 40px;
  font-size: 1.125rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* Controls */
.controls {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
}

label {
  font-weight: 500;
  color: #1d1d1f;
  font-size: 0.875rem;
  letter-spacing: -0.01em;
  padding-left: 4px;
}

.select-input {
  padding: 12px 16px;
  font-size: 1rem;
  border: 1px solid #d2d2d7;
  border-radius: 10px;
  background-color: #ffffff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 400;
  color: #1d1d1f;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2386868b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.select-input:hover {
  border-color: #0071e3;
  box-shadow: 0 0 0 1px rgba(0, 113, 227, 0.1);
}

.select-input:focus {
  outline: none;
  border-color: #0071e3;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

/* Image Container */
.image-container {
  text-align: center;
  min-height: 400px;
  max-height: 90vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow: hidden;
}

/* Heatmap Pair Layout */
.heatmap-pair {
  display: flex;
  gap: 32px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 1600px;
}

.heatmap-wrapper {
  flex: 1;
  max-width: 700px;
  text-align: center;
}

.heatmap-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.heatmap-wrapper img {
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08),
              0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.heatmap-wrapper img:hover {
  transform: scale(1.02);
}

/* Stats Boxes */
.stats-box {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(242, 242, 247, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.stat-label {
  color: #424245;
  font-weight: 500;
}

.stat-value {
  color: #1d1d1f;
  font-weight: 600;
  font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
  font-size: 1rem;
}

.stat-emoji {
  margin-left: 8px;
  font-size: 1.2rem;
  transition: transform 0.2s ease;
}

.stat-emoji:hover {
  transform: scale(1.1);
}

/* Clickable images cursor */
.heatmap-wrapper img {
  cursor: pointer;
}

/* Chi-square Statistical Analysis Section */
.chisquare-container {
  display: flex;
  justify-content: center;
  margin: 32px 0;
}

.chisquare-wrapper {
  max-width: 800px;
  text-align: center;
}

.chisquare-wrapper img {
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08),
              0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.chisquare-wrapper img:hover {
  transform: scale(1.02);
}

#chisquare-section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

#chisquare-section p {
  color: #86868b;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

/* Toggle hint styling */
.toggle-hint {
  font-size: 0.875rem;
  color: #86868b;
  margin-top: 8px;
  font-style: italic;
}

/* FAQ Section */
.faq-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.faq-section h1 {
  font-size: 1.875rem;
  margin-bottom: 20px;
  text-align: left;
}

.faq-section p {
  font-size: 1rem;
  line-height: 1.6;
  color: #424245;
  margin-bottom: 16px;
}

.faq-section ul, .faq-section ol {
  margin-left: 24px;
  margin-bottom: 16px;
}

.faq-section li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.faq-section code {
  background-color: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

.faq-section pre {
  background-color: rgba(0, 0, 0, 0.05);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.faq-section pre code {
  background-color: transparent;
  padding: 0;
}

.faq-section img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 24px auto;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08),
              0 2px 8px rgba(0, 0, 0, 0.04);
}

.faq-section audio {
  width: 100%;
  max-width: 600px;
  display: block;
  margin: 24px auto;
  border-radius: 8px;
  outline: none;
}

.faq-section blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  background-color: rgba(0, 113, 227, 0.06);
  border-left: 4px solid #0071e3;
  border-radius: 8px;
  font-style: italic;
  color: #424245;
}

.faq-section blockquote p {
  margin-bottom: 0;
}

.faq-section blockquote p:not(:last-child) {
  margin-bottom: 12px;
}

.error-message {
  padding: 24px 32px;
  background: linear-gradient(135deg, #fff4e6 0%, #fff9f0 100%);
  border: 1px solid rgba(255, 149, 0, 0.2);
  border-radius: 12px;
  color: #bf5700;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  max-width: 400px;
}

/* Debug Info - iOS Style */
#debug-info {
  background: rgba(242, 242, 247, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 16px 20px;
  margin: 24px 0;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: #1d1d1f;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

#debug-info strong {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.01em;
  color: #1d1d1f;
}

#debug-output {
  display: block;
  margin-top: 8px;
  color: #424245;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }
  
  .container {
    padding: 32px 24px;
    border-radius: 16px;
  }
  
  .github-button {
    top: 16px;
    right: 16px;
    padding: 8px 12px;
    font-size: 0.875rem;
  }
  
  h1 {
    font-size: 2rem;
    padding-right: 80px;
  }
  
  .subtitle {
    font-size: 1rem;
    margin-bottom: 32px;
  }
  
  .controls {
    flex-direction: column;
    gap: 12px;
  }
  
  .control-group {
    width: 100%;
    min-width: unset;
  }
  
  .select-input {
    width: 100%;
  }
  
  .image-container {
    min-height: 300px;
    max-height: none;
    padding: 12px;
  }
  
  .heatmap-pair {
    flex-direction: column;
    gap: 24px;
  }
  
  .heatmap-wrapper img {
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }
  
  .container {
    padding: 24px 20px;
    border-radius: 14px;
  }
  
  .github-button {
    top: 12px;
    right: 12px;
    padding: 7px 10px;
    font-size: 0.8125rem;
    gap: 6px;
  }
  
  .github-icon {
    width: 16px;
    height: 16px;
  }
  
  h1 {
    font-size: 1.75rem;
    padding-right: 75px;
  }
  
  .subtitle {
    font-size: 0.9375rem;
  }
  
  #debug-info {
    font-size: 10px;
    padding: 14px 16px;
  }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
  html {
    background: linear-gradient(180deg, #000000 0%, #1c1c1e 100%);
    background-attachment: fixed;
  }
  
  body {
    background: transparent;
    color: #f5f5f7;
  }
  
  .container {
    background-color: rgba(28, 28, 30, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  h1 {
    color: #f5f5f7;
  }
  
  .subtitle {
    color: #98989d;
  }
  
  label {
    color: #f5f5f7;
  }
  
  .select-input {
    background-color: #1c1c1e;
    border-color: #38383a;
    color: #f5f5f7;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2398989d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
  
  .select-input:hover {
    border-color: #0a84ff;
    box-shadow: 0 0 0 1px rgba(10, 132, 255, 0.2);
  }
  
  .select-input:focus {
    border-color: #0a84ff;
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.15);
  }
  
  #debug-info {
    background: rgba(44, 44, 46, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #f5f5f7;
  }
  
  #debug-info strong {
    color: #f5f5f7;
  }
  
  #debug-output {
    color: #ebebf5;
  }
  
  .error-message {
    background: linear-gradient(135deg, #3d2500 0%, #4d3000 100%);
    border: 1px solid rgba(255, 149, 0, 0.3);
    color: #ffa940;
  }
  
  .github-button {
    background-color: #f5f5f7;
    color: #1d1d1f;
  }
  
  .github-button:hover {
    background-color: #0a84ff;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(10, 132, 255, 0.3);
  }
  
  .faq-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .faq-section p {
    color: #ebebf5;
  }
  
  .faq-section code {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .faq-section pre {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .faq-section blockquote {
    background-color: rgba(10, 132, 255, 0.12);
    border-left-color: #0a84ff;
    color: #ebebf5;
  }
}

/* Smooth transitions */
* {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

button, select, input, a {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
