body {
  font-family: 'BIZ UDPGothic', 'Segoe UI', 'Meiryo', sans-serif;
  background: #f7f7f7;
}

header {
  background: #fff;
}
.header-bar {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  padding: 12px 0;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-bar a {
  color: #222;
  text-decoration: none;
  font-weight: bold;
  font-size: 1.1em;
  margin-left: 12px;
}
.title-header {
  margin: 32px auto 16px auto;
  text-align: center;
  font-size: 2em;
  font-weight: bold;
  letter-spacing: 0.08em;
}
.title-header img {
  max-width: 1500px;
  width: 80vw;
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

@media (max-width: 600px) {
  .title-header img {
    max-width: 90vw;
    width: 90vw;
  }
  .problem-image {
    max-width: 95vw;
    width: 95vw;
  }
  .answer-box input[type="text"] {
    width: 90vw;
    font-size: 1.1em;
  }
}
@media (min-width: 601px) and (max-width: 900px) {
  .title-header img {
    max-width: 400px;
    width: 85vw;
  }
  .problem-image {
    max-width: 400px;
    width: 85vw;
  }
  .answer-box input[type="text"] {
    width: 350px;
    font-size: 1.15em;
  }
}
@media (min-width: 901px) {
  .title-header img {
    max-width: 600px;
    width: 600px;
  }
  .problem-image {
    max-width: 600px;
    width: 600px;
  }
  .answer-box input[type="text"] {
    width: 480px;
    font-size: 1.5em;
    padding: 16px 32px;
  }
  .answer-box button {
    font-size: 1.3em;
    padding: 16px 40px;
  }
}
.question-counter {
  text-align: center;
  margin: 0 auto 24px auto;
  font-size: 1.2em;
  font-weight: bold;
  color: #222;
  padding: 12px 24px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 2px solid #e9ecef;
}
.progress-steps-bar-container {
  width: 90vw;
  max-width: 540px;
  margin: 0 auto 24px auto;
  display: flex;
  justify-content: center;
}
.progress-steps-bar {
  display: flex;
  width: 100%;
  gap: 6px;
}
.progress-step {
  flex: 1 1 0;
  height: 28px;
  border-radius: 8px;
  background: #bbb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  cursor: pointer;
  border: none;
  outline: none;
  font-size: 1em;
  transition: background 0.2s, color 0.2s, border 0.2s;
  opacity: 0.7;
}
.progress-step.current {
  background: #fff !important;
  color: #222 !important;
  border: 2px solid #2196f3;
  opacity: 1;
  z-index: 1;
}
.progress-step.cleared {
  background: #4caf50 !important;
  color: #fff !important;
  opacity: 1;
}
.progress-step.locked {
  background: #bbb;
  color: #fff;
  cursor: not-allowed;
  opacity: 0.5;
}
.progress-step.reached {
  background: #bbb;
  color: #fff;
  opacity: 0.7;
  cursor: pointer;
}
.progress-step:not(.locked):hover {
  filter: brightness(1.1);
  box-shadow: 0 2px 8px rgba(33,150,243,0.08);
}
.progress-step.cleared.current {
  background: #fff !important;
  color: #222 !important;
  border: 2px solid #222;
}
.problem-image {
  display: block;
  margin: 0 auto 24px auto;
  max-width: 540px;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.rule-image {
  display: block;
  margin: 0 auto 24px auto;
  max-width: 540px;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.answer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}
.answer-box input[type="text"] {
  font-size: 1.2em;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #bbb;
  margin-bottom: 8px;
  width: 220px;
  max-width: 90vw;
}
.answer-box button {
  font-size: 1em;
  padding: 8px 24px;
  border-radius: 6px;
  border: none;
  background: #222;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}
.answer-box button:disabled {
  background: #bbb;
  cursor: not-allowed;
}
.result-message {
  margin-top: 12px;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: bold;
  text-align: center;
  min-height: 20px;
  transition: all 0.3s ease;
}
.result-message.correct {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}
.result-message.incorrect {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}
.result-message.error {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}
.accordion {
  max-width: 400px;
  margin: 0 auto 32px auto;
  text-align: left;
}
.accordion-item {
  border-bottom: 1px solid #ddd;
}
.accordion-title {
  font-size: 1.15em;
  font-weight: bold;
  padding: 16px 24px;
  background: #fff;
  color: #222;
  border-radius: 8px;
  border: 2px solid #bbb;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s, border 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  width: 100%;
  box-sizing: border-box;
  text-decoration: none;
}
.accordion-title:hover, .accordion-item.open .accordion-title {
  background: #f5f5f5;
  border-color: #bbb;
}
.accordion-content {
  line-height: 1.8;
  padding: 12px 16px;
  display: none;
  background: #fff;
  border-radius: 0 0 6px 6px;
}
.accordion-item.open .accordion-content {
  display: block;
}
.popup {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.popup-content {
  background: #fff;
  padding: 32px 24px;
  border-radius: 16px;
  max-width: 90vw;
  text-align: center;
  font-size: 1.1em;
}
.clear-image {
  display: block;
  margin: 32px auto 0 auto;
  max-width: 320px;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

input, button, textarea, select {
  font-family: 'BIZ UDPGothic', 'Segoe UI', 'Meiryo', sans-serif;
}

.progress-bar-container {
  width: 90vw;
  max-width: 540px;
  height: 18px;
  background: #e9ecef;
  border-radius: 9px;
  margin: 0 auto 24px auto;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4caf50 0%, #2196f3 100%);
  width: 0%;
  border-radius: 9px 0 0 9px;
  transition: width 0.5s cubic-bezier(.4,2,.6,1);
}

/* クリアポップアップ用の強調スタイル */
#clearPopup {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.35);
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999;
}
#clearPopup .popup-content {
  margin: 0 !important;
  left: 0 !important;
  right: 0 !important;
  position: static !important;
}
#clearPopup img {
  max-width: 320px;
  width: 80vw;
  height: auto;
  display: block;
  margin: 0 auto 16px auto;
  border: 2px solid #333;
  border-radius: 12px;
  background: #fff;
  box-sizing: border-box;
  padding: 6px;
}
#clearPopup button {
  background: #444;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 32px;
  font-size: 1.2em;
  margin-top: 16px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: bold;
  height: auto;
  line-height: 1.2;
  box-sizing: border-box;
}
#clearPopup button:hover {
  background: #222;
}

/* X（Twitter）ロゴボタンのスタイル */
#tweetClearBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 32px;
  font-size: 1.2em;
  margin-top: 16px;
  margin-bottom: 0;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: bold;
  height: auto;
  line-height: 1.2;
  box-sizing: border-box;
  vertical-align: top;
}
#tweetClearBtn:hover {
  background: #333;
}
#tweetClearBtn:active {
  background: #222;
}
#tweetClearBtn svg {
  width: 1.2em;
  height: 1.2em;
  fill: currentColor;
  display: block;
  vertical-align: middle;
}

