* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; }
body {
  background: linear-gradient(135deg, #ffe4e6 0%, #fef3c7 50%, #ffedd5 100%);
  color: #431407;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", sans-serif;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100dvh;
}
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  background: #fffbeb;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(120, 53, 15, 0.16);
  border-left: 1px solid #fde68a;
  border-right: 1px solid #fde68a;
}
.top-brand-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px 6px;
  background: #ffffff;
}
.brand-logo { font-size: 16px; font-weight: 900; color: #431407; letter-spacing: -0.03em; }
.brand-logo span {
  background: linear-gradient(135deg, #f43f5e, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.guide-pill-btn {
  background: #fff1f2;
  border: 1.5px solid #fecdd3;
  color: #e11d48;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(244, 63, 94, 0.12);
}
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #ffffff;
  padding: 4px 12px 10px;
  gap: 8px;
  border-bottom: 1.5px solid #fde68a;
}
.mode-btn {
  padding: 8px 0;
  border: 1.5px solid #fed7aa;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 800;
  background: #fff7ed;
  color: #9a3412;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn.active {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  border-color: #e11d48;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}
.hud {
  padding: 9px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border-bottom: 1.5px solid #fde68a;
  z-index: 10;
}
.score-box {
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-radius: 12px;
  padding: 5px 11px;
  min-width: 106px;
}
.score-label { display: block; font-size: 9.5px; color: #b45309; font-weight: 800; letter-spacing: 0.6px; }
.score-val { display: block; font-size: 19px; font-weight: 900; color: #431407; font-variant-numeric: tabular-nums; margin-top: 1px; }
.combo-badge {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #ffffff;
  font-weight: 900;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.combo-badge.active { opacity: 1; transform: scale(1); }
.order-bar {
  margin: 10px 12px 0;
  padding: 10px 14px;
  background: #ffffff;
  border: 1.5px solid #fed7aa;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 6px 18px rgba(180, 83, 9, 0.07);
  z-index: 10;
}
.order-title { font-size: 13px; color: #78350f; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.core-tag {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #b45309;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  display: none;
}
.core-tag.show { display: inline-block; }
.order-count {
  background: #fff1f2;
  border: 1.5px solid #fecdd3;
  padding: 6px 11px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 900;
  color: #e11d48;
}
#canvas-wrap { position: relative; flex: 1; width: 100%; touch-action: none; }
canvas { display: block; width: 100%; height: 100%; }
.tray-section {
  padding: 10px 12px 14px;
  background: #ffffff;
  border-top: 1.5px solid #fde68a;
  z-index: 10;
}
.tray-header { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 800; color: #78350f; margin-bottom: 7px; }
.tray-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.slot {
  height: 48px;
  background: #fff7ed;
  border: 1.5px dashed #fdba74;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #d97706;
  transition: all 0.2s;
}
.slot.filled {
  background: #fff1f2;
  border: 1.5px solid #fb7185;
  color: #be123c;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(244, 63, 94, 0.16);
  padding: 4px 2px;
  gap: 2px;
}
.slot.danger { border-color: #e11d48; background: #ffe4e6; box-shadow: 0 0 12px rgba(225, 29, 72, 0.25); }
.slot-pct { font-size: 12px; font-weight: 900; line-height: 1.1; }
.slot-name { font-size: 9px; color: #881337; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-highlight-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 5px 11px;
  border-radius: 11px;
  background: #fff1f2;
  border: 1.5px solid #fb7185;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.target-highlight-box.pulse { transform: scale(1.06); }
.target-highlight-box.t-third { background: #fef3c7; border-color: #f59e0b; }
.target-highlight-box.t-quarter { background: #f3e8ff; border-color: #a855f7; }
.target-fraction { font-size: 11px; font-weight: 900; padding: 2px 7px; border-radius: 6px; background: #f43f5e; color: #ffffff; }
.t-third .target-fraction { background: #f59e0b; }
.t-quarter .target-fraction { background: #a855f7; }
.target-pct { font-size: 18px; font-weight: 900; color: #431407; letter-spacing: -0.02em; }
.target-mini-bar { width: 46px; height: 8px; background: rgba(120, 53, 15, 0.12); border-radius: 999px; overflow: hidden; }
.target-mini-fill { height: 100%; background: #f43f5e; transition: width 0.25s ease; }
.t-third .target-mini-fill { background: #f59e0b; }
.t-quarter .target-mini-fill { background: #a855f7; }
#overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 251, 235, 0.96);
  backdrop-filter: blur(10px);
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px 24px;
  text-align: center;
  z-index: 30;
  overflow-y: auto;
}
#overlay.show { display: flex; }
#cert-preview { width: 100%; max-width: 320px; border-radius: 16px; box-shadow: 0 12px 32px rgba(120, 53, 15, 0.18); margin-bottom: 12px; border: 2px solid #fde68a; }
.rank-box { width: 100%; max-width: 320px; background: #ffffff; border: 1.5px solid #fed7aa; border-radius: 14px; padding: 12px; margin-bottom: 12px; text-align: left; }
.rank-box h3 { font-size: 13px; color: #431407; font-weight: 900; margin-bottom: 8px; display: flex; justify-content: space-between; }
.rank-form { display: flex; gap: 6px; margin-bottom: 10px; }
.rank-input { flex: 1; background: #fff7ed; border: 1.5px solid #fdba74; border-radius: 9px; padding: 8px 10px; color: #431407; font-size: 13px; user-select: text; -webkit-user-select: text; }
.rank-submit { background: #f43f5e; color: #ffffff; border: none; border-radius: 9px; padding: 0 12px; font-weight: 800; font-size: 12px; cursor: pointer; }
.rank-list { list-style: none; font-size: 12px; max-height: 150px; overflow-y: auto; color: #78350f; }
.rank-item { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid #fef3c7; }
.rank-item strong { color: #e11d48; }
.btn-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 320px; margin-bottom: 8px; }
.btn { width: 100%; max-width: 320px; padding: 13px; border: none; border-radius: 13px; font-size: 14px; font-weight: 900; cursor: pointer; color: #ffffff; box-shadow: 0 4px 12px rgba(120, 53, 15, 0.15); }
.btn-primary { background: linear-gradient(135deg, #fb7185, #e11d48); }
.btn-share { background: linear-gradient(135deg, #f59e0b, #d97706); }
.btn-save { background: #78350f; }
.modal-backdrop { position: fixed; inset: 0; z-index: 999; background: rgba(67, 20, 7, 0.45); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; padding: 18px; }
.modal-backdrop.show { display: flex; }
.modal-card { width: 100%; background: #ffffff; border: 2px solid #fde68a; border-radius: 22px; padding: 22px; box-shadow: 0 24px 60px rgba(67, 20, 7, 0.22); color: #431407; }
.guide-step { display: flex; align-items: center; gap: 12px; background: #fff7ed; border: 1.5px solid #fed7aa; border-radius: 14px; padding: 9px 11px; margin-bottom: 9px; }
.guide-illus { flex: 0 0 72px; display: flex; align-items: center; justify-content: center; }
.guide-desc { display: flex; flex-direction: column; gap: 2px; font-size: 12px; line-height: 1.4; color: #78350f; }
.guide-desc strong { font-size: 13.5px; color: #431407; }
.guide-desc b { color: #e11d48; }
