* { box-sizing: border-box; }

body {
  font-family: 'Apple SD Gothic Neo', sans-serif;
  background: #000;
  padding: 40px 20px 80px;
  color: #333;
  margin: 0;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  background: #000;
  padding: 0px;
  min-height: 700px;
}

h2 {
  text-align: center;
  margin-bottom: 30px;
  color: #507bff;
}

/* ── 계산기 컨테이너 ── */
#calculators-container {
  display: flex;
  justify-content: center;
}

/* ── 계산기 박스 ── */
.calculator-wrapper {
  width: 100%;
  max-width: 780px;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 24px;
  background: #fefefe;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* ── 입력 행 ── */
.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* 토글 버튼 */
.toggle-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px;
  height: 42px;
  border: none;
  border-radius: 21px;
  background: linear-gradient(135deg, #507bff, #3a66e0);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(80,123,255,0.35);
  transition: box-shadow 0.15s, transform 0.1s;
}
.toggle-mode-btn::before { content: none; }
.toggle-mode-btn::after  { content: attr(data-label); }
.toggle-mode-btn:hover {
  box-shadow: 0 5px 16px rgba(80,123,255,0.5);
  transform: translateY(-1px);
}

/* 버튼 내부 아이콘 이미지 */
.toggle-btn-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 4px;
  pointer-events: none;
}

/* 결과 헤더 아이콘 */
.result-title-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 4px;
}

.input-mode { display: flex; align-items: center; gap: 8px; }

.input-mode input {
  height: 42px;
  padding: 0 14px;
  font-size: 15px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  width: 280px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-mode input:focus {
  outline: none;
  border-color: #507bff;
  box-shadow: 0 0 0 3px rgba(80,123,255,0.15);
}

.input-suffix {
  font-size: 14px;
  color: #555;
  white-space: nowrap;
}

/* ── 아이템 그리드 ── */
.item-grid-wrap { margin-bottom: 16px; }

.item-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

@media (max-width: 640px) {
  .item-grid { grid-template-columns: repeat(3, 1fr); }
  .input-mode input { width: 180px; }
}

.item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px 10px;
  border: 2px solid #d8d8d8;
  border-radius: 12px;
  background: #f8f8f8;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
  text-align: center;
  user-select: none;
  position: relative;
}
.item-card:hover {
  border-color: #507bff;
  background: #eef2ff;
  box-shadow: 0 3px 10px rgba(80,123,255,0.18);
  transform: translateY(-2px);
}
.item-card.selected {
  border-color: #507bff;
  background: #dce6ff;
  box-shadow: 0 3px 14px rgba(80,123,255,0.3);
}
.item-card img { width: 48px; height: 48px; object-fit: contain; pointer-events: none; }
.item-card-name {
  font-size: 11px;
  font-weight: 700;
  color: #222;
  line-height: 1.3;
  word-break: keep-all;
  pointer-events: none;
}
.item-card-cost { font-size: 10px; color: #888; pointer-events: none; }

/* 수량 조절 */
.item-card-qty {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.item-card.selected .item-card-qty { display: flex; }

.qty-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #507bff;
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.12s;
}
.qty-btn:hover { background: #3a66e0; }
.qty-val {
  font-size: 13px;
  font-weight: 700;
  color: #333;
  min-width: 18px;
  text-align: center;
}

/* ── 계산 버튼 ── */
.calc-btn {
  width: 100%;
  padding: 13px;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #507bff, #3a66e0);
  color: #fff;
  cursor: pointer;
  margin-top: 4px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 3px 12px rgba(80,123,255,0.3);
  transition: box-shadow 0.15s, transform 0.1s;
}
.calc-btn:hover {
  box-shadow: 0 5px 18px rgba(80,123,255,0.45);
  transform: translateY(-1px);
}

.error-msg {
  color: #d9534f;
  font-weight: 700;
  min-height: 20px;
  margin: 6px 0 0;
  font-size: 13px;
}

.error-msg-large {
  display: block;
  font-size: 18px;
  font-weight: 900;
  color: #d9534f;
  background: #fff0f0;
  border: 2px solid #d9534f;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 4px;
  letter-spacing: 0.2px;
}

/* ── 결과 박스 ── */
.result-box {
  margin-top: 16px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dce3ff;
  background: #fff;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #507bff, #3a66e0);
  padding: 11px 16px;
}
.result-title { font-size: 15px; font-weight: 700; color: #fff; }
.result-mode-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  color: #fff;
}
.badge-coin { background: rgba(255,255,255,0.25); }
.badge-meso { background: #e07b00; }

/* 결과 행 */
.result-rows { padding: 4px 0; }

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #eef0f8;
  gap: 12px;
}
.result-row:last-child { border-bottom: none; }

.result-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.result-item-img { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.result-item-name { font-size: 13px; font-weight: 700; color: #2c3e7a; margin-bottom: 4px; }

.result-row-meta {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.meta-chip {
  font-size: 10px;
  background: #eef2ff;
  color: #507bff;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.result-row-meso {
  font-size: 16px;
  font-weight: 900;
  color: #e07b00;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 합계 행 */
.result-grand-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: linear-gradient(135deg, #2c3e7a, #507bff);
  font-weight: 700;
  color: #fff;
}
.result-grand-total span:first-child { font-size: 14px; }
.result-grand-total span:last-child  { font-size: 22px; color: #ffe97a; font-weight: 900; }

/* ── 비율 결과 오른쪽 강조 텍스트 ── */
.result-row-ratio {
  font-size: 20px;
  font-weight: 900;
  color: #e07b00;
  white-space: nowrap;
  flex-shrink: 0;
}

.guide-text {
  width: 100%;
  max-width: 780px;
  margin: 20px auto 0;
  padding: 22px 28px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  font-size: 14px;
  color: #444;
}
.guide-text strong p {
  font-size: 17px;
  color: #ff0000;
  margin: 0 0 10px;
}
.guide-text ul {
  margin: 0;
  padding-left: 20px;
  color: #555;
}
.guide-text ul li { margin-bottom: 7px; line-height: 1.7; }
