html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

:root {
  --primary-color: #4a90e2;
  --secondary-color: #2c3e50;
  --background-color: #f5f6fa;
  --text-color: #2c3e50;
  --border-color: #dcdde1;
  --accent-color: #e74c3c;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
}

header {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background-color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h1 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 2rem;
  line-height: 1.3;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  font-display: swap;
  text-rendering: optimizeSpeed;
}

.subtitle {
  color: var(--secondary-color);
  font-size: 1.2rem;
  line-height: 1.4;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.calculator-container {
  background-color: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.calculator-title {
  color: var(--primary-color);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.calculator-subtitle {
  color: var(--secondary-color);
  font-size: 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

input[type="text"] {
  width: 120px;
  padding: 0.8rem;
  border: 2px solid var(--border-color);
  border-radius: 5px;
  font-size: 1rem;
  transition: all 0.3s ease;
  -moz-appearance: textfield;
}

input[type="text"]::-webkit-outer-spin-button,
input[type="text"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

input[type="text"].invalid {
  border-color: var(--accent-color);
  background-color: rgba(231, 76, 60, 0.05);
}

input[type="text"].valid {
  border-color: var(--primary-color);
  background-color: rgba(74, 144, 226, 0.05);
}

.result-container {
  text-align: center;
  margin-top: 2rem;
  padding: 1rem;
  background-color: var(--background-color);
  border-radius: 5px;
}

.detailed-result {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.sub-result {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--secondary-color);
}

.total-result {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 2px solid var(--border-color);
  width: 100%;
}

.result {
  font-size: 2em;
  font-weight: bold;
  color: #2c3e50;
  margin: 20px 0;
}

.button-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px auto;
  width: 100%;
  max-width: 200px;
}

.clean-button {
  padding: 12px 24px;
  min-width: 140px;
  max-width: 180px;
  background-color: #125382;
  border: 2px solid #125382;
  border-radius: 5px;
  color: white;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  margin: 0;
}

.clean-button:hover {
  background-color: #2980b9;
  border-color: #2471a3;
}

.clean-button:active {
  transform: scale(0.98);
}

.explanation,
.faq,
.game-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h2 {
  color: var(--secondary-color);
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}

h3 {
  color: var(--primary-color);
  margin: 1rem 0;
  font-size: 1.3rem;
}

ol,
ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

li {
  margin-bottom: 0.5rem;
}

.faq-item {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.faq-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Footer Styles */
footer {
  text-align: center;
  padding: 3rem 2rem;
  background-color: white;
  margin-top: 2rem;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  text-align: left;
}

.footer-section {
  padding: 0 1rem;
}

.footer-section h4 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.footer-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-section ul li {
  margin-bottom: 0.8rem;
  position: relative;
  padding-left: 1rem;
}

.footer-section ul li::before {
  content: "•";
  color: var(--primary-color);
  position: absolute;
  left: 0;
}

.footer-section a {
  color: #1e40c8;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  padding-bottom: 2px;
}

.footer-section a:hover {
  color: #1e40c8;
}

.footer-section a::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 1px;
  bottom: 0;
  left: 0;
  background-color: var(--primary-color);
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.3s ease;
}

.footer-section a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.footer-bottom {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.footer-bottom p {
  color: var(--secondary-color);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.keywords {
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .input-group {
    flex-direction: column;
    align-items: stretch;
  }

  input[type="text"] {
    width: 100%;
  }

  h1 {
    font-size: 1.8rem;
  }

  .subtitle {
    font-size: 1.1rem;
  }

  .result {
    font-size: 2rem;
  }

  .button-container {
    flex-direction: column;
    gap: 15px;
    max-width: 200px;
  }

  .clean-button {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .footer-section {
    text-align: center;
  }

  footer {
    padding: 2rem 1rem;
  }

  header {
    padding: 2rem 1rem;
  }
}

.modal-content {
  background-color: white;
  margin: 15% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  max-width: 600px;
  border-radius: 5px;
  position: relative;
}

/* Game Styles */
.game-section {
  text-align: center;
  margin-bottom: 2rem;
}

.game-container {
  max-width: 600px;
  margin: 0 auto;
}

.game-button {
  background-color: #1e40c8;
  border: 2px solid #1e40c8;
  color: white;
  padding: 12px 24px;
  border-radius: 5px;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 10px;
}

.game-button:hover {
  background-color: #d35400;
  border-color: #c0392b;
}

.game-button:active {
  transform: scale(0.98);
}

.game-question {
  display: none;
  margin: 20px 0;
}

.question-text {
  font-size: 1.2em;
  margin-bottom: 20px;
  color: var(--secondary-color);
}

.game-input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
}

.game-input-group input {
  width: 150px;
  padding: 10px;
  border: 2px solid var(--border-color);
  border-radius: 5px;
  font-size: 1em;
}

.feedback-text {
  margin: 15px 0;
  font-weight: bold;
}

.feedback-text.correct {
  color: #27ae60;
}

.feedback-text.incorrect {
  color: #e74c3c;
}

.game-progress {
  margin: 15px 0;
  font-size: 1.1em;
  color: var(--secondary-color);
}

.final-score {
  font-size: 2.5em;
  font-weight: bold;
  color: var(--primary-color);
  margin: 20px 0;
}

.score-message {
  font-size: 1.2em;
  margin: 15px 0;
  color: var(--secondary-color);
}

.game-results {
  display: none;
  text-align: center;
}

.game-results h3 {
  color: var(--primary-color);
  margin-bottom: 15px;
}

/* Share Button Styles */
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.header-text {
  flex: 1;
}

.share-button {
  flex-shrink: 0;
  margin-top: 0.5rem;
}

.share-button button {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.share-button button:hover {
  background: #f5f5f5;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.share-button button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.share-button svg {
  color: #666;
}

@media (max-width: 768px) {
  .share-button button {
    width: 36px;
    height: 36px;
    padding: 6px;
  }

  .share-button svg {
    width: 20px;
    height: 20px;
  }
}
