* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: linear-gradient(135deg, #080c18, #0a1428, #0c0e20);
  color: #c8d0e0;
  min-height: 100vh;
}

button,
.btn {
  touch-action: manipulation;
}

input {
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

header {
  background: rgba(8, 12, 24, 0.85);
  backdrop-filter: blur(16px);
  padding: 20px 0;
  text-align: center;
  border-bottom: 2px solid rgba(100, 140, 200, 0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 2rem;
  color: #88b0e8;
  text-shadow: 0 0 24px rgba(100, 160, 232, 0.3);
  margin-bottom: 10px;
}

nav {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  padding: 0 20px;
}

nav a {
  color: #8898b0;
  text-decoration: none;
  padding: 10px 25px;
  border-radius: 8px;
  border: 1px solid rgba(100, 140, 200, 0.12);
  transition: all 0.3s ease;
  font-size: 1rem;
  background: rgba(100, 140, 200, 0.05);
}

nav a:hover, nav a.active {
  background: rgba(100, 140, 200, 0.15);
  color: #88b0e8;
  border-color: rgba(100, 140, 200, 0.3);
  box-shadow: 0 0 20px rgba(100, 140, 200, 0.12);
}

.container {
  max-width: 1000px;
  margin: 30px auto;
  padding: 0 20px;
}

.page-title {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 10px;
  color: #88b0e8;
}

.page-subtitle {
  text-align: center;
  color: #607090;
  margin-bottom: 30px;
  font-size: 1rem;
}

.difficulty-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: bold;
  margin-bottom: 12px;
}

.badge-easy {
  background: rgba(76, 175, 80, 0.15);
  color: #60c080;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.badge-medium {
  background: rgba(200, 160, 80, 0.15);
  color: #c8a050;
  border: 1px solid rgba(200, 160, 80, 0.3);
}

.badge-hard {
  background: rgba(200, 80, 80, 0.15);
  color: #c87070;
  border: 1px solid rgba(200, 80, 80, 0.3);
}

.puzzle-card {
  background: rgba(100, 140, 200, 0.06);
  border: 1px solid rgba(100, 140, 200, 0.1);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.puzzle-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(100, 160, 232, 0.3), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.puzzle-card:hover {
  border-color: rgba(100, 160, 232, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.puzzle-card:hover::before {
  opacity: 1;
}

.puzzle-number {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 2.5rem;
  font-weight: bold;
  color: rgba(100, 160, 232, 0.08);
}

.puzzle-question {
  font-size: 1.15rem;
  line-height: 1.6;
  margin-bottom: 15px;
  color: #d0d8e8;
}

.puzzle-hint {
  font-size: 0.9rem;
  color: #607090;
  font-style: italic;
  margin-bottom: 15px;
  display: none;
}

.puzzle-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  font-family: 'Georgia', serif;
}

.btn-hint {
  background: rgba(100, 140, 200, 0.12);
  color: #88b0e8;
  border: 1px solid rgba(100, 140, 200, 0.25);
}

.btn-hint:hover {
  background: rgba(100, 140, 200, 0.25);
}

.btn-answer {
  background: rgba(100, 160, 232, 0.15);
  color: #88b0e8;
  border: 1px solid rgba(100, 160, 232, 0.3);
}

.btn-answer:hover {
  background: rgba(100, 160, 232, 0.3);
}

.answer-block {
  display: none;
  margin-top: 15px;
  padding: 15px;
  background: rgba(100, 160, 232, 0.06);
  border-radius: 8px;
  border: 1px solid rgba(100, 160, 232, 0.12);
}

.answer-block.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

.answer-label {
  font-weight: bold;
  color: #88b0e8;
  margin-bottom: 5px;
}

.answer-text {
  color: #909cb0;
  line-height: 1.5;
}

.puzzle-input-area {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.puzzle-input {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid rgba(100, 140, 200, 0.2);
  background: rgba(100, 140, 200, 0.06);
  color: #d0d8e8;
  font-size: 1rem;
  font-family: 'Georgia', serif;
  outline: none;
  transition: border-color 0.3s;
  flex: 1;
  min-width: 200px;
}

.puzzle-input:focus {
  border-color: #88b0e8;
}

.input-result {
  font-size: 0.9rem;
  padding: 5px 12px;
  border-radius: 8px;
  display: none;
}

.input-result.correct {
  display: inline;
  background: rgba(76, 175, 80, 0.15);
  color: #60c080;
}

.input-result.wrong {
  display: inline;
  background: rgba(200, 80, 80, 0.15);
  color: #c87070;
}

.hero {
  text-align: center;
  padding: 60px 20px 40px;
}

.hero h2 {
  font-size: 2.5rem;
  color: #88b0e8;
  margin-bottom: 15px;
  text-shadow: 0 0 30px rgba(100, 160, 232, 0.2);
}

.hero p {
  font-size: 1.2rem;
  color: #607090;
  max-width: 600px;
  margin: 0 auto 30px;
  line-height: 1.6;
}

.difficulty-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.diff-card {
  background: rgba(100, 140, 200, 0.06);
  border: 1px solid rgba(100, 140, 200, 0.1);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.diff-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.diff-card.easy:hover {
  border-color: rgba(76, 175, 80, 0.4);
  box-shadow: 0 10px 40px rgba(76, 175, 80, 0.1);
}

.diff-card.medium:hover {
  border-color: rgba(200, 160, 80, 0.4);
  box-shadow: 0 10px 40px rgba(200, 160, 80, 0.1);
}

.diff-card.hard:hover {
  border-color: rgba(200, 80, 80, 0.4);
  box-shadow: 0 10px 40px rgba(200, 80, 80, 0.1);
}

.diff-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.diff-card h3 {
  font-size: 1.4rem;
  margin-bottom: 10px;
}

.diff-card.easy h3 { color: #60c080; }
.diff-card.medium h3 { color: #c8a050; }
.diff-card.hard h3 { color: #c87070; }

.diff-card p {
  color: #607090;
  font-size: 0.95rem;
  line-height: 1.5;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 30px 0;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: bold;
  color: #88b0e8;
}

.stat-label {
  font-size: 0.85rem;
  color: #506080;
  margin-top: 5px;
}

.rebus-visual {
  font-size: 1.8rem;
  text-align: center;
  padding: 20px;
  margin: 10px 0;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  letter-spacing: 3px;
  font-family: 'Courier New', monospace;
  border: 1px solid rgba(100, 140, 200, 0.1);
}

.footer {
  text-align: center;
  padding: 30px 20px;
  color: #384058;
  font-size: 0.85rem;
  border-top: 1px solid rgba(100, 140, 200, 0.08);
  margin-top: 40px;
}

.score-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(8, 12, 24, 0.85);
  backdrop-filter: blur(16px);
  padding: 15px 20px;
  border-radius: 12px;
  border: 1px solid rgba(100, 160, 232, 0.2);
  z-index: 99;
  text-align: center;
  min-width: 180px;
}

.score-panel .score-label {
  font-size: 0.8rem;
  color: #607090;
}

.score-panel .score-value {
  font-size: 1.5rem;
  color: #88b0e8;
  font-weight: bold;
}

.score-bar {
  height: 6px;
  background: rgba(100, 140, 200, 0.1);
  border-radius: 3px;
  margin: 8px 0;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5080c0, #88b0e8);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.global-line {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #909cb0;
}

.page-celebration {
  display: none;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(100, 160, 232, 0.1);
  border: 1px solid rgba(100, 160, 232, 0.25);
  color: #88b0e8;
  font-size: 0.85rem;
  animation: fadeIn 0.4s ease;
}

.diff-count {
  color: #88b0e8;
  font-weight: bold;
  margin-top: 10px;
  font-size: 0.95rem;
}

.diff-progress {
  height: 6px;
  background: rgba(100, 140, 200, 0.1);
  border-radius: 3px;
  margin-top: 10px;
  overflow: hidden;
}

.diff-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5080c0, #88b0e8);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.celebration {
  display: none;
  margin: 20px auto;
  max-width: 600px;
  padding: 20px;
  text-align: center;
  background: rgba(100, 160, 232, 0.08);
  border: 1px solid rgba(100, 160, 232, 0.25);
  border-radius: 16px;
  animation: fadeIn 0.5s ease;
}

.celebration .celebrate-title {
  font-size: 1.6rem;
  color: #88b0e8;
  margin-bottom: 8px;
}

.celebration p {
  color: #909cb0;
  line-height: 1.5;
}

.reset-btn {
  margin-top: 12px;
  padding: 10px 24px;
  border: 1px solid rgba(200, 80, 80, 0.3);
  background: rgba(200, 80, 80, 0.1);
  color: #c87070;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: 'Georgia', serif;
  transition: all 0.3s ease;
}

.reset-btn:hover {
  background: rgba(200, 80, 80, 0.2);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .container {
    margin: 20px auto;
    padding: 0 14px;
  }

  header {
    padding: 12px 0;
  }

  header h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
  }

  nav {
    gap: 8px;
    padding: 0 10px;
  }

  nav a {
    padding: 8px 16px;
    font-size: 0.9rem;
    flex: 1 1 auto;
    min-width: 64px;
  }

  .hero {
    padding: 40px 14px 30px;
  }

  .hero h2 {
    font-size: 1.9rem;
  }

  .hero p {
    font-size: 1.05rem;
    line-height: 1.5;
  }

  .stats {
    gap: 18px;
    margin: 24px 0;
  }

  .stat-number {
    font-size: 1.7rem;
  }

  .difficulty-section {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 30px;
  }

  .diff-card {
    padding: 22px;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .page-subtitle {
    margin-bottom: 22px;
  }

  .puzzle-card {
    padding: 18px;
    border-radius: 14px;
    margin-bottom: 16px;
  }

  .puzzle-question {
    font-size: 1.05rem;
  }

  .rebus-visual {
    font-size: 1.4rem;
    padding: 14px 10px;
    letter-spacing: 2px;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .answer-block {
    padding: 12px;
  }
}

@media (max-width: 620px) {
  .puzzle-input-area {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .puzzle-input {
    min-width: 0;
    width: 100%;
    padding: 13px 16px;
    font-size: 16px;
  }

  .puzzle-input-area .btn {
    width: 100%;
    padding: 13px 20px;
    min-height: 44px;
  }

  .puzzle-actions {
    gap: 8px;
  }

  .puzzle-actions .btn {
    flex: 1 1 45%;
    min-height: 44px;
    padding: 12px 0;
    text-align: center;
  }

  .input-result {
    text-align: center;
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  .input-result.correct,
  .input-result.wrong {
    display: block;
  }

  .footer {
    padding: 24px 14px;
  }
}

@media (max-width: 600px) {
  nav a {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .score-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }

  .score-panel .score-label,
  .score-panel .global-line {
    display: none;
  }

  .score-panel .score-value {
    font-size: 1.1rem;
    white-space: nowrap;
  }

  .score-bar {
    flex: 1;
    min-width: 60px;
    margin: 0;
  }

  .page-celebration {
    flex: 1 1 100%;
    margin: 6px 0 0;
    padding: 6px 8px;
    font-size: 0.8rem;
    text-align: center;
  }
}

@media (max-width: 600px) {
  body {
    padding-bottom: calc(58px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  header h1 {
    font-size: 1.25rem;
  }

  nav {
    gap: 6px;
  }

  nav a {
    padding: 7px 8px;
    font-size: 0.78rem;
    min-width: 56px;
  }

  .rebus-visual {
    font-size: 1.2rem;
  }
}

@media (hover: none) {
  .btn:hover,
  nav a:hover,
  .diff-card:hover,
  .puzzle-card:hover {
    transform: none;
    box-shadow: none;
  }
}