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

body {
  font-family: 'Hi Melody', cursive;
  background: #e8e4df;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  position: relative;
}

/* 화면 전환 */
.screen {
  display: none;
  width: 100%;
  min-height: 100dvh;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 노트북 배경 */
.notebook {
  width: 94%;
  min-height: 75dvh;
  background: #fff;
  border: 2px solid #333;
  border-radius: 4px;
  position: relative;
  box-shadow: 3px 3px 0 #bbb;
  background-image:
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      #d4e4f7 31px,
      #d4e4f7 32px
    );
  background-position: 0 20px;
  overflow: hidden;
}

.notebook::before {
  content: '';
  position: absolute;
  left: 32px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #f0a0a0;
  opacity: 0.4;
  z-index: 0;
}

.notebook-content {
  padding: 28px 16px 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

/* 제목 */
.title {
  font-size: 42px;
  color: #222;
  letter-spacing: 4px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.08);
  text-align: center;
  line-height: 1.3;
}

/* 말풍선 */
.speech-bubble {
  position: relative;
  background: #fff;
  border: 2px solid #333;
  border-radius: 18px;
  padding: 10px 16px;
  font-size: 18px;
  color: #333;
  max-width: 85%;
  text-align: center;
  align-self: center;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  margin-left: -8px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 4px solid transparent;
  border-top: 12px solid #333;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 50%;
  margin-left: -7px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 3px solid transparent;
  border-top: 10px solid #fff;
  z-index: 1;
}

.speech-bubble p {
  line-height: 1.4;
}

/* 스테퍼 */
.stepper {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 16px 0;
}

.stepper-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid #222;
  background: #222;
  color: #fff;
  font-size: 30px;
  font-family: 'Hi Melody', cursive;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.stepper-btn:active {
  transform: scale(0.92);
}

.stepper-value {
  width: 72px;
  height: 72px;
  border: 3px dashed #555;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  color: #e74c3c;
}

/* 버튼 */
.btn-main {
  font-family: 'Hi Melody', cursive;
  font-size: 24px;
  padding: 8px 28px;
  border: 2px dashed #333;
  background: transparent;
  color: #333;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn-main:active {
  background: #333;
  color: #fff;
}

.btn-sub {
  font-family: 'Hi Melody', cursive;
  font-size: 20px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: #888;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn-group {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* 입력 영역 */
.input-area {
  width: 100%;
}

.input-section-label {
  font-size: 22px;
  color: #555;
  margin-bottom: 8px;
  text-align: center;
}

.input-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.input-grid input {
  width: 70%;
  min-width: 0;
  font-family: 'Hi Melody', cursive;
  font-size: 18px;
  padding: 4px 6px;
  border: 2px dashed #aaa;
  border-radius: 4px;
  background: transparent;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.input-grid input:focus {
  border-color: #333;
}

/* 로딩 */
.loading-content {
  justify-content: center;
  min-height: 60vh;
}

.loading-pencil {
  animation: pencilDraw 1s ease-in-out infinite;
  text-align: center;
}

.pencil-icon {
  font-size: 48px;
}

@keyframes pencilDraw {
  0%, 100% { transform: translate(0, 0) rotate(-10deg); }
  25% { transform: translate(15px, 5px) rotate(5deg); }
  50% { transform: translate(30px, 0) rotate(-5deg); }
  75% { transform: translate(15px, -5px) rotate(10deg); }
}

.loading-text {
  font-size: 26px;
  color: #555;
}

/* 사다리 영역 */
.ladder-content {
  gap: 10px;
}

.ladder-wrapper {
  width: 100%;
  position: relative;
}

.ladder-names {
  display: flex;
  justify-content: space-around;
  width: 100%;
  padding: 0 4px;
  gap: 4px;
}

.ladder-name {
  font-size: 17px;
  text-align: center;
  padding: 5px 6px;
  border: 2px solid #333;
  border-radius: 4px;
  cursor: pointer;
  min-width: 0;
  flex: 1;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  background: #fff;
  word-break: keep-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ladder-name:active,
.ladder-name.active {
  background: #333;
  color: #fff;
}

.ladder-name.highlight {
  background: #e74c3c;
  color: #fff;
  border-color: #e74c3c;
}

#ladder-canvas {
  width: 100%;
  display: block;
  margin: 4px 0;
}

/* 결과 */
.result-title {
  font-size: 34px;
  color: #333;
  margin-bottom: 4px;
}

.result-list {
  width: 100%;
}

.result-item {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  padding: 8px 0;
  border-bottom: 1px dashed #ccc;
}

.result-item .name {
  font-weight: bold;
  color: #222;
}

.result-item .arrow {
  color: #aaa;
}

.result-item .prize {
  color: #e74c3c;
}

/* 모바일 소형 */
@media (max-width: 380px) {
  .notebook-content {
    padding: 24px 10px 20px 10px;
  }

  .title {
    font-size: 34px;
  }

  .speech-bubble {
    font-size: 16px;
    padding: 8px 12px;
  }

  .stepper-value {
    width: 60px;
    height: 60px;
    font-size: 36px;
  }

  .stepper-btn {
    width: 44px;
    height: 44px;
    font-size: 26px;
  }

  .ladder-name {
    font-size: 14px;
    padding: 4px 3px;
  }

  .input-grid input {
    font-size: 17px;
    padding: 5px 4px;
  }

  .btn-main {
    font-size: 20px;
    padding: 6px 20px;
  }

  .result-item {
    font-size: 20px;
  }
}
