* {
  box-sizing: border-box;
  user-select: none;
}

body {
  background: #eef2f7;
  font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
}

.game-container {
  max-width: 1200px;
  width: 100%;
  background: white;
  border-radius: 36px;
  box-shadow: 0 20px 35px rgba(0, 0, 0, 0.1);
  padding: 24px 28px;
  transition: all 0.2s;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

h1 {
  font-size: 1.6rem;
  margin: 0;
  background: linear-gradient(135deg, #1f4870, #2a6f8f);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.timer-box {
  background: #f2f6fb;
  padding: 6px 20px;
  border-radius: 60px;
  font-family: monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: #1f5a6e;
}

.game-layout {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.canvas-area {
  flex: 2;
  min-width: 280px;
  display: flex;
  justify-content: center;
}

canvas {
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  width: 100%;
  height: auto;
  cursor: pointer;
  display: block;
  aspect-ratio: 1 / 1;
  max-width: 700px;
}

.control-panel {
  flex: 1;
  min-width: 260px;
  background: #fafcff;
  border-radius: 32px;
  padding: 20px 16px;
  border: 1px solid #eef2f8;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.difficulty-group {
  display: flex;
  gap: 12px;
  justify-content: stretch;
}

.difficulty-btn {
  flex: 1;
  background: white;
  border: 1px solid #dce5ef;
  border-radius: 60px;
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 0;
  color: #1f4a6e;
  cursor: pointer;
  transition: 0.1s ease;
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  text-align: center;
}

.difficulty-btn.active {
  background: #2a6f8f;
  border-color: #2a6f8f;
  color: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.difficulty-btn:active {
  transform: scale(0.96);
}

.difficulty-btn:hover {
  background: #e3edf6;
}

.difficulty-btn.active:hover {
  background: #1f5a6e;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.num-btn {
  background: white;
  border: 1px solid #dce5ef;
  border-radius: 60px;
  font-size: 1.6rem;
  font-weight: 600;
  padding: 10px 0;
  color: #1f4a6e;
  cursor: pointer;
  transition: 0.1s ease;
  font-family: monospace;
}

.num-btn:active {
  background: #e3edf6;
  transform: scale(0.96);
}

.undo-btn,
.new-btn,
.print-btn,
.download-btn {
  background: #fef5ef;
  border-color: #f0e0d0;
  font-size: 1rem;
  font-weight: 500;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.undo-btn {
  background: #ecf3fa;
  border-color: #cbdde9;
}

.new-btn {
  background: #e8f0e8;
  border-color: #cde0cd;
}

.print-btn,
.download-btn {
  background: #f0f4fa;
  border-color: #d0deec;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: stretch;
}

.action-buttons button {
  flex: 1;
  min-width: 70px;
}

.status-area {
  background: #ffffffdb;
  border-radius: 40px;
  padding: 12px 16px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: #2c5a6e;
  border: 1px solid #e2e9f2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.howto-section {
  margin-top: 28px;
  background: #fefef7;
  border-radius: 32px;
  padding: 20px 24px;
  border: 1px solid #e6ede8;
}

.howto-section h3 {
  font-size: 1.3rem;
  margin: 0 0 16px 0;
  color: #2c6e4a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.howto-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.rule-card {
  width: 100%;
  background: #ffffff;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  border: 1px solid #eef0e5;
}

.rule-card h4 {
  margin: 0 0 10px 0;
  color: #1f4870;
}

.diagram {
  background: #f9f7ef;
  border-radius: 16px;
  padding: 10px;
  text-align: center;
  margin: 12px 0;
}

.jigsaw-shape {
  display: inline-grid;
  grid-template-columns: repeat(3, 32px);
  gap: 2px;
  background: #e2dcd0;
  padding: 4px;
  border-radius: 12px;
}

.shape-cell {
  width: 32px;
  height: 32px;
  background: #cbd8cf;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: #2e4e3a;
  border-radius: 8px;
}

.shape-cell.highlight {
  background: #b3cfa3;
  box-shadow: inset 0 0 0 2px #4e7b3a;
}

.tip-list {
  margin: 8px 0 0 18px;
  padding-left: 0;
}

.tip-list li {
  margin: 6px 0;
  line-height: 1.4;
}

.other-puzzles-section {
  margin-top: 32px;
  padding: 20px 0 10px 0;
  border-top: 2px solid #e2e9f0;
}

.other-puzzles-section h2 {
  font-size: 1.5rem;
  margin: 0 0 24px 0;
  color: #2c6e4a;
  text-align: center;
  font-weight: 600;
}

.puzzles-grid {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 28px;
  row-gap: 32px;
}

.puzzle-item {
  flex: 0 0 auto;
  width: 104px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.puzzle-item:hover {
  transform: translateY(-5px);
}

.puzzle-icon {
  width: 104px;
  height: 104px;
  background: #f5f7fc;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
  border: 1px solid #eef2f0;
  margin-bottom: 12px;
}

.puzzle-item:hover .puzzle-icon {
  background: #eef3fc;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.1);
}

.puzzle-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #2c5a6e;
  letter-spacing: 0.3px;
}

.footer-note {
  font-size: 0.7rem;
  text-align: center;
  color: #8c9aa8;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #eef3fa;
}

.privacy-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.7rem;
  color: #2a6f8f;
  text-decoration: none;
}

.privacy-link:hover {
  text-decoration: underline;
}

.error-message {
  background: #ffe6e5;
  color: #b33;
  padding: 12px;
  border-radius: 28px;
  text-align: center;
  font-weight: 500;
}

@media (max-width: 780px) {
  .game-container {
    padding: 16px;
  }
  .game-layout {
    flex-direction: column;
    gap: 20px;
  }
  .control-panel {
    width: 100%;
  }
  .numpad-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .num-btn {
    font-size: 1.4rem;
    padding: 8px;
  }
  .action-buttons button {
    font-size: 0.85rem;
  }
  .difficulty-btn {
    font-size: 0.85rem;
    padding: 8px 0;
  }
  .shape-cell {
    width: 28px;
    height: 28px;
  }
  .jigsaw-shape {
    grid-template-columns: repeat(3, 28px);
  }
  .puzzles-grid {
    gap: 20px;
  }
  .puzzle-item {
    width: 90px;
  }
  .puzzle-icon {
    width: 90px;
    height: 90px;
    font-size: 2.8rem;
    border-radius: 24px;
  }
  .puzzle-name {
    font-size: 0.75rem;
  }
}

@media (max-width: 550px) {
  .num-btn {
    font-size: 1.2rem;
  }
  .undo-btn,
  .new-btn,
  .print-btn,
  .download-btn {
    font-size: 0.8rem;
  }
  .timer-box {
    font-size: 1.2rem;
    padding: 4px 14px;
  }
  .puzzles-grid {
    gap: 16px;
  }
  .puzzle-item {
    width: 80px;
  }
  .puzzle-icon {
    width: 80px;
    height: 80px;
    font-size: 2.5rem;
    border-radius: 20px;
  }
  .difficulty-btn {
    font-size: 0.75rem;
  }
}

/* Multilingual links section - located below the button on the right */
.language-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e9f2;
}

.lang-link {
  font-size: 0.8rem;
  font-weight: 500;
  color: #2a6f8f;
  text-decoration: none;
  background: #f0f4fa;
  padding: 6px 12px;
  border-radius: 40px;
  transition: 0.1s ease;
  display: inline-block;
}

.lang-link:hover {
  background: #e3edf6;
  color: #1f4a6e;
  text-decoration: none;
  transform: translateY(-1px);
}