html, body {
  margin: 0;
  background: #f8f5ee;
  font-family: 'Trebuchet MS', 'Avenir Next', sans-serif;
}

.cursive-wrap {
  width: min(800px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.cursive-header {
  text-align: center;
  margin-bottom: 24px;
}

.cursive-header h1 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  font-weight: 900;
  color: #1f2430;
  margin: 0 0 6px;
}

.pen-icon {
  display: inline-block;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-6px) rotate(-5deg); }
}

.cursive-header p {
  color: #5a6272;
  margin: 0;
  font-size: 1rem;
}

.cursive-input-area {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(31, 36, 48, 0.08);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 14px 34px rgba(31, 36, 48, 0.08);
  margin-bottom: 20px;
}

.cursive-input-area label {
  display: block;
  font-weight: 800;
  color: #1f2430;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.cursive-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.cursive-input-row input {
  flex: 1;
  min-width: 180px;
  padding: 12px 16px;
  border: 2px solid rgba(31, 36, 48, 0.12);
  border-radius: 14px;
  font-size: 1.1rem;
  font-family: 'Trebuchet MS', 'Avenir Next', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  background: white;
}

.cursive-input-row input:focus {
  border-color: #0f766e;
}

.cursive-input-row button {
  padding: 12px 24px;
  border-radius: 14px;
  border: none;
  font-weight: 900;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.cursive-input-row button:active {
  transform: scale(0.96);
}

.cursive-input-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #1f2430;
  color: white;
  box-shadow: 0 6px 16px rgba(31, 36, 48, 0.18);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: #1f2430;
  border: 1px solid rgba(31, 36, 48, 0.12);
}

.canvas-area {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(31, 36, 48, 0.08);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 14px 34px rgba(31, 36, 48, 0.08);
  position: relative;
  overflow: hidden;
  min-height: 250px;
}

.canvas-area svg {
  display: block;
  width: 100%;
  height: auto;
}

.font-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5a6272;
  font-weight: 700;
  font-size: 1rem;
}

.guideline {
  stroke: rgba(31, 36, 48, 0.08);
  stroke-width: 1;
}

.guideline-dash {
  stroke: rgba(31, 36, 48, 0.05);
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

.ghost-text {
  font-family: 'Dancing Script', cursive;
  font-size: 100px;
  fill: rgba(31, 36, 48, 0.12);
}

.main-text {
  font-family: 'Dancing Script', cursive;
  font-size: 100px;
  fill: #1f2430;
}

.pen-nib {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
  animation: nib-glow 1s ease-in-out infinite;
}

@keyframes nib-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.controls-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.controls-row button {
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid rgba(31, 36, 48, 0.12);
  background: white;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}

@media (hover: hover) {
  .controls-row button:hover:not(:disabled) {
    background: #f1f5f9;
  }
}

.controls-row button:active:not(:disabled) {
  transform: scale(0.95);
}

.controls-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.speed-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: #5a6272;
  font-size: 0.85rem;
}

.speed-icon {
  font-size: 1.1rem;
}

.speed-text {
  width: 6ch;
  text-align: center;
}

.speed-label input[type="range"] {
  width: 90px;
  accent-color: #0f766e;
}

.letter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 16px;
}

.letter-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid rgba(31, 36, 48, 0.1);
  background: white;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  color: #1f2430;
  font-family: 'Dancing Script', cursive;
}

@media (hover: hover) {
  .letter-btn:hover:not(:disabled) {
    background: #f1f5f9;
    transform: scale(1.08);
  }
}

.letter-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.letter-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .cursive-input-row {
    flex-direction: column;
  }
  .cursive-input-row input {
    width: 100%;
    min-width: 0;
  }
  .cursive-input-row button {
    width: 100%;
  }
}
