/* =============================================
   키보드 연습 — 스타일시트
   ES5 + Safari 11 호환 (flexbox, CSS Grid 의존)
   ============================================= */

/* ===== 리셋 ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f6f8;
  color: #1d1d1f;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

body {
  display: flex;
  flex-direction: column;
}

/* ===== 앱 메인 레이아웃 ===== */
#app {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* ===== 메뉴 (1/5) ===== */
#menu {
  flex: 1 1 0;
  display: flex;
  flex-direction: row;
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
  padding: 10px;
  gap: 8px;
  border-bottom: 1px solid #2d5d8f;
}

.menu-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  color: #1d1d1f;
  transition: background 0.15s, transform 0.05s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  min-height: 0;
  padding: 8px 4px;
}

.menu-item:hover {
  background: #ffffff;
}

.menu-item:active {
  transform: translateY(1px);
}

.menu-item.active {
  background: #ffd54f;
  box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.4), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.menu-num {
  font-size: 1.4em;
  font-weight: 700;
  color: #4a90e2;
  line-height: 1;
  margin-bottom: 4px;
}

.menu-item.active .menu-num {
  color: #b88500;
}

.menu-text {
  font-size: 1em;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
}

/* ===== 출력 영역 (2/5) ===== */
#output {
  flex: 2 1 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d1d5da;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.hint {
  font-size: 1.4em;
  color: #8e8e93;
  text-align: center;
}

/* ===== 거대 키 (출력 영역에 표시) ===== */
.output-big-key {
  background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
  border: 3px solid #888;
  border-radius: 16px;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.05),
    0 8px 16px rgba(0, 0, 0, 0.15),
    inset 0 -4px 0 rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px 28px;
  height: 75%;
  max-height: 200px;
  width: max-content;
  white-space: nowrap;
  box-sizing: border-box;
}

.output-big-key .label-en {
  font-size: 5em;
  font-weight: 700;
  color: #1d1d1f;
  line-height: 1;
  margin-bottom: 12px;
}

.output-big-key .label-ko {
  font-size: 2.4em;
  font-weight: 500;
  color: #4a4a4f;
  line-height: 1;
}

.output-big-key.compact .label-en {
  font-size: 3em;
  margin-bottom: 8px;
}

.output-big-key.compact .label-ko {
  font-size: 1.4em;
}

/* ===== 받아쓰기 영역 ===== */
.typing-area {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 90%;
  height: 100%;
  gap: 16px;
}

.typing-hidden-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 10;
  cursor: default;
}

.typing-target {
  font-size: 3em;
  font-weight: 600;
  color: #8e8e93;
  text-align: center;
  letter-spacing: 2px;
  padding: 12px;
  border-bottom: 2px dashed #d1d5da;
  width: 100%;
  min-height: 1.2em;
}

.typing-input-wrapper {
  position: relative;
  font-size: 3em;
  font-weight: 600;
  color: #1d1d1f;
  text-align: center;
  letter-spacing: 2px;
  min-height: 1.2em;
  width: 100%;
}

.typing-input {
  display: inline;
}

.typing-input .correct {
  color: #1d1d1f;
}

.typing-input .wrong {
  color: #d93838;
  background: #ffe8e8;
  text-decoration: underline;
}

.cursor {
  display: inline-block;
  width: 4px;
  height: 1em;
  background: #1d1d1f;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to { visibility: hidden; }
}

.typing-hint {
  font-size: 0.95em;
  color: #a0a0a8;
  margin-top: 8px;
}

/* ===== 결과 배너 ===== */
.result-banner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  text-align: center;
}

.result-banner.pass {
  color: #2e8b57;
}

.result-banner.fail {
  color: #c0392b;
}

.result-title {
  font-size: 2.4em;
  font-weight: 700;
  margin-bottom: 12px;
}

.result-detail {
  font-size: 1.4em;
  color: #4a4a4f;
  margin-bottom: 8px;
}

.result-next {
  font-size: 0.9em;
  color: #8e8e93;
  margin-top: 16px;
}

/* ===== 키보드 (2/5) ===== */
#keyboard {
  flex: 2 1 0;
  background: #ffffff;
  border-top: 1px solid #d1d5da;
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  position: relative;
}

.keyboard-body {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  grid-auto-flow: dense;
  gap: 4px;
  max-width: 100%;
}

.key {
  background: linear-gradient(180deg, #3a3a3e 0%, #2c2c30 100%);
  border: 1px solid #18181a;
  border-radius: 6px;
  color: #f0f0f0;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  padding: 2px 4px;
  user-select: none;
  transition: background 0.05s ease, transform 0.05s ease, box-shadow 0.05s ease;
  margin: 0;
  box-shadow:
    0 3px 0 #18181a,
    0 4px 6px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.key:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #18181a,
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.key.pressed {
  background: linear-gradient(180deg, #5dade2 0%, #2e86c1 100%);
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #1b4f72,
    0 0 8px rgba(93, 173, 226, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.key.target {
  background: linear-gradient(180deg, #f39c12 0%, #d68910 100%);
  box-shadow:
    0 3px 0 #935116,
    0 0 10px rgba(243, 156, 18, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.key.target.pressed {
  background: linear-gradient(180deg, #5dade2 0%, #2e86c1 100%);
}

.key .label-en {
  font-size: 0.95em;
  font-weight: 600;
  line-height: 1.1;
}

.key .label-ko {
  font-size: 0.7em;
  color: #bdc3c7;
  line-height: 1;
  margin-top: 1px;
}

.key.key-modifier {
  background: linear-gradient(180deg, #2e2e32 0%, #222225 100%);
  font-size: 0.85em;
}

.key.key-function {
  background: linear-gradient(180deg, #2b2b2e 0%, #1f1f22 100%);
  font-size: 0.7em;
  color: #d0d0d0;
}

.key.key-space {
  width: auto !important;
}

/* ===== 메모장 ===== */
.memo-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #8e8e93;
}

.memo-placeholder h2 {
  font-size: 1.8em;
  color: #4a4a4f;
  margin-bottom: 12px;
}

.memo-placeholder p {
  font-size: 1.05em;
}

/* ===== 진행 표시 ===== */
.tier-progress {
  position: absolute;
  top: 8px;
  right: 12px;
  background: rgba(0, 0, 0, 0.05);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #4a4a4f;
  font-weight: 500;
}

/* ===== 작은 화면 경고 ===== */
.warning-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(245, 246, 248, 1);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.warning-card {
  background: white;
  border-radius: 12px;
  padding: 32px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid #d1d5da;
}

.warning-card h2 {
  font-size: 1.4em;
  margin-bottom: 12px;
  color: #1d1d1f;
}

.warning-card p {
  font-size: 1em;
  line-height: 1.6;
  color: #4a4a4f;
}

/* ===== 키보드 영역 최소 높이 보장 ===== */
@media (min-width: 1024px) {
  /* 1024px 이상에서만 정상 동작 */
}

/* ===== 타이포그래피 폴백 ===== */
.label-en, .label-ko, .typing-target, .typing-input-wrapper {
  font-family: 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
}