#noticePopup .popup-content {
  line-height: 1.8;
  margin-left: 8px;
  margin-right: 8px;
}
#noticePopup button {
  font-size: 1.15em;
  padding: 10px 32px;
  border-radius: 6px;
  background: #888;
  color: #fff;
  border: none;
  margin-top: 16px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}
#noticePopup button:hover {
  background: #444;
}

/* Canvas書き込み用スタイル */
#puzzleCanvasContainer {
  max-width: 540px;
  width: 100%;
  margin: 0 auto 24px auto;
  position: relative;
  text-align: center;
}

#puzzleCanvasBg {
  display: block;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-radius: 12px;
  pointer-events: none;
}

#puzzleCanvas {
  display: block;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
  position: relative;
  z-index: 1;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: crosshair;
}

.canvas-controls {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-controls button {
  font-size: 1em;
  padding: 8px 24px;
  border-radius: 6px;
  border: none;
  background: #888;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.canvas-controls #penBtn {
  background: #222;
}

.canvas-controls button:hover {
  background: #666;
}

.canvas-controls #penBtn:hover {
  background: #000;
}

.canvas-controls button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* スマホ版: 「元に戻す」を2行目に表示 */
@media (max-width: 600px) {
  .canvas-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .canvas-controls #penBtn,
  .canvas-controls #eraserBtn,
  .canvas-controls #clearCanvasBtn {
    flex: 0 0 auto;
  }
  
  /* 「元に戻す」を2行目に表示し、消しゴムボタンと同じ幅にする */
  .canvas-controls #undoCanvasBtn {
    flex-basis: 100%;
    margin-top: 12px;
    width: 120px;
    max-width: 120px;
  }
  
  /* 消しゴムボタンの幅を固定 */
  .canvas-controls #eraserBtn {
    width: 120px;
  }
}

/* フッター */
footer {
  background: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 24px 16px;
  margin-top: 48px;
  text-align: center;
  color: #666;
  font-size: 0.9em;
}

footer p {
  margin: 8px 0;
  line-height: 1.6;
}

footer a {
  color: #222;
  text-decoration: none;
  border-bottom: 1px solid #ccc;
  transition: border-color 0.2s;
}

footer a:hover {
  border-bottom-color: #222;
}

