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

body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 500px;
  padding: 30px;
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden {
  display: none !important;
}

h1 {
  color: #333;
  margin-bottom: 15px;
  font-size: 1.8em;
}

h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 1.5em;
}

.description {
  color: #666;
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.6;
}

.info-box {
  background: #f8f9fa;
  padding: 15px 25px;
  border-radius: 10px;
  margin-bottom: 25px;
}

.info-box p {
  color: #555;
  margin: 5px 0;
}

.btn {
  padding: 12px 30px;
  border: none;
  border-radius: 25px;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.3s;
}

.btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn.secondary {
  background: #e9ecef;
  color: #495057;
}

.btn.secondary:hover {
  background: #dee2e6;
}

.btn.small {
  padding: 8px 16px;
  font-size: 0.85em;
}

.btn.hint {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
}

.btn.hint:hover {
  background: #ffe69c;
}

/* Header & Progress */
.header {
  width: 100%;
  margin-bottom: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.9em;
  color: #666;
}

.timer-badge {
  background: #e9ecef;
  padding: 5px 12px;
  border-radius: 15px;
  font-weight: bold;
}

.timer-badge.warning {
  background: #f8d7da;
  color: #721c24;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.progress-bar {
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  transition: width 0.3s;
  width: 0%;
}

/* Question Area */
.question-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.prompt {
  text-align: center;
  margin-bottom: 20px;
}

.prompt-label {
  color: #666;
  font-size: 0.9em;
  margin-bottom: 8px;
}

.prompt-reading {
  font-size: 1.8em;
  color: #333;
  font-weight: bold;
  margin-bottom: 5px;
}

.prompt-meaning {
  color: #888;
  font-size: 0.9em;
}

/* Canvas */
.canvas-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 15px;
}

#writingCanvas {
  border: 3px solid #dee2e6;
  border-radius: 10px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

#writingCanvas.active {
  border-color: #667eea;
}

.canvas-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

/* Hint */
.hint-area {
  margin-bottom: 20px;
}

.hint-display {
  margin-top: 10px;
  padding: 10px;
  background: #fff3cd;
  border-radius: 10px;
  text-align: center;
}

.hint-char {
  font-size: 3em;
  color: #856404;
  opacity: 0.5;
}

/* Feedback */
.feedback-area {
  width: 100%;
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 15px;
  text-align: center;
}

.feedback-area.correct {
  background: #d4edda;
  color: #155724;
}

.feedback-area.incorrect {
  background: #f8d7da;
  color: #721c24;
}

.comparison-area {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 15px;
}

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

.comparison-item p {
  font-size: 0.85em;
  margin-bottom: 8px;
}

#userAnswerDisplay {
  border: 2px solid #dee2e6;
  border-radius: 8px;
  background: #fff;
}

.correct-char {
  display: inline-block;
  width: 100px;
  height: 100px;
  line-height: 100px;
  font-size: 4em;
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 8px;
}

/* Result Screen */
.result-summary {
  width: 100%;
  margin-bottom: 25px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.result-item.main {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.result-item.main .result-value {
  font-size: 1.5em;
}

.result-label {
  color: inherit;
}

.result-value {
  font-weight: bold;
}

.result-details {
  width: 100%;
  margin-bottom: 20px;
}

.result-details h3 {
  font-size: 1em;
  color: #666;
  margin-bottom: 10px;
}

.answer-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-item {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 1.5em;
}

.answer-item.correct {
  background: #d4edda;
  color: #155724;
}

.answer-item.incorrect {
  background: #f8d7da;
  color: #721c24;
}

.answer-item.hint-used {
  position: relative;
}

.answer-item.hint-used::after {
  content: '?';
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  background: #ffc107;
  color: #333;
  border-radius: 50%;
  font-size: 0.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.level-description {
  text-align: center;
  color: #666;
  font-size: 0.95em;
  line-height: 1.6;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 20px;
  }

  h1 {
    font-size: 1.5em;
  }

  .prompt-reading {
    font-size: 1.5em;
  }

  #writingCanvas {
    width: 240px;
    height: 240px;
  }
}
